+ rm -f "$isreadonly"
+ BUILDTMP=/data/tmp
+ fi
+ fi
+
+ FULL_VERSION_STRING="${PLC_NAME} BootCD ${BOOTCD_VERSION}"
+
+}
+
+# NOTE
+# the custom-dir feature is designed to let a myplc try/ship a patched bootcd
+# without the need for a full devel environment
+# for example, you would create /root/custom-bootcd/etc/rc.d/init.d/pl_hwinit
+# and run this script with -C /root/custom-bootcd
+# this creates a third .img image of the custom dir, that 'hides' the files from
+# bootcd.img in the resulting unionfs
+# it seems that this feature has not been used nor tested in a long time, use with care
+
+usage() {
+ echo "Usage: build.sh [OPTION]..."
+ echo " -f plnode.txt Node to customize CD for (default: none)"
+ echo " -t 'types' Build the specified images (default: $DEFAULT_TYPES)"
+ echo " NOTE: mentioning 'serial' as part of the type is not supported anymore"
+ echo " -a Build all known types as listed below"
+ echo " -s console-info Enable a serial line as console and also bring up getty on that line"
+ echo " console-info: tty:baud-rate:parity:bits"
+ echo " or 'default' shortcut for $SERIAL_CONSOLE"
+ echo " -S equivalent to -s default"
+ echo " -O output-base The prefix of the generated files (default: PLC_NAME-BootCD-VERSION)"
+ echo " useful when multiple types are provided"
+ echo " can be a full path"
+ echo " -o output-name The full name of the generated file"
+ echo " -C custom-dir Custom directory"
+ echo " -n Dry run - mostly for debug/test purposes"
+ echo " -k Add additional parameters to the kargs.txt file"
+ echo " -h This message"
+ echo "All known types: $ALL_TYPES"
+ exit 1
+}
+
+####################
+function parse_command_line () {
+
+ # init
+ TYPES=""
+ # Get options
+ while getopts "f:t:as:SO:o:C:k:nh" opt ; do
+ case $opt in
+ f) NODE_CONFIGURATION_FILE=$OPTARG ;;
+ t) TYPES="$TYPES $OPTARG" ;;
+ a) TYPES="$ALL_TYPES" ;;
+ s) CONSOLE_INFO="$OPTARG" ;;
+ S) CONSOLE_INFO=$SERIAL_CONSOLE ;;
+ O) OUTPUT_BASE="$OPTARG" ;;
+ o) OUTPUT_NAME="$OPTARG" ;;
+ C) CUSTOM_DIR="$OPTARG" ;;
+ k) KARGS_STR="$OPTARG" ;;
+ n) DRY_RUN=true ;;
+ h|*) usage ;;
+ esac
+ done
+
+ # use defaults if not set
+ [ -z "$TYPES" ] && TYPES="$DEFAULT_TYPES"
+ [ "$CONSOLE_INFO" == "default" ] && CONSOLE_INFO=$SERIAL_CONSOLE
+
+ # check TYPES
+ local matcher="XXX$(echo $ALL_TYPES | sed -e 's,\W,XXX,g')XXX"
+ for t in $TYPES; do
+ echo Checking type $t
+ echo $matcher | grep XXX${t}XXX &> /dev/null
+ if [ "$?" != 0 ] ; then
+ echo Unknown type $t
+ usage