support for config file or cmdline arguments

This commit is contained in:
George Danchev 2011-06-23 10:34:39 +00:00
parent 2e5cec66ec
commit d7cd3be2df

View File

@ -2,16 +2,60 @@
set -e
if [ ! "${3}" ]; then
printf "$0 xorriso_cmd dir_in image_out [--clean]\n"
exit 1;
# required
XOR=""
DIR=""
IMG=""
# optional
ISOLINUX_BIN=""
BOOT_CAT=""
CONFFILE=$HOME/releng_build_jigdo.conf
CLEAN=0
print_help() {
cat << HLP
Usage:
$0 -help
# using a config file ${CONFFILE}
$0 -rc [-clean]
config file content:
XOR=/path/to/xorriso
DIR=/path/to/input_dir
IMG=/path/to/out_image
ISOLINUX_BIN=/path/to/isolinux.bin
BOOT_CAT=/path/to/boot.cat
# without using a config file
$0 xorriso_cmd IN_dir OUT_image [IN_isolinux] [IN_bootcat] [-clean]
HLP
}
# help
if [ ! "${1}" -o "${1}" == "-help" ]; then print_help && exit 0; fi
# config file
if [ "${1}" == "-rc" ]; then
if [ -e ${CONFFILE} ]; then . ${CONFFILE}
else echo -e "$0: can not find config file: ${CONFFILE}\n"
fi
if [ "${2}" == "-clean" ]; then CLEAN=1; fi
# command line args
elif [ "${3}" ]; then
XOR="${1}"
DIR="${2}"
IMG="${3}"
if [ "{4}" ]; then
ISOLINUX_BIN="${4}"
if [ "{5}" ]; then BOOT_CAT="${5}"; fi
if [ "${4}" == "-clean" -o "${5}" == "-clean" -o "${6}" == "-clean" ]; then CLEAN=1; fi
fi
# the rest
else
print_help && exit 0
fi
XOR=${1}
DIR=${2}
IMG=${3}
RES="${IMG}.iso ${IMG}.new ${IMG}.md5 ${IMG}.jigdo ${IMG}.template"
############################################################
main() {
# remove cruft from previous runs
# rm -f ${RES}
@ -33,7 +77,7 @@ CMD="${XOR} \
-partition_offset 16 \
-J -joliet-long \
"
# boot section
# boot section TODO
#if [ "${5}" -a "${6}" ]; then
#CMD+=\
# -b boot/isolinux/isolinux.bin \ # $5
@ -73,9 +117,13 @@ jigit-mkimage \
diff ${IMG}.iso ${IMG}.new
# sort out the cruft
if [ "${4}" == "--clean" ]; then
if [ ${CLEAN} -eq 1 ]; then
rm -f ${RES}
printf "removed: %s\n" ${RES}
else
printf "left: %s\n" ${RES}
fi
}
#
main