From: James Cameron Date: Thu, 28 Aug 2008 05:59:26 +0000 (+1000) Subject: Add --distribution option to choose which distribution of Debian to use. X-Git-Tag: v0.2~35 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1796af4d2969fd3eb0f0d6dd218e2090ef911bd3;p=xodist Add --distribution option to choose which distribution of Debian to use. Add --user option to specify username to create, default olpc. Add --mirror option to allow a local package mirror to be used, tested to work with the approx package. Add --othermirror optioin to allow an addition sources.list line. Add --package-list option. Move chroot mount and umount to functions for shell use. Add package lists for lxde and kde. Cache the kernel package. Only configure xorg.conf, Gnome, or KDE files if they are present. Add user to the floppy group for thumb drive use. --- diff --git a/functions.sh b/functions.sh index 226b8b4..a166867 100644 --- a/functions.sh +++ b/functions.sh @@ -83,3 +83,19 @@ then boot EOF } + +chroot_internal_mounts() +{ + root_dir="$1" + mount -t proc proc ${root_dir}/proc + mount -t devpts devpts ${root_dir}/dev/pts + mount -t tmpfs tmpfs ${root_dir}/var/cache/apt/cache +} + +chroot_internal_umounts() +{ + root_dir="$1" + umount ${root_dir}/proc + umount ${root_dir}/dev/pts + umount ${root_dir}/var/cache/apt/cache +} diff --git a/initchroot.sh b/initchroot.sh index 025f8c2..f77612d 100755 --- a/initchroot.sh +++ b/initchroot.sh @@ -18,23 +18,71 @@ DIST=lenny DEFUSER=olpc +PLIST=package_list +MIRROR=http://http.us.debian.org/debian/ +OTHERMIRROR= . functions.sh usage() { echo "" 1>&2 - echo "Usage: $0 " 1>&2 + echo "Usage: $0 [] " 1>&2 + echo "" 1>&2 + echo "Options:" 1>&2 + echo " --distribution Which distribution to use" 1>&2 + echo " --user Username for default user" 1>&2 + echo " --package-list File containing package list" 1>&2 + echo " --mirror Main Mirror URL prefix" 1>&2 + echo " --othermirror An additional sources.list line" 1>&2 echo "" 1>&2 exit 1 } -if [ "$#" != "1" ]; then +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 + ;; + --package-list) + PLIST=$2 + shift + ;; + --mirror) + MIRROR=$2 + shift + ;; + --othermirror) + OTHERMIRROR=$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,13 +91,15 @@ fi check_for_cmds debootstrap || exit 1 +if [ -z "${OTHERMIRROR}" ]; then + OTHERMIRROR="deb http://security.debian.org/ ${DIST}/updates main contrib non-free" +fi + # create chroot -debootstrap --arch i386 lenny ${ROOT_DIR} http://http.us.debian.org/debian +debootstrap --arch i386 ${DIST} ${ROOT_DIR} ${MIRROR} mkdir ${ROOT_DIR}/ofw mkdir ${ROOT_DIR}/var/cache/apt/cache -mount -t proc proc ${ROOT_DIR}/proc -mount -t devpts devpts ${ROOT_DIR}/dev/pts -mount -t tmpfs tmpfs ${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 @@ -74,8 +124,8 @@ Dir { }; EOF cat >${ROOT_DIR}/etc/apt/sources.list<${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} +mkdir -p cache +wget --continue -O cache/${k} http://queued.mit.edu/~dilinger/builds-master/${k} +cp cache/${k} ${ROOT_DIR}/${k} (chroot ${ROOT_DIR} dpkg -i /${k}) rm -f ${ROOT_DIR}/${k} @@ -103,10 +155,11 @@ ff02::3 ip6-allhosts EOF # install packages -(chroot ${ROOT_DIR} aptitude install -y `cat package_list`) +(chroot ${ROOT_DIR} aptitude install -y `cat ${PLIST}`) # configure X -cat >${ROOT_DIR}/etc/X11/xorg.conf<${ROOT_DIR}/etc/X11/xorg.conf<${ROOT_DIR}/etc/gconf/2/local-defaults.path<${ROOT_DIR}/etc/gconf/2/local-defaults.path<> ${ROOT_DIR}/etc/sudoers # 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 -umount ${ROOT_DIR}/var/cache/apt/cache +chroot_internal_umounts ${ROOT_DIR} diff --git a/kde.packages b/kde.packages new file mode 100644 index 0000000..8ca9f48 --- /dev/null +++ b/kde.packages @@ -0,0 +1,19 @@ +libertas-firmware +xserver-xorg-core +xserver-xorg-input-kbd +xserver-xorg-input-mouse +xserver-xorg-input-evdev +xserver-xorg-video-geode +xfonts-100dpi +xfonts-scalable +xfonts-base +openssh-client +wireless-tools +openntpd +menu +aspell-en +sudo +big-cursor +kde +kdm +network-manager-kde diff --git a/lxde.packages b/lxde.packages new file mode 100644 index 0000000..5646032 --- /dev/null +++ b/lxde.packages @@ -0,0 +1,21 @@ +libertas-firmware +xserver-xorg-core +xserver-xorg-input-kbd +xserver-xorg-input-mouse +xserver-xorg-input-evdev +xserver-xorg-video-geode +xfonts-100dpi +xfonts-scalable +xfonts-base +openssh-client +wireless-tools +openntpd +menu +aspell-en +sudo +big-cursor +xinit +lxde +lxnm +lxsession-lite +lxterminal