+
+PXML_schema="PXML_schema.xsd"
+GENPXML_PATH="genpxml.sh"
+
+# useful functions ...
+black='\E[30m'
+red='\E[31m'
+green='\E[32m'
+yellow='\E[33m'
+blue='\E[34m'
+magenta='\E[35m'
+cyan='\E[36m'
+white='\E[37m'
+
+
+cecho () # Color-echo. Argument $1 = message, Argument $2 = color
+{
+ local default_msg="No message passed." # Doesn't really need to be a local variable.
+ message=${1:-$default_msg} # Defaults to default message.
+ color=${2:-$black} # Defaults to black, if not specified.
+ echo -e "$color$message"
+ tput sgr0 # Reset to normal.
+ return
+}
+
+
+print_help()
+{
+ cat << EOSTREAM
+pnd_make.sh - A script to package "something" into a PND.
+
+Usage:
+ $(basename ${0}) {--directory|-d} <folder> {--pndname|-p} <file> [{--compress-squashfs|-c}]
+ [{--genpxml} <file>] [{--icon|-i} <file>] [{--pxml|-x} <file>]
+ [{--schema|-s} <file>] [{--help|-h}]
+
+
+Switches:
+ --compress-squashfs / -c Define wether or not the pnd should be compressed using
+ squashfs. If this parameter is selected, a compressed pnd
+ will be created.
+
+ --directory / -d Sets the folder that is to be used for the resulting pnd
+ to <folder>. This option is mandatory for the script to
+ function correctly.
+
+ --genpxml
+
+ --help / -h Displays this help text.
+
+ --icon / -i Sets the icon that will be appended in the pnd to <file>.
+
+ --pndname / -p Sets the output filename of the resulting pnd to <file>.
+ This option is mandatory for the script to function
+ correctly.
+
+ --pxml / -x Sets the PXML file that is to be used to <file>. If you
+ neither provide a PXML file or set this entry to 'guess',
+ an existing 'PXML.xml' in your selected '--directory'
+ will be used, or the script $GENPXML_PATH will be called
+ to try to generate a basic PXML file for your.
+
+ --schema / -s Sets the schema file, that is to be used for validation,
+ to <file. If this is not defined, the script will try to
+ use the file 'PXML_schema.xsd'. If this fails, a warning
+ is issued.
+
+If you select the option to create a compressed squashfs, a version >=4.0 of squashfs
+is required to be available in your PATH.
+EOSTREAM
+}
+
+
+# Parse command line parameters
+while [ "${1}" != "" ]; do
+ if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ];
+ then
+ SQUASH=1
+ shift 1
+ elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ];
+ then
+ FOLDER=$2
+ shift 2
+ elif [ "${1}" = "--genpxml" ];
+ then
+ GENPXML_PATH=$2
+ shift 2
+ elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ];
+ then
+ print_help
+ exit 0
+ elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ];
+ then
+ ICON=$2
+ shift 2
+ elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ];
+ then
+ PNDNAME=$2
+ shift 2
+ elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ];
+ then
+ PXML=$2
+ shift 2
+ elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ]
+ then
+ PXML_schema=$2
+ shift 2
+ else
+ cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red
+ print_help
+ exit 1;
+ fi