# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# 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 15:26:11 CEST 2007 [mika]
################################################################################
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'
# 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
+ echo "Notice: stage $1 has been executed already, skipping execution therefore.">&2
+ return 1
fi
}
# }}}
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
+ DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL $(cat /etc/debootstrap/packages) $GRMLPACKAGES
fi
fi
}
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
+ DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL $KERNELPACKAGES
fi
}
# }}}
reconfigure() {
if [ -n "$RECONFIGURE" ] ; then
for package in $RECONFIGURE ; do
- dpkg --list $package 1>/dev/null 2>/dev/null && dpkg-reconfigure $package || echo "Warning: $package does not exist, can not reconfigure it."
+ dpkg --list $package 1>/dev/null 2>/dev/null && \
+ DEBIAN_FRONTEND=$DEBIAN_FRONTEND dpkg-reconfigure $package || \
+ echo "Warning: $package does not exist, can not reconfigure it."
done
fi
}
[ "$RELEASE" = 'sarge' ] && cp /lib/grub/i386-pc/* /boot/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 [ -x /usr/sbin/update-grub ] ; then
+ UPDATEGRUB='/usr/sbin/update-grub'
+ else
+ UPDATEGRUB='/sbin/update-grub'
+ fi
+ $UPDATEGRUB -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
+ $UPDATEGRUB -y
+ fi
fi
}
# }}}