more unification
This commit is contained in:
@ -2,68 +2,17 @@
|
||||
|
||||
set -e
|
||||
|
||||
START_DIR_DONT_CHANGE=`pwd`
|
||||
SELF=$(basename "$0")
|
||||
GEN_DATA_DIR=releng_generated_data/${SELF}
|
||||
KEEP=0
|
||||
. inc/releng_getopts.inc
|
||||
|
||||
# xorriso binary is not needed for that particular test
|
||||
|
||||
SAMPLE_CODE_DIR=codesamples
|
||||
CC=g++
|
||||
|
||||
#####################################################################
|
||||
print_help() {
|
||||
cat << HLP
|
||||
Usage:
|
||||
$0 -help
|
||||
|
||||
#
|
||||
$0 -rc [-keep]
|
||||
|
||||
# cleanup test generated data directory and exit
|
||||
$0 -cleanup
|
||||
HLP
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
cleanup() {
|
||||
if [ ${KEEP} -eq 0 ]; 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
|
||||
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
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# help
|
||||
if [ ! "${1}" ]; then
|
||||
print_help && exit 3
|
||||
#
|
||||
elif [ "${1}" == "-cleanup" ]; then
|
||||
cleanup
|
||||
exit 0
|
||||
#
|
||||
elif [ "${1}" == "-rc" -a "${2}" == "-keep" ]; then
|
||||
KEEP=1
|
||||
elif [ "${1}" == "-rc" -a ! "${2}" ]; then
|
||||
KEEP=0
|
||||
# the rest
|
||||
else
|
||||
print_help && exit 4
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# check data dir
|
||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
||||
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
|
||||
printf "\n${SELF}: use '${SELF} -c1' to remove.\n"
|
||||
exit 5
|
||||
else
|
||||
mkdir "${GEN_DATA_DIR}"
|
||||
|
Reference in New Issue
Block a user