X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=chroot-script;h=bb6d7ad4821db66a51408d29e1dec9fba66546a6;hp=81fc13278f1555398a1aba9302dead2aeef17c31;hb=80e002e524071cb32d020e222d4aa28331c305e3;hpb=7ab56e7053ae81a293d7eb905dbd288f6a009411 diff --git a/chroot-script b/chroot-script index 81fc132..bb6d7ad 100644 --- a/chroot-script +++ b/chroot-script @@ -4,7 +4,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Don Apr 12 11:55:23 CEST 2007 [mika] +# Latest change: Mon Apr 16 13:12:14 CEST 2007 [mika] ################################################################################ set -e # exit on any error @@ -14,6 +14,15 @@ set -e # exit on any error [ -r /proc/1 ] || mount -t proc none /proc +# use aptitude only if it's available +if [ -x /usr/bin/aptitude ] ; then + APTINSTALL='aptitude -y install ' + APTUPDATE='aptitude update' +else + APTINSTALL='apt-get --force-yes -y install' + APTUPDATE='apt-get update' +fi + # variable checks {{{ if [ -z "$STAGES" ] ; then STAGES='/etc/debootstrap/stages' @@ -23,12 +32,12 @@ fi # helper functions {{{ stage() { - if grep -q done "$STAGES/$1" 2>/dev/null ; then - echo " * Notice: stage $1 has been executed already, skipping execution therefore." - return 1 - else + if [ -n "$2" ] ; then echo "$2" > "$STAGES/$1" return 0 + elif grep -q done "$STAGES/$1" 2>/dev/null ; then + ewarn "Notice: stage $1 has been executed already, skipping execution therefore." ; eend 0 + return 1 fi } # }}} @@ -79,8 +88,8 @@ packages() { echo "Error: /etc/debootstrap/packages not found, exiting." exit 1 else - apt-get update - apt-get --force-yes -y install $(cat /etc/debootstrap/packages) $GRMLPACKAGES + $APTUPDATE + $APT $(cat /etc/debootstrap/packages) $GRMLPACKAGES fi fi } @@ -106,13 +115,13 @@ kernel() { fi if [ -n "$KERNEL" ] ; then - apt-get update + $APTUPDATE if [ "$RELEASE" = 'sarge' ] ; then KERNELPACKAGES="kernel-image-$KERNEL kernel-headers-$KERNEL" else KERNELPACKAGES="linux-image-$KERNEL linux-headers-$KERNEL" fi - apt-get --force-yes -y install $KERNELPACKAGES + $APTINSTALL $KERNELPACKAGES fi } # }}} @@ -252,11 +261,13 @@ grub() { # finally install grub update-grub -y - sed -i "s/^# groot=.*/# groot=(${GROOT})/g" /boot/grub/menu.lst - sed -i "s|^# kopt=root=.*|# kopt=root=${TARGET} ro|g" /boot/grub/menu.lst - # not sure why savedefault does not work for me; any ideas? - sed -i "s/^savedefault.*/# &/g" /boot/grub/menu.lst - update-grub -y + if [ -f /boot/grub/menu.lst ] ; then + sed -i "s/^# groot=.*/# groot=(${GROOT})/g" /boot/grub/menu.lst + sed -i "s|^# kopt=root=.*|# kopt=root=${TARGET} ro|g" /boot/grub/menu.lst + # not sure why savedefault does not work for me; any ideas? + sed -i "s/^savedefault.*/# &/g" /boot/grub/menu.lst + update-grub -y + fi fi } # }}}