converted to the unified usage pattern

This commit is contained in:
George Danchev 2011-07-08 12:42:05 +00:00
parent 8cfd6308bb
commit 7918b6cd24

View File

@ -4,53 +4,60 @@
# Test the correct handling of hardlinks by xorriso options # Test the correct handling of hardlinks by xorriso options
# -update_r , -hardlinks perform_update , and -extract # -update_r , -hardlinks perform_update , and -extract
export prog=$(basename "$0") . inc/releng_getopts.inc
export xorriso=xorriso if [ ! -x $RELENG_XORRISO ]; then
export workdir=./releng_generated_data/"$prog" print_help
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
exit 31
fi
export prog=${SELF}
export xorriso=${RELENG_XORRISO}
export workdir=${GEN_DATA_DIR}
export image_file="$workdir"/xorriso_hardlinks.iso export image_file="$workdir"/xorriso_hardlinks.iso
export on_disk="$workdir"/xorriso_hardlinks_test_dir export on_disk="$workdir"/xorriso_hardlinks_test_dir
export in_iso="" export in_iso=""
export copy_on_disk="$workdir"/xorriso_hardlinks_copy_dir export copy_on_disk="$workdir"/xorriso_hardlinks_copy_dir
export keep=0 export keep=${KEEP}
export failure=0 export failure=0
export simulate_failure=0 export simulate_failure=${SIMULATE_FAILURE}
export next_is_xorriso=0 export next_is_xorriso=0
export next_is_rc=0 export next_is_rc=0
export bad=0 export bad=0
export report_about="-report_about UPDATE" export report_about="-report_about UPDATE"
config_by_var() { #config_by_var() {
# This is called once before option interpretation, and once for each # This is called once before option interpretation, and once for each
# option -rc. # option -rc.
# Variables get set to empty content to keep them from being applied # Variables get set to empty content to keep them from being applied
# more than once and thus overriding settings of higher precedence. # more than once and thus overriding settings of higher precedence.
test -n "$RELENG_XORRISO" && xorriso="$RELENG_XORRISO" && RELENG_XORRISO= # test -n "$RELENG_XORRISO" && xorriso="$RELENG_XORRISO" && RELENG_XORRISO=
test -n "$RELENG_WORKIMAGE" && image_file="$RELENG_WORKIMAGE" \ # test -n "$RELENG_WORKIMAGE" && image_file="$RELENG_WORKIMAGE" \
&& RELENG_WORKIMAGE= # && RELENG_WORKIMAGE=
test -n "$RELENG_WORKDIR" && on_disk="$RELENG_WORKDIR" && RELENG_WORKDIR= # test -n "$RELENG_WORKDIR" && on_disk="$RELENG_WORKDIR" && RELENG_WORKDIR=
test -n "$RELENG_ISODIR" && in_iso="$RELENG_ISODIR" && RELENG_ISODIR= # test -n "$RELENG_ISODIR" && in_iso="$RELENG_ISODIR" && RELENG_ISODIR=
test -n "$RELENG_WORKCOPYDIR" && copy_on_disk="$RELENG_WORKCOPYDIR" \ # test -n "$RELENG_WORKCOPYDIR" && copy_on_disk="$RELENG_WORKCOPYDIR" \
&& RELENG_WORKCOPYDIR= # && RELENG_WORKCOPYDIR=
} #}
clean_up() { #clean_up() {
if test "$keep" = 1 # if test "$keep" = 1
then # then
echo "=== Kept test area because of option -keep" >&2 # echo "=== Kept test area because of option -keep" >&2
echo "$on_disk" "$copy_on_disk" "$image_file" "$workdir" >&2 # echo "$on_disk" "$copy_on_disk" "$image_file" "$workdir" >&2
else # else
echo "=== Removing test area" >&2 # echo "=== Removing test area" >&2
rm -r "$on_disk" "$copy_on_disk" "$image_file" # rm -r "$on_disk" "$copy_on_disk" "$image_file"
rm -r "$workdir" # rm -r "$workdir"
fi # fi
} #}
# Setup # Setup
@ -62,50 +69,50 @@ clean_up() {
# >>> Best would be if the configuration file would not override env variables. # >>> Best would be if the configuration file would not override env variables.
# Process env variables and default configfile variables together # Process env variables and default configfile variables together
config_by_var # config_by_var
# Now interpret program arguments and possibly given config files # Now interpret program arguments and possibly given config files
for i in "$@" #for i in "$@"
do #do
if test "$next_is_xorriso" = 1 # if test "$next_is_xorriso" = 1
then # then
xorriso="$i" # xorriso="$i"
next_is_xorriso=0 # next_is_xorriso=0
elif test "$next_is_rc" = 1 # elif test "$next_is_rc" = 1
then # then
# >>> This looks darn dangerous. We need a trustworthy config interpreter. # >>> This looks darn dangerous. We need a trustworthy config interpreter.
# >>> http://www.netjeff.com/humor/item.cgi?file=ShootInFoot-OS # >>> http://www.netjeff.com/humor/item.cgi?file=ShootInFoot-OS
. "$i" # . "$i"
config_by_var # config_by_var
next_is_rc=0 # next_is_rc=0
elif test x"$i" = x"-rc" # elif test x"$i" = x"-rc"
then # then
next_is_rc=1 # next_is_rc=1
elif test x"$i" = x"-keep" # elif test x"$i" = x"-keep"
then # then
keep=1 # keep=1
elif test x"$i" = x"-cleanup" # elif test x"$i" = x"-cleanup"
then # then
keep=0 # keep=0
clean_up # cleanup
exit 0 # exit 0
elif test x"$i" = x"-xorriso" # elif test x"$i" = x"-xorriso"
then # then
next_is_xorriso=1 # next_is_xorriso=1
elif test x"$i" = x"-v" # elif test x"$i" = x"-v"
then # then
report_about="-report_about ALL" # report_about="-report_about ALL"
elif test x"$i" = x"-fail" # elif test x"$i" = x"-fail"
then # then
simulate_failure=1 # simulate_failure=1
else # else
echo "Usage: $0 [-rc FILE] [-keep] [-cleanup] [-fail] [-xorriso PATH] [-v]" >&2 # echo "Usage: $0 [-rc FILE] [-keep] [-cleanup] [-fail] [-xorriso PATH] [-v]" >&2
exit 2 # exit 2
fi # fi
done # done
test -z "$in_iso" && in_iso="$on_disk" test -z "$in_iso" && in_iso="$on_disk"
@ -246,7 +253,7 @@ else
fi fi
clean_up cleanup
# Report result # Report result