diff --git a/libisoburn/trunk/releng/inc/releng_getopts.inc b/libisoburn/trunk/releng/inc/releng_getopts.inc new file mode 100644 index 00000000..77e5ea3d --- /dev/null +++ b/libisoburn/trunk/releng/inc/releng_getopts.inc @@ -0,0 +1,55 @@ +SELF=$(basename $0) +RELENG_XORRISO=0 +KEEP=0 +SIMULATE_FAILURE=0 + +usage() { +cat << EOF + +Usage: $SELF -x path/to/xorriso [-k0|1] [-f0|1] [-h] + -x absolute or relative path to binary to be run. + -k keep selfgenerated data, values 0,1 default 0. + -f simulate failure, values 0,1 default 0. +EOF +} + +while getopts “x:k:f:h” OPTION +do + case $OPTION in + x) + RELENG_XORRISO=$OPTARG + ;; + k) + KEEP=$OPTARG + ;; + f) + SIMULATE_FAILURE=$OPTARG + ;; + h) + usage + exit 0 + ;; + *) + usage + exit 31 + ;; + esac +done + +if [ ! -x $RELENG_XORRISO ]; then + usage + printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n" + exit 31 +fi + +if [ x"$KEEP" != x"0" -a x"$KEEP" != x"1" ]; then + usage + printf "\n${SELF}: -k keep selfgenerated data, values 0,1 default 0.\n\n" + exit 31 +fi + +if [ x"$SIMULATE_FAILURE" != x"0" -a x"$SIMULATE_FAILURE" != x"1" ]; then + usage + printf "\n${SELF}: -f simulate failure, values 0,1 default 0.\n\n" + exit 31 +fi diff --git a/libisoburn/trunk/releng/inc/test_releng_getopt b/libisoburn/trunk/releng/inc/test_releng_getopt new file mode 100755 index 00000000..7d0c1e34 --- /dev/null +++ b/libisoburn/trunk/releng/inc/test_releng_getopt @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +. releng_getopts.inc + +printf "\nRELENG_XORRISO =${RELENG_XORRISO}" +printf "\nKEEP =${KEEP}" +printf "\nSIMULATE_FAILURE =${SIMULATE_FAILURE}" +printf "\n" + +exit 0