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