2011-07-08 10:32:22 +00:00
|
|
|
SELF=$(basename $0)
|
|
|
|
RELENG_XORRISO=0
|
|
|
|
KEEP=0
|
|
|
|
SIMULATE_FAILURE=0
|
2011-07-08 12:16:44 +00:00
|
|
|
CLEANUP=1
|
2011-07-08 10:32:22 +00:00
|
|
|
|
2011-07-08 12:16:44 +00:00
|
|
|
START_DIR_DONT_CHANGE=`pwd`
|
|
|
|
GEN_DATA_DIR=releng_generated_data/${SELF}
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
print_help() {
|
2011-07-08 10:32:22 +00:00
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
Usage: $SELF -x path/to/xorriso [-k0|1] [-f0|1] [-h]
|
|
|
|
-x absolute or relative path to binary to be run.
|
2011-07-08 12:16:44 +00:00
|
|
|
-k keep selfgenerated data (values 0,1, default 0).
|
|
|
|
-c cleanup selfgenerated data kept from previous
|
|
|
|
run and exit (values 0,1, default 0).
|
|
|
|
-f simulate failure (values 0,1, default 0).
|
2011-07-08 10:32:22 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2011-07-08 12:16:44 +00:00
|
|
|
#############################################
|
|
|
|
cleanup() {
|
|
|
|
if [ ${KEEP} -eq 0 -a ${CLEANUP} -eq 1 ]; then
|
|
|
|
# safety net, just in case -> we want to be in the starting
|
|
|
|
# directory before removing whatever self-generated stuff
|
|
|
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
|
|
|
cd "${START_DIR_DONT_CHANGE}" || exit 2
|
2011-07-08 13:05:21 +00:00
|
|
|
chmod +w -R ${GEN_DATA_DIR}
|
2011-07-08 12:16:44 +00:00
|
|
|
rm -rf ${GEN_DATA_DIR}
|
|
|
|
printf "${SELF}: Removed (self-generated) %s\n" ${GEN_DATA_DIR}
|
|
|
|
else
|
|
|
|
printf "${SELF}: ${GEN_DATA_DIR} does not exist. Nothing to clean.\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "${SELF}: Leaving (self-generated) %s\n" ${GEN_DATA_DIR}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
while getopts “x:k:c:f:h” OPTION
|
2011-07-08 10:32:22 +00:00
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
x)
|
|
|
|
RELENG_XORRISO=$OPTARG
|
|
|
|
;;
|
|
|
|
k)
|
|
|
|
KEEP=$OPTARG
|
|
|
|
;;
|
2011-07-08 12:16:44 +00:00
|
|
|
c)
|
|
|
|
CLEANUP=$OPTARG
|
|
|
|
cleanup
|
|
|
|
exit 0
|
|
|
|
;;
|
2011-07-08 10:32:22 +00:00
|
|
|
f)
|
|
|
|
SIMULATE_FAILURE=$OPTARG
|
|
|
|
;;
|
|
|
|
h)
|
2011-07-08 12:16:44 +00:00
|
|
|
print_help
|
2011-07-08 10:32:22 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
2011-07-08 12:16:44 +00:00
|
|
|
print_help
|
2011-07-08 10:32:22 +00:00
|
|
|
exit 31
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2011-07-08 12:16:44 +00:00
|
|
|
# Each releng_ test should decide whether or not to check that
|
|
|
|
#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
|
|
|
|
|
|
|
|
if [ x"$KEEP" != x"0" -a x"$KEEP" != x"1" ]; then
|
|
|
|
print_help
|
|
|
|
printf "\n${SELF}: -k keep selfgenerated data.\n\n"
|
2011-07-08 10:32:22 +00:00
|
|
|
exit 31
|
|
|
|
fi
|
|
|
|
|
2011-07-08 12:16:44 +00:00
|
|
|
if [ x"$CLEANUP" != x"0" -a x"$CLEANUP" != x"1" ]; then
|
|
|
|
print_help
|
|
|
|
printf "\n${SELF}: -c cleanup selfgenerated data kept from previous run.\n\n"
|
2011-07-08 10:32:22 +00:00
|
|
|
exit 31
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x"$SIMULATE_FAILURE" != x"0" -a x"$SIMULATE_FAILURE" != x"1" ]; then
|
2011-07-08 12:16:44 +00:00
|
|
|
print_help
|
|
|
|
printf "\n${SELF}: -f simulate failure.\n\n"
|
2011-07-08 10:32:22 +00:00
|
|
|
exit 31
|
|
|
|
fi
|