]> spindle.queued.net Git - xodist/blobdiff - initchroot.sh
drop kdm/gdm, use autox instead
[xodist] / initchroot.sh
index 081801596eba66d53c2632c120989fb294688c1a..6a5239e6743eebf11264fdfe485e08c8a3e9514a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
 #
 # Copyright © 2008  Andres Salomon <dilinger@queued.net>
 #
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-DIST=lenny
 DEFUSER=olpc
 PLIST=gnome.packages
-MIRROR=http://http.us.debian.org/debian/
-OTHERMIRROR=
+APT_SOURCES="deb http://http.us.debian.org/debian/ lenny main contrib non-free
+deb http://security.debian.org/ lenny/updates main contrib non-free"
+LOCAL_APT_MIRROR=
 
-. functions.sh
+. ./functions.sh
 
 usage()
 {
@@ -30,11 +30,10 @@ usage()
        echo "Usage: $0 [<options>] <root directory>" 1>&2
        echo "" 1>&2
        echo "Options:" 1>&2
-       echo "  --distribution <name>     Which distribution to use" 1>&2
        echo "  --user <user>             Username for default user" 1>&2
        echo "  --package-list <list>     File containing package list" 1>&2
-       echo "  --mirror <url>            Main Mirror URL prefix" 1>&2
-       echo "  --othermirror <line>      An additional sources.list line" 1>&2
+       echo "  --apt-sources <srcs>      Contents of /etc/apt/sources.list" 1>&2
+       echo "  --local-apt-mirror <srcs> sources.list for local mirror" 1>&2
        echo "" 1>&2
        exit 1
 }
@@ -42,13 +41,6 @@ usage()
 while test $# != 0
 do
        case $1 in
-       --distribution)
-               DIST=$2
-               shift
-               if [ -z "${OTHERMIRROR}" ]; then
-                   OTHERMIRROR="deb http://security.debian.org/ ${DIST}/updates main contrib non-free"
-               fi
-               ;;
        --user)
                DEFUSER=$2
                shift
@@ -61,12 +53,12 @@ do
                }
                shift
                ;;
-       --mirror)
-               MIRROR=$2
+       --apt-sources)
+               APT_SOURCES="$2"
                shift
                ;;
-       --othermirror)
-               OTHERMIRROR=$2
+       --local-apt-mirror)
+               LOCAL_APT_MIRROR="$2"
                shift
                ;;
        *)
@@ -93,12 +85,18 @@ if [ -d "${ROOT_DIR}" ]; then
        usage
 fi
 
+start_logging $ROOT_DIR
+
 check_for_cmds debootstrap || exit 1
 
-if [ -z "${OTHERMIRROR}" ]; then
-    OTHERMIRROR="deb http://security.debian.org/ ${DIST}/updates main contrib non-free"
+if [ -z "${LOCAL_APT_MIRROR}" ]; then
+    LOCAL_APT_MIRROR="${APT_SOURCES}"
 fi
 
+# parse apt mirror
+MIRROR=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $2}' | head -n1)
+DIST=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $3}' | head -n1)
+
 # create chroot
 debootstrap --arch i386 ${DIST} ${ROOT_DIR} ${MIRROR}
 mkdir ${ROOT_DIR}/ofw
@@ -114,6 +112,21 @@ echo "Warning: Fake start-stop-daemon called, doing nothing"
 EOF
 chmod 755 ${ROOT_DIR}/sbin/start-stop-daemon
 
+# set up hostname stuff
+echo "debxo" > ${ROOT_DIR}/etc/hostname
+cat >${ROOT_DIR}/etc/hosts<<EOF
+127.0.0.1 localhost.localdomain localhost
+127.0.0.1 debxo
+
+# The following lines are desirable for IPv6 capable hosts
+::1     ip6-localhost ip6-loopback
+fe00::0 ip6-localnet
+ff00::0 ip6-mcastprefix
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+ff02::3 ip6-allhosts
+EOF
+
 # set up apt (working around #314334)
 export DEBIAN_FRONTEND=noninteractive
 export DEBCONF_PRIORITY=critical
@@ -127,10 +140,7 @@ Dir {
        };
 };
 EOF
-cat >${ROOT_DIR}/etc/apt/sources.list<<EOF
-deb ${MIRROR} ${DIST} main contrib non-free
-${OTHERMIRROR}
-EOF
+printf "${LOCAL_APT_MIRROR}\n" >${ROOT_DIR}/etc/apt/sources.list
 (chroot ${ROOT_DIR} aptitude update)
 
 # set up base system and base packages
@@ -139,7 +149,9 @@ echo "en_US.UTF-8 UTF-8" >${ROOT_DIR}/etc/locale.gen
 
 k="http://lunge.mit.edu/~dilinger/debxo-0.2/initramfs-tools_0.92l.2_all.deb 
  http://lunge.mit.edu/~dilinger/debxo-0.2/ofw-config_0.1_all.deb 
- http://lunge.mit.edu/~dilinger/debxo-0.3/linux-2.6.25.15_2.6.25.15-147_i386.deb"
+ http://lunge.mit.edu/~dilinger/debxo-0.4/linux-2.6.25.15_2.6.25.15-165_i386.deb 
+ http://lunge.mit.edu/~dilinger/debxo-0.5/xserver-xorg-video-geode_2.11.0-0.3_i386.deb 
+ http://lunge.mit.edu/~dilinger/debxo-0.5/autox_0.1_all.deb"
 mkdir -p cache
 for i in $k; do
        pkg=$(basename ${i})
@@ -150,6 +162,10 @@ for i in $k; do
        echo $pkgbase hold | (chroot ${ROOT_DIR} dpkg --set-selections)
        rm -f ${ROOT_DIR}/${pkg}
 done
+# take the geode driver off hold
+echo xserver-xorg-video-geode install | (chroot ${ROOT_DIR} dpkg --set-selections)
+# take autox off hold
+echo autox install | (chroot ${ROOT_DIR} dpkg --set-selections)
 
 # ensure certain modules get loaded during boot
 cat >>${ROOT_DIR}/etc/modules<<EOF
@@ -158,59 +174,27 @@ fbcon
 olpc_dcon
 scx200_acb
 i8042
-EOF
-
-echo "debxo" > ${ROOT_DIR}/etc/hostname
-cat >${ROOT_DIR}/etc/hosts<<EOF
-127.0.0.1 localhost.localdomain localhost
-127.0.0.1 debxo
-
-# The following lines are desirable for IPv6 capable hosts
-::1     ip6-localhost ip6-loopback
-fe00::0 ip6-localnet
-ff00::0 ip6-mcastprefix
-ff02::1 ip6-allnodes
-ff02::2 ip6-allrouters
-ff02::3 ip6-allhosts
+olpc_battery
+msr
 EOF
 
 # install packages
-(chroot ${ROOT_DIR} aptitude install -y `cat ${PLIST}`)
+(chroot ${ROOT_DIR} aptitude install -y `grep --invert-match '^#' ${PLIST}`)
 
-# configure X
-if [ -d ${ROOT_DIR}/etc/X11 ]; then
-    cat >${ROOT_DIR}/etc/X11/xorg.conf<<EOF
-# xorg.conf (X.Org X Window System server configuration file)
+# no longer a need for xorg.conf
+rm -f ${ROOT_DIR}/etc/X11/xorg.conf
 
-Section "Monitor"
-       Identifier "Configured Monitor"
-       HorizSync 30-67
-       VertRefresh 48-52
-       DisplaySize 152 114
-       Mode "1200x900"
-               DotClock 57.275
-               HTimings 1200 1208 1216 1240
-               VTimings 900 905 908 912
-               Flags "-HSync" "-VSync"
-       EndMode
-EndSection
-
-Section "Screen"
-       Identifier "Default Screen"
-       Monitor "Configured Monitor"
-EndSection
-EOF
+# key bindings/mappings
+if [ -d ${ROOT_DIR}/usr/share/hal/fdi/information/10freedesktop/ ]; then
+    cp 30-keymap-olpc.fdi ${ROOT_DIR}/usr/share/hal/fdi/information/10freedesktop/
 fi
 
-# configure kdm, kde
-if [ -d ${ROOT_DIR}/etc/kde3/kdm ]; then
-    sed --in-place "s/AllowNullPasswd=false/AllowNullPasswd=true/;s/#AutoLoginEnable=true/AutoLoginEnable=true/;s/#AutoLoginUser=fred/AutoLoginUser=${DEFUSER}/" ${ROOT_DIR}/etc/kde3/kdm/kdmrc
+# configure autox
+if [ -f ${ROOT_DIR}/etc/default/autox ]; then
+    sed --in-place "s/USER=$/USER=${DEFUSER}/" ${ROOT_DIR}/etc/default/autox
 fi
 
-# configure gdm, gnome
-if [ -d ${ROOT_DIR}/etc/gdm ]; then
-    sed -i "s_\[daemon\]_\[daemon\]\n\nGreeter=/usr/lib/gdm/gdmlogin\n\nAutomaticLoginEnable=true\n\nAutomaticLogin=${DEFUSER}_" ${ROOT_DIR}/etc/gdm/gdm.conf
-fi
+# configure gnome
 if [ -d ${ROOT_DIR}/etc/gconf/2 ]; then
     cat >${ROOT_DIR}/etc/gconf/2/local-defaults.path<<EOF
 # DebXO defaults (customized for the XO-1's display
@@ -251,6 +235,21 @@ sugar
 EOF
 fi
 
+# run any local postinstall scripts for the build
+PLIST_DIR=${PLIST/.packages/}
+if [ -d ${PLIST_DIR} ]; then
+    if [ -x ${PLIST_DIR}/postinst.sh ]; then
+       ${PLIST_DIR}/postinst.sh ${ROOT_DIR}
+    fi
+    if [ -x ${PLIST_DIR}/postinst-local.sh ]; then
+       ${PLIST_DIR}/postinst-local.sh ${ROOT_DIR}
+    fi
+fi
+
+# override sources.list with shipping version
+printf "${APT_SOURCES}\n" >${ROOT_DIR}/etc/apt/sources.list
+(chroot ${ROOT_DIR} aptitude update)
+
 # done, clean up
 mv ${ROOT_DIR}/sbin/start-stop-daemon.REAL ${ROOT_DIR}/sbin/start-stop-daemon
 (chroot ${ROOT_DIR} aptitude clean)