X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=initchroot.sh;h=7edff438896ef27132e7a378de668c747510d47d;hb=36debc0ac2eddcc52f2d605f4dd06530091c4664;hp=322abe4ad6e595af8b2b06618afff574ee370ef4;hpb=124ffe2803c6dc8c3288eee04f2dcf81588fac51;p=xodist diff --git a/initchroot.sh b/initchroot.sh index 322abe4..7edff43 100755 --- a/initchroot.sh +++ b/initchroot.sh @@ -16,25 +16,69 @@ # 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 +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() { echo "" 1>&2 - echo "Usage: $0 " 1>&2 + echo "Usage: $0 [] " 1>&2 + echo "" 1>&2 + echo "Options:" 1>&2 + echo " --user Username for default user" 1>&2 + echo " --package-list File containing package list" 1>&2 + echo " --apt-sources Contents of /etc/apt/sources.list" 1>&2 + echo " --local-apt-mirror sources.list for local mirror" 1>&2 echo "" 1>&2 exit 1 } -if [ "$#" != "1" ]; then +while test $# != 0 +do + case $1 in + --user) + DEFUSER=$2 + shift + ;; + --package-list) + PLIST=$2 + [ -f ${PLIST} ] || { + echo "Error: can't find file '${PLIST}'!" 1>&2 + exit 2 + } + shift + ;; + --apt-sources) + APT_SOURCES="$2" + shift + ;; + --local-apt-mirror) + LOCAL_APT_MIRROR="$2" + shift + ;; + *) + if [ "$#" != "1" ]; then + echo "Unknown option $1" 1>&2 + usage + else + ROOT_DIR="$1" + fi + ;; + esac + shift +done + +if [ "$ROOT_DIR" = "" ]; then + echo "" 1>&2 + echo "*** No root directory specified!" 1>&2 usage fi -ROOT_DIR=$1 - if [ -d "${ROOT_DIR}" ]; then echo "" 1>&2 echo "*** ${ROOT_DIR} already exists!" 1>&2 @@ -43,10 +87,19 @@ fi check_for_cmds debootstrap || exit 1 +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 lenny ${ROOT_DIR} http://http.us.debian.org/debian -mount -t proc proc ${ROOT_DIR}/proc -mount -t devpts devpts ${ROOT_DIR}/dev/pts +debootstrap --arch i386 ${DIST} ${ROOT_DIR} ${MIRROR} +mkdir ${ROOT_DIR}/ofw +mkdir ${ROOT_DIR}/var/cache/apt/cache +chroot_internal_mounts ${ROOT_DIR} # allow daemons to be installed without breaking mv ${ROOT_DIR}/sbin/start-stop-daemon ${ROOT_DIR}/sbin/start-stop-daemon.REAL @@ -57,32 +110,72 @@ echo "Warning: Fake start-stop-daemon called, doing nothing" EOF chmod 755 ${ROOT_DIR}/sbin/start-stop-daemon -# set up apt +# set up hostname stuff +echo "debxo" > ${ROOT_DIR}/etc/hostname +cat >${ROOT_DIR}/etc/hosts<${ROOT_DIR}/etc/apt/apt.conf<${ROOT_DIR}/etc/apt/sources.list<${ROOT_DIR}/etc/apt/sources.list (chroot ${ROOT_DIR} aptitude update) -# set up base system +# set up base system and base packages echo "en_US.UTF-8 UTF-8" >${ROOT_DIR}/etc/locale.gen -(chroot ${ROOT_DIR} aptitude install -y locales) -k=$(wget -O- http://queued.mit.edu/~dilinger/builds-master/ | sed -ne 's/.*href="\(.\+\)_i386.deb".*/\1_i386.deb/p' | tail -n1) -wget -O ${ROOT_DIR}/${k} http://queued.mit.edu/~dilinger/builds-master/${k} -(chroot ${ROOT_DIR} dpkg -i /${k}) -rm -f ${ROOT_DIR}/${k} +(chroot ${ROOT_DIR} aptitude install -y `cat base.packages`) + +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" +mkdir -p cache +for i in $k; do + pkg=$(basename ${i}) + wget --continue -O cache/${pkg} ${i} + cp cache/${pkg} ${ROOT_DIR}/${pkg} + (chroot ${ROOT_DIR} dpkg -i /${pkg}) + pkgbase=$(echo $pkg | cut -d_ -f1) + echo $pkgbase hold | (chroot ${ROOT_DIR} dpkg --set-selections) + rm -f ${ROOT_DIR}/${pkg} +done + +# ensure certain modules get loaded during boot +cat >>${ROOT_DIR}/etc/modules<${ROOT_DIR}/etc/X11/xorg.conf<${ROOT_DIR}/etc/X11/xorg.conf<${ROOT_DIR}/etc/gconf/2/local-defaults.path<> ${ROOT_DIR}/etc/sudoers +(chroot ${ROOT_DIR} adduser ${DEFUSER} floppy) +echo "${DEFUSER} ALL=(ALL) NOPASSWD: ALL" >> ${ROOT_DIR}/etc/sudoers + +# add local network interface +cat >>${ROOT_DIR}/etc/network/interfaces<> ${ROOT_DIR}/home/${DEFUSER}/.Xsession <<- EOF +matchbox-window-manager -use_titlebar no & +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) -umount ${ROOT_DIR}/proc -umount ${ROOT_DIR}/dev/pts +chroot_internal_umounts ${ROOT_DIR}