From: Andres Salomon Date: Wed, 27 May 2009 20:20:59 +0000 (-0400) Subject: rename: initchroot.sh -> mkchroot.sh X-Git-Tag: v0.6~65 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?p=xodist;a=commitdiff_plain;h=a66726dadd0e9c8a7bf3ec55bebbf0247a869baa rename: initchroot.sh -> mkchroot.sh Signed-off-by: Andres Salomon --- diff --git a/README b/README index 15025d5..427a67a 100644 --- a/README +++ b/README @@ -13,7 +13,7 @@ How to use xodist to generate a Debian KDE image for an OLPC XO: 1. build the root filesystem, - sudo ./initchroot.sh --package-list kde.packages kde.root + sudo ./mkchroot.sh --package-list kde.packages kde.root 2. make the JFFS2 filesystem, diff --git a/README.approx b/README.approx index 512b375..f142c46 100644 --- a/README.approx +++ b/README.approx @@ -1,4 +1,4 @@ -Problem: every time you use initchroot.sh the hundreds of megabytes of +Problem: every time you use mkchroot.sh the hundreds of megabytes of packages are downloaded again. Solution: set up the approx package to cache these packages. @@ -19,7 +19,7 @@ security http://security.debian.org/ 4. follow README, but during the creation of the root filesystem, add the --mirror option, like this: - sudo ./initchroot.sh \ + sudo ./mkchroot.sh \ --package-list kde.packages \ --local-apt-mirror "deb http://localhost:9999/debian lenny main contrib non-free deb http://localhost:9999/security lenny/updates main contrib non-free" \ diff --git a/initchroot.sh b/initchroot.sh deleted file mode 100755 index 2808620..0000000 --- a/initchroot.sh +++ /dev/null @@ -1,255 +0,0 @@ -#!/bin/bash -e -# -# Copyright © 2008 Andres Salomon -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -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 - -usage() -{ - echo "" 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 -} - -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 - -if [ -d "${ROOT_DIR}" ]; then - echo "" 1>&2 - echo "*** ${ROOT_DIR} already exists!" 1>&2 - usage -fi - -start_logging $ROOT_DIR - -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 ${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 -cat >${ROOT_DIR}/sbin/start-stop-daemon< ${ROOT_DIR}/etc/hostname -cat >${ROOT_DIR}/etc/hosts<${ROOT_DIR}/etc/apt/apt.conf<${ROOT_DIR}/etc/apt/sources.list -(chroot ${ROOT_DIR} aptitude update) - -# 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 `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.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}) - 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 -# 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<${ROOT_DIR}/etc/gconf/2/local-defaults.path<> ${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) -chroot_internal_umounts ${ROOT_DIR} diff --git a/mkchroot.sh b/mkchroot.sh new file mode 100755 index 0000000..2808620 --- /dev/null +++ b/mkchroot.sh @@ -0,0 +1,255 @@ +#!/bin/bash -e +# +# Copyright © 2008 Andres Salomon +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +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 + +usage() +{ + echo "" 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 +} + +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 + +if [ -d "${ROOT_DIR}" ]; then + echo "" 1>&2 + echo "*** ${ROOT_DIR} already exists!" 1>&2 + usage +fi + +start_logging $ROOT_DIR + +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 ${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 +cat >${ROOT_DIR}/sbin/start-stop-daemon< ${ROOT_DIR}/etc/hostname +cat >${ROOT_DIR}/etc/hosts<${ROOT_DIR}/etc/apt/apt.conf<${ROOT_DIR}/etc/apt/sources.list +(chroot ${ROOT_DIR} aptitude update) + +# 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 `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.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}) + 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 +# 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<${ROOT_DIR}/etc/gconf/2/local-defaults.path<> ${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) +chroot_internal_umounts ${ROOT_DIR} diff --git a/release.sh b/release.sh index f2c0130..e453292 100755 --- a/release.sh +++ b/release.sh @@ -3,7 +3,7 @@ # prepare a release for f in *.packages; do desktop=$(echo $f | sed 's/\.packages//') - ./initchroot.sh --package-list ${f} \ + ./mkchroot.sh --package-list ${f} \ --local-apt-mirror "deb http://localhost:9999/debian lenny main contrib non-free deb http://localhost:9999/security lenny/updates main contrib non-free" \ debxo-${desktop}