Permalink
Browse files

Replace BUILD_PROD_ISO and BUILD_DEBUG_ISO with a single variable: BU…

…NDLE_TYPE. This can be set to 'prod', 'debug', or 'dev'.

Replaced a few /bin/echo instances with printf statements.
  • Loading branch information...
1 parent 4b9146b commit 66d8444a64bfaf5b7a4fdccb0f6bcfba97fddfc0 @sayotte sayotte committed Nov 20, 2012
Showing with 45 additions and 29 deletions.
  1. +44 −27 build-bundle-file.sh
  2. +1 −2 bundle.cfg.example
View
@@ -74,28 +74,49 @@ set -- $options
# 'tr' command is used to remove the leading and trailing quotes from
# the arguments while the 'sed' command is used to remove the leading
# equals sign from the argument (if it exists).
+BUNDLE_TYPE_SELECTED=0
while [ $# -gt 0 ]
do
case $1 in
-r|--reuse-prev-dl) RE_USE_PREV_DL='yes';;
-b|--builtin-list) BUILTIN_LIST=`echo $2 | tr -d "'" | sed 's:^[=]\?\(.*\)$:\1:'`; shift;;
-m|--mirror-list) MIRROR_LIST=`echo $2 | tr -d "'" | sed 's:^[=]\?\(.*\)$:\1:'`; shift;;
- -p|--build-prod-image) BUILD_PROD_ISO='yes';;
- -d|--build-debug-image) BUILD_DEBUG_ISO='yes';;
+ -p|--build-prod-image)
+ if [ $BUNDLE_TYPE_SELECTED -eq 0 ]; then
+ BUNDLE_TYPE='prod';
+ BUNDLE_TYPE_SELECTED=1
+ else
+ printf '%s: ERROR, cannot specify both -d and -p\n' "$0"
+ printf ' (bundle must be either prod or debug, not both)\n'
+ usage
+ exit 1
+ fi
+ ;;
+ -d|--build-debug-image)
+ if [ $BUNDLE_TYPE_SELECTED -eq 0 ]; then
+ BUNDLE_TYPE='debug';
+ BUNDLE_TYPE_SELECTED=1
+ else
+ printf '%s: ERROR, cannot specify both -d and -p\n' "$0"
+ printf ' (bundle must be either prod or debug, not both)\n'
+ usage
+ exit 1
+ fi
+ ;;
-t|--tc-passwd)
TC_PASSWD=`echo $2 | tr -d "'"`
test1=`echo $TC_PASSWD | grep '^c-passwd='`
if [[ ! -z $test1 ]]; then
test=`echo $test1 | sed 's:^c-passwd=\(.*\)$:\1:'`
- echo -n "$0: WARNING, found value that looks like it includes part"
- echo -n " of the long argument name ($TC_PASSWD); should the password value be"
- echo " \"$test\" instead?"
+ printf '%s: WARNING, found value that looks like it includes part' "$0"
+ printf ' of the long argument name (%s); should the password value be' "$TC_PASSWD"
+ printf ' "%s" instead?\n' "$test"
fi;
test2=`echo $TC_PASSWD | grep '^='`
if [[ ! -z $test2 ]]; then
- echo -n "$0: WARNING, password value with a leading '=' found"
- echo -n " ($test2), did you use an '=' between the short argument (-t)"
- echo " and its value? If so, you might not get the password you expect..."
+ printf "%s: WARNING, password value with a leading '=' found" "$0"
+ printf " (%s), did you use an '=' between the short argument (-t)" "$test2"
+ printf " and its value? If so, you might not get the password you expect...\n"
fi;
shift;;
-c|--config) CONFIG_FILE=`printf '%s' "$2" | tr -d "'" | sed 's:^[=]\?\(.*\)$:\1:'`; shift;;
@@ -127,10 +148,8 @@ fi
TC_PASSWD="$MK_BUNDLE_TC_PASSWD"
[ -z "$RE_USE_PREV_DL" -a -n "$MK_BUNDLE_RE_USE_PREV_DL" ] &&
RE_USE_PREV_DL="$MK_BUNDLE_RE_USE_PREV_DL"
-[ -z "$BUILD_PROD_ISO" -a -n "$MK_BUNDLE_BUILD_PROD_ISO" ] &&
- BUILD_PROD_ISO="$MK_BUNDLE_BUILD_PROD_ISO"
-[ -z "$BUILD_DEBUG_ISO" -a -n "$MK_BUNDLE_BUILD_DEBUG_ISO" ] &&
- BUILD_DEBUG_ISO="$MK_BUNDLE_BUILD_DEBUG_ISO"
+[ -z "$BUNDLE_TYPE" -a -n "$MK_BUNDLE_TYPE" ] &&
+ BUNDLE_TYPE="$MK_BUNDLE_TYPE"
[ -z "$TCL_MIRROR_URI" -a -n "$MK_BUNDLE_TCL_MIRROR_URI" ] &&
TCL_MIRROR_URI="$MK_BUNDLE_TCL_MIRROR_URI"
[ -z "$TCL_ISO_URL" -a -n "$MK_BUNDLE_TCL_ISO_URL" ] &&
@@ -147,8 +166,7 @@ fi
# Set to default anything still not specified, for which there is a reasonable
# default-value
[ -z "$RE_USE_PREV_DL" ] && RE_USE_PREV_DL='no'
-[ -z "$BUILD_PROD_ISO" ] && BUILD_PROD_ISO='no'
-[ -z "$BUILD_DEBUG_ISO" ] && BUILD_DEBUG_ISO='no'
+[ -z "$BUNDLE_TYPE" ] && BUNDLE_TYPE='dev'
[ -z "$TCL_MIRROR_URI" ] && TCL_MIRROR_URI='http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz'
[ -z "$TCL_ISO_URL" ] && TCL_ISO_URL='http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/Core-current.iso'
[ -z "$RUBY_GEMS_URL" ] && RUBY_GEMS_URL='http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz'
@@ -170,12 +188,11 @@ elif [ ! -r $BUILTIN_LIST ] || [ ! -r $MIRROR_LIST ]; then
printf '\tmirror-list\t=> "%s"\n' "$MIRROR_LIST"
usage
exit 1
-elif [ $BUILD_DEBUG_ISO = 'yes' ] && [ $BUILD_PROD_ISO = 'yes' ]; then
- printf "\nError; Only one of the '-d' and '-p' options should be specified\n"
- printf " (ISO cannot be both a debug and production ISO)\n"
+elif [ "$BUNDLE_TYPE" != 'prod' ] && [ "$BUNDLE_TYPE" != 'debug' ] && [ "$BUNDLE_TYPE" != 'dev' ]; then
+ printf "\nBundle type must be one of 'prod', 'dev', or 'debug'\n"
usage
exit 1
-elif [[ ! -z $TC_PASSWD ]] && [ $BUILD_PROD_ISO = 'yes' ]; then
+elif [[ ! -z $TC_PASSWD ]] && [ $BUNDLE_TYPE = 'prod' ]; then
printf "\nError; Only one of the '-t' and '-p' options should be specified\n"
printf " (Cannot specify a 'tc' password to use for a production ISO)\n"
usage
@@ -204,9 +221,9 @@ mkdir -p tmp-build-dir/build_dir/dependencies
# gzipped tarfile that can be unpacked and will contain almost all of
# the files/tools needed to build the Microkernel ISO)
cp -p iso-build-files/* tmp-build-dir/build_dir
-if [ $BUILD_PROD_ISO = 'yes' ]; then
+if [ $BUNDLE_TYPE = 'prod' ]; then
sed -i 's/ISO_NAME=rz_mk_dev-image/ISO_NAME=rz_mk_prod-image/' tmp-build-dir/build_dir/rebuild_iso.sh
-elif [ $BUILD_DEBUG_ISO = 'yes' ]; then
+elif [ $BUNDLE_TYPE = 'debug' ]; then
sed -i 's/ISO_NAME=rz_mk_dev-image/ISO_NAME=rz_mk_debug-image/' tmp-build-dir/build_dir/rebuild_iso.sh
fi
@@ -293,15 +310,15 @@ echo `pwd`
mkdir -p tmp-build-dir/tmp/builtin/optional
rm tmp-build-dir/tmp/builtin/onboot.lst 2> /dev/null
for file in `cat $BUILTIN_LIST`; do
- if [ $BUILD_PROD_ISO = 'no' ] || [ ! $file = 'openssh.tcz' ]; then
+ if [ $BUNDLE_TYPE != 'prod' ] || [ ! $file = 'openssh.tcz' ]; then
if [ $RE_USE_PREV_DL = 'no' ] || [ ! -f tmp-build-dir/tmp/builtin/optional/$file ]
then
wget -P tmp-build-dir/tmp/builtin/optional $TCL_MIRROR_URI/$file
wget -P tmp-build-dir/tmp/builtin/optional -q $TCL_MIRROR_URI/$file.md5.txt
wget -P tmp-build-dir/tmp/builtin/optional -q $TCL_MIRROR_URI/$file.dep
fi
echo $file >> tmp-build-dir/tmp/builtin/onboot.lst
- elif [ $BUILD_PROD_ISO = 'yes' ] && [ -f tmp-build-dir/tmp/builtin/optional/$file ]
+ elif [ $BUNDLE_TYPE = 'prod' ] && [ -f tmp-build-dir/tmp/builtin/optional/$file ]
then
rm tmp-build-dir/tmp/builtin/optional/$file
rm tmp-build-dir/tmp/builtin/optional/$file.md5.txt 2> /dev/null
@@ -322,7 +339,7 @@ fi
# initial behavior of the Razor Microkernel Controller, the third disables automatic
# login of the tc user when the Microkernel finishes booting)
cp -p tmp/first_checkin.yaml tmp-build-dir/tmp
-if [ $BUILD_DEBUG_ISO = 'yes' ]
+if [ $BUNDLE_TYPE = 'debug' ]
then
# if we're building a "debug" bundle, then copy over a microkernel configuration
# file that will enable logging of DEBUG messages from the start
@@ -335,7 +352,7 @@ fi
cp -p etc/inittab tmp-build-dir/etc
# check to see if we're building a "Debug ISO"; if so, use sed to modify the inittab
# file we just copied over so that re-enables autologin
-if [ $BUILD_DEBUG_ISO = 'yes' ]; then
+if [ $BUNDLE_TYPE = 'debug' ]; then
AUTO_LOGIN_STR='-nl /sbin/autologin'
OLD_INITTAB_TTY1_PAT='^\(tty1.*\)\(38400 tty1\)$'
sed -i "s/$OLD_INITTAB_TTY1_PAT/\1$(echo $AUTO_LOGIN_STR | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g') \2/" tmp-build-dir/etc/inittab
@@ -398,7 +415,7 @@ fi
# (and remove the SSH setup files from the files we just copied over to the
# dependencies directory)
cp -p etc/passwd tmp-build-dir/etc
-if [ $BUILD_PROD_ISO = 'no' ]; then
+if [ $BUNDLE_TYPE != 'prod' ]; then
cp -p etc/shadow tmp-build-dir/etc
# if a password for the tc user was passed in (using the -t or --tc-passwd flag)
# then use it to replace the default password for the tc user in the shadow
@@ -441,9 +458,9 @@ tar zcvf build_dir/dependencies/razor-microkernel-overlay.tar.gz usr etc opt tmp
# copy over this one file to a directory somewhere and unpack it and they will
# be ready to build the ISO
bundle_out_file_name='razor-microkernel-bundle-dev.tar.gz'
-if [ $BUILD_PROD_ISO = 'yes' ]; then
+if [ $BUNDLE_TYPE = 'prod' ]; then
bundle_out_file_name='razor-microkernel-bundle-prod.tar.gz'
-elif [ $BUILD_DEBUG_ISO = 'yes' ]; then
+elif [ $BUNDLE_TYPE = 'debug' ]; then
bundle_out_file_name='razor-microkernel-bundle-debug.tar.gz'
fi
View
@@ -2,8 +2,7 @@ MK_BUNDLE_BUILTIN_LIST=additional-build-files/builtin-extensions.lst
MK_BUNDLE_MIRROR_LIST=additional-build-files/mirror-extensions.lst
MK_BUNDLE_TC_PASSWD=bigsecret
MK_BUNDLE_RE_USE_PREV_DL=no
-MK_BUNDLE_BUILD_PROD_ISO=yes
-MK_BUNDLE_BUILD_DEBUG_ISO=no
+MK_BUNDLE_TYPE=prod
MK_BUNDLE_TCL_MIRROR_URI=http://localmirror.localdomain/tinycorelinux/4.x/x86/tcz
MK_BUNDLE_TCL_ISO_URL=http://localmirror.localdomain/tinycorelinux/4.x/x86/release/Core-current.iso
MK_BUNDLE_RUBY_GEMS_URL=http://localmirror.localdomain/rubygems/rubygems-1.8.24.tgz

0 comments on commit 66d8444

Please sign in to comment.