From 91f2e990ca65aa3670454097d6d3937d392d7652 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 4 Jun 2015 12:43:56 +0200 Subject: [PATCH] Rename --scripts to --post-scripts for consistency The --scripts option and SCRIPTS config are still supported but display a deprecation warning now. Fixes #52 @ github --- cmdlineopts.clp | 8 ++++++-- config | 4 ++-- grml-debootstrap | 46 +++++++++++++++++++++++++++++++--------------- grml-debootstrap.8.txt | 19 ++++++++++--------- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/cmdlineopts.clp b/cmdlineopts.clp index 1696d9c..0a46fc9 100644 --- a/cmdlineopts.clp +++ b/cmdlineopts.clp @@ -12,7 +12,7 @@ # should be handled in the main script, where it belongs. ################################################################################ -CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,defaultinterfaces,interactive,nodebootstrap,nointerfaces,nokernel,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,pre-scripts:,debconf:,vm,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force,debug,contrib,non-free +CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,defaultinterfaces,interactive,nodebootstrap,nointerfaces,nokernel,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,post-scripts:,pre-scripts:,debconf:,vm,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force,debug,contrib,non-free _opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \ $CMDLINE_OPTS -- "$@"` @@ -93,10 +93,14 @@ while :; do shift; _opt_pre_scripts="$1" _opt_pre_scripts_set=T ;; - --scripts) # Execute scripts from specified directory + --scripts) # Execute scripts from specified directory [NOTE: deprecated, replaced via --post-scripts] shift; _opt_scripts="$1" _opt_scripts_set=T ;; + --post-scripts) # Execute scripts from specified directory + shift; _opt_post_scripts="$1" + _opt_post_scripts_set=T + ;; --chroot-scripts) # Execute chroot scripts from specified directory shift; _opt_chroot_scripts="$1" _opt_chroot_scripts_set=T diff --git a/config b/config index 918b028..fe4e1d5 100644 --- a/config +++ b/config @@ -133,9 +133,9 @@ # Default: 'yes' # CHROOT_SCRIPTS='no' -# Run scripts from /etc/debootstrap/scripts/ after setting up chroot. +# Run scripts from /etc/debootstrap/post-scripts/ after setting up chroot. # Default: 'yes' -# SCRIPTS='no' +# POST_SCRIPTS='no' # Install *.deb packages from /etc/debootstrap/extrapackages/ # Default: 'yes' diff --git a/grml-debootstrap b/grml-debootstrap index 5604849..4554d46 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -69,6 +69,7 @@ MNTPOINT="/mnt/debootstrap.$$" [ -n "$MKFS" ] || MKFS='mkfs.ext4' [ -n "$MKFS_OPTS" ] || MKFS_OPTS='' [ -n "$PACKAGES" ] || PACKAGES='yes' +[ -n "$POST_SCRIPTS" ] || POST_SCRIPTS='yes' [ -n "$PRE_SCRIPTS" ] || PRE_SCRIPTS='yes' [ -n "$RECONFIGURE" ] || RECONFIGURE='console-data' [ -n "$RELEASE" ] || RELEASE='jessie' @@ -378,7 +379,13 @@ fi [ "$_opt_packages_set" ] && PACKAGES='yes' [ "$_opt_nopackages" ] && PACKAGES='' [ "$_opt_debconf_set" ] && DEBCONF='yes' -[ "$_opt_scripts_set" ] && SCRIPTS='yes' + +if [ "$_opt_scripts_set" ] ; then + ewarn "Deprecation NOTE: --scripts option is deprecated, please switch to --post-scripts instead." + SCRIPTS='yes' # deprecated since grml-debootstrap >=0.71 +fi + +[ "$_opt_post_scripts_set" ] && POST_SCRIPTS='yes' [ "$_opt_pre_scripts_set" ] && PRE_SCRIPTS='yes' [ "$_opt_chroot_scripts_set" ] && CHROOT_SCRIPTS='yes' [ "$_opt_keep_src_list" ] && KEEP_SRC_LIST='yes' @@ -1276,6 +1283,7 @@ preparechroot() { [ -n "$NOPASSWORD" ] && echo "NOPASSWORD=\"true\"" >> "$CHROOT_VARIABLES" [ -n "$NOKERNEL" ] && echo "NOKERNEL=\"true\"" >> "$CHROOT_VARIABLES" [ -n "$PACKAGES" ] && echo "PACKAGES='$(sed "s,','\\\\'',g" <<<"${PACKAGES}")'" >> "$CHROOT_VARIABLES" + [ -n "$POST_SCRIPTS" ] && echo "POST_SCRIPTS='$(sed "s,','\\\\'',g" <<<"${POST_SCRIPTS}")'" >> "$CHROOT_VARIABLES" [ -n "$PRE_SCRIPTS" ] && echo "PRE_SCRIPTS='$(sed "s,','\\\\'',g" <<<"${PRE_SCRIPTS}")'" >> "$CHROOT_VARIABLES" [ -n "$RECONFIGURE" ] && echo "RECONFIGURE='$(sed "s,','\\\\'',g" <<<"${RECONFIGURE}")'" >> "$CHROOT_VARIABLES" [ -n "$RELEASE" ] && echo "RELEASE='$(sed "s,','\\\\'',g" <<<"${RELEASE}")'" >> "$CHROOT_VARIABLES" @@ -1412,19 +1420,27 @@ execute_pre_scripts() { } # }}} -# execute all scripts in /etc/debootstrap/scripts/ {{{ -execute_scripts() { - # make sure we have $MNTPOINT available for our scripts - export MNTPOINT - if [ -d "$_opt_scripts" ] || [ "$SCRIPTS" = 'yes' ] ; then - [ -d "$_opt_scripts" ] && scripts="$_opt_scripts" || scripts="$CONFFILES/scripts/" - for script in ${scripts}/* ; do - if [ -x "$script" ] ; then - einfo "Executing script $script" - $script ; eend $? - fi - done - fi +# execute all scripts in /etc/debootstrap/post-scripts/ {{{ +execute_post_scripts() { + # make sure we have $MNTPOINT available for our scripts + export MNTPOINT + + if [ -d "$_opt_scripts" ] || [ "$SCRIPTS" = 'yes'] ; then + # legacy support for /etc/debootstrap/scripts/ + [ -d "$_opt_scripts" ] && post_scripts="$_opt_scripts" || post_scripts="${CONFFILES}/scripts/" + ewarn "Deprecation NOTE: --scripts/SCRIPTS are deprecated, please switch to --post-scripts/POST_SCRIPTS instead." + elif [ -d "$_opt_post_scripts" ] || [ "$POST_SCRIPTS" = 'yes' ] ; then + [ -d "$_opt_post_scripts" ] && post_scripts="$_opt_post_scripts" || post_scripts="${CONFFILES}/post-scripts/" + fi + + if [ -n "$post_scripts" ] ; then + for script in "${post_scripts}"/* ; do + if [ -x "$script" ] ; then + einfo "Executing post-script $script" + "$script" ; eend $? + fi + done + fi } # }}} @@ -1528,7 +1544,7 @@ fscktool() { # now execute all the functions {{{ for i in prepare_vm mkfs tunefs mount_target debootstrap_system \ - preparechroot execute_pre_scripts chrootscript execute_scripts \ + preparechroot execute_pre_scripts chrootscript execute_post_scripts \ umount_chroot finalize_vm fscktool ; do if stage "${i}" ; then if "$i" ; then diff --git a/grml-debootstrap.8.txt b/grml-debootstrap.8.txt index e585719..3c1febb 100644 --- a/grml-debootstrap.8.txt +++ b/grml-debootstrap.8.txt @@ -182,11 +182,13 @@ Options and environment variables command line might be visible in the process list and the shell history. It's meant for automatic installation only. -*-r*, *--release* _releasename_:: +*--post-scripts* _directory_:: - Specify release of new Debian system. Supported releases names: lenny, - squeeze, wheezy, jessie, stretch (note: requires a recent version of debootstrap) - and sid. Corresponding with configuration variable RELEASE. + Execute scripts from specified directory after executing the chroot script. + This allows customisation of the system after the chroot has been set up. + The environment variable $MNTPOINT is available inside the scripts for + direct access of the chroot. + Default directory: /etc/debootstrap/post-scripts/ *--pre-scripts* _directory_:: @@ -196,12 +198,11 @@ Options and environment variables scripts for direct access of the chroot. Default directory: /etc/debootstrap/pre-scripts/ -*--scripts* _directory_:: +*-r*, *--release* _releasename_:: - Execute scripts from specified directory. This allows customisation of - the system after the chroot has been set up. The environment variable - $MNTPOINT is available inside the scripts for direct access of the chroot. - Default directory: /etc/debootstrap/scripts/ + Specify release of new Debian system. Supported releases names: lenny, + squeeze, wheezy, jessie, stretch (note: requires a recent version of debootstrap) + and sid. Corresponding with configuration variable RELEASE. *-t*, *--target* _target_:: -- 2.1.4