Rename --scripts to --post-scripts for consistency
authorMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 10:43:56 +0000 (12:43 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 11:32:47 +0000 (13:32 +0200)
The --scripts option and SCRIPTS config are still supported but display a
deprecation warning now.

Fixes #52 @ github

cmdlineopts.clp
config
grml-debootstrap
grml-debootstrap.8.txt

index 1696d9c..0a46fc9 100644 (file)
@@ -12,7 +12,7 @@
 # should be handled in the main script, where it belongs.
 ################################################################################
 
 # 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 -- "$@"`
 
 _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
     ;;
     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
     ;;
     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
   --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 (file)
--- a/config
+++ b/config
 # Default: 'yes'
 # CHROOT_SCRIPTS='no'
 
 # 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'
 # Default: 'yes'
-# SCRIPTS='no'
+# POST_SCRIPTS='no'
 
 # Install *.deb packages from /etc/debootstrap/extrapackages/
 # Default: 'yes'
 
 # Install *.deb packages from /etc/debootstrap/extrapackages/
 # Default: 'yes'
index 5604849..4554d46 100755 (executable)
@@ -69,6 +69,7 @@ MNTPOINT="/mnt/debootstrap.$$"
 [ -n "$MKFS" ] || MKFS='mkfs.ext4'
 [ -n "$MKFS_OPTS" ] || MKFS_OPTS=''
 [ -n "$PACKAGES" ] || PACKAGES='yes'
 [ -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'
 [ -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_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'
 [ "$_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 "$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"
   [ -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 \
 
 # 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
          umount_chroot finalize_vm fscktool ; do
     if stage "${i}" ; then
       if "$i" ; then
index e585719..3c1febb 100644 (file)
@@ -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.
 
     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_::
 
 
 *--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 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_::
 
 
 *-t*, *--target* _target_::