From: Tong Sun Date: Fri, 17 Oct 2008 21:23:44 +0000 (-0400) Subject: Re-think the confdir logic X-Git-Tag: v0.23~17^2~5 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=b7f67e9915e948a20a6c9264e1c7e27e0597f0e2 Re-think the confdir logic the default configuration file should always be /etc/debootstrap/config, regardless whether --confdir=path is supplied or not. However, if --confdir=path is supplied, everything should be based on it, including the configuration file. --- diff --git a/grml-debootstrap b/grml-debootstrap index 809e9e4..908aad9 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -49,10 +49,10 @@ Bootstrap options: Configuration options: + -c, --config=file Use specified configuration file, defaults to + /etc/debootstrap/config -d, --confdir=path Place of config files for debootstrap, defaults to /etc/debootstrap - -c, --config=file Use specified configuration file, defaults to - /config --packages[=f] Install packages defined in /packages. Option arg: alternative package list file. --debconf[=f] Pre-seed packages using /debconf-selections. @@ -104,7 +104,20 @@ fi # source external command line parameter-processing script . $prog_real.clp -# business-logic of command line parameter-processing +# == business-logic of command line parameter-processing + +# source configuration file in if supplied. {{{ +[ "$_opt_confdir" ] && { + CONFFILES=$_opt_confdir + if ! [ -r "$CONFFILES/config" ] ; then + eerror "Error: config file $CONFFILES/config not found."; eend 1; exit 1 + fi + if ! . "$CONFFILES/config" ; then + eerror "Error reading config file $CONFFILES/config" ; eend 1 ; exit 1 + fi +} +# }}} + [ "$_opt_mirror" ] && MIRROR=$_opt_mirror [ "$_opt_iso" ] && ISO=$_opt_iso [ "$_opt_release" ] && RELEASE=$_opt_release @@ -112,7 +125,6 @@ fi [ "$_opt_mntpoint" ] && MNTPOINT=$_opt_mntpoint [ "$_opt_debopt" ] && DEBOOTSTRAP_OPT=$_opt_debopt [ "$_opt_interactive" ] && INTERACTIVE=1 -[ "$_opt_confdir" ] && CONFFILES=$_opt_confdir [ "$_opt_config" ] && CONFIGFILE=$_opt_config [ "$_opt_packages_set" ] && PACKAGES='yes' [ "$_opt_debconf_set" ] && DEBCONF='yes' diff --git a/grml-debootstrap.clp b/grml-debootstrap.clp index 4e43b4a..2038db8 100644 --- a/grml-debootstrap.clp +++ b/grml-debootstrap.clp @@ -19,11 +19,11 @@ -_opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:d:c:hv --long \ - mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,confdir:,config:,packages::,debconf::,keep_src_list,hostname:,password:,bootappend:,groot:,grub:,help,version \ +_opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:hv --long \ + mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,config:,confdir:,packages::,debconf::,keep_src_list,hostname:,password:,bootappend:,groot:,grub:,help,version \ -- "$@"` if [ $? != 0 ]; then - eerror "Try `grml-debootstrap --help' for more information."; eend 1; exit 1 + eerror "Try 'grml-debootstrap --help' for more information."; eend 1; exit 1 fi eval set -- "$_opt_temp" @@ -55,12 +55,12 @@ while :; do # # == Configuration options + --config|-c) # Use specified configuration file, defaults to /etc/debootstr + shift; _opt_config="$1" + ;; --confdir|-d) # Place of config files for debootstrap, defaults to /etc/debo shift; _opt_confdir="$1" ;; - --config|-c) # Use specified configuration file, defaults to /conf - shift; _opt_config="$1" - ;; --packages) # Install packages defined in /packages. Option arg: shift; _opt_packages="$1" _opt_packages_set=T