X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=grml-debootstrap;h=31b26ebedb7234ad846a62d5cf447e7c87f7862f;hp=2544c8542fab181c58114c3c54b611a161b002b7;hb=c852c935af341e15b5174247e9c6cd23a3c2fc2f;hpb=7614eb950deb2b036bc22b328929d79065f63153 diff --git a/grml-debootstrap b/grml-debootstrap index 2544c85..31b26eb 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -11,7 +11,7 @@ set -e # exit on any error # variables {{{ PN="$(basename $0)" -VERSION='0.33-pre1' +VERSION='0.34' MNTPOINT="/mnt/debootstrap.$$" # inside the chroot system locales might not be available, so use minimum: @@ -57,14 +57,15 @@ Configuration options: /etc/debootstrap/config -d, --confdir Place of config files for debootstrap, defaults to /etc/debootstrap - --packages Install packages defined in specified list file. - --debconf Pre-seed packages using specified pre-seed db file. + --packages[=] Install packages defined in specified list file. + --debconf[=] Pre-seed packages using specified pre-seed db file. --keep_src_list Do not overwrite user provided apt sources.list. --hostname Hostname of Debian system. --password Use specified password as password for user root. --bootappend Add specified appendline to kernel whilst booting. --chroot-scripts Execute chroot scripts from specified directory. - --scripts Execute scripts from specified directory. + --pre-scripts[=] Execute scripts from specified directory (before chroot-scripts). + --scripts[=] Execute scripts from specified directory (after chroot-scripts). Other options: @@ -104,10 +105,10 @@ fi # cmdline handling {{{ # source external command line parameter-processing script -if [ -r /usr/share/grml-debootstrap/functions/cmdlineopts.clp ] ; then - . /usr/share/grml-debootstrap/functions/cmdlineopts.clp -elif [ -r ./cmdlineopts.clp ] ; then +if [ -r ./cmdlineopts.clp ] ; then . ./cmdlineopts.clp +elif [ -r /usr/share/grml-debootstrap/functions/cmdlineopts.clp ] ; then + . /usr/share/grml-debootstrap/functions/cmdlineopts.clp else echo "Error: cmdline function file not found, exiting.">&2 exit 1 @@ -141,6 +142,7 @@ fi [ "$_opt_packages_set" ] && PACKAGES='yes' [ "$_opt_debconf_set" ] && DEBCONF='yes' [ "$_opt_scripts_set" ] && SCRIPTS='yes' +[ "$_opt_pre_scripts_set" ] && PRE_SCRIPTS='yes' [ "$_opt_chroot_scripts_set" ] && CHROOT_SCRIPTS='yes' [ "$_opt_keep_src_list" ] && KEEP_SRC_LIST='yes' [ "$_opt_hostname" ] && HOSTNAME=$_opt_hostname @@ -235,7 +237,7 @@ prompt_for_bootmanager() MBRDISK=$(readlink -f $MBRDISK) else # fall back to old behaviour - MBRDISK=$(echo ${TARGET} | sed -e 's/[0-9][0-9]*$/') + MBRDISK=$(echo ${TARGET} | sed -e 's/[0-9][0-9]*$//') fi MBRPART="MBR of $MBRDISK" @@ -574,15 +576,17 @@ set_target_directory(){ TUNE2FS='' FSCK='' GRUB='' + # make sure we normalise the path to an absolute directory name so something like: + # mkdir -p foo/a bar/a; (cd foo; grml-debootstrap -t a)&; (cd bar; grml-debootstrap -t a)&; wait + # works + TARGET="$(readlink -f $TARGET)" } -case $TARGET in - /dev/shm/*) set_target_directory ;; - /dev/*) +if [ -b "$TARGET" ] ; then PARTITION=1 - ;; - *) set_target_directory ;; -esac +else + set_target_directory +fi # }}} # architecture setup {{{ @@ -858,6 +862,22 @@ preparechroot() { } # }}} +# execute all scripts in /etc/debootstrap/pre-scripts/ {{{ +execute_pre_scripts() { + # make sure we have $MNTPOINT available for our scripts + export MNTPOINT + if [ -d "$_opt_pre_scripts" ] || [ "$PRE_SCRIPTS" = 'yes' ] ; then + [ -d "$_opt_pre_scripts" ] && pre_scripts="$_opt_pre_scripts" || pre_scripts="$CONFFILES/pre-scripts/" + for script in ${pre_scripts}/* ; do + if [ -x "$script" ] ; then + einfo "Executing pre-script $script" + $script ; eend $? + fi + done + fi +} +# }}} + # execute all scripts in /etc/debootstrap/scripts/ {{{ execute_scripts() { # make sure we have $MNTPOINT available for our scripts @@ -956,7 +976,7 @@ fscktool() { # now execute all the functions {{{ for i in mkfs tunefs mount_target debootstrap_system preparechroot \ - chrootscript execute_scripts grub_install umount_chroot \ + execute_pre_scripts chrootscript execute_scripts grub_install umount_chroot \ fscktool ; do if stage "${i}" ; then $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i"