cleanup on prepature exits when self-generated data has been produced
This commit is contained in:
parent
73090436d4
commit
d25db0a6ef
@ -25,6 +25,7 @@ RES=""
|
|||||||
REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/current/i386/iso-cd"
|
REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/current/i386/iso-cd"
|
||||||
REMOTE_IMG="debian-testing-i386-businesscard.iso"
|
REMOTE_IMG="debian-testing-i386-businesscard.iso"
|
||||||
|
|
||||||
|
#####
|
||||||
print_help() {
|
print_help() {
|
||||||
cat << HLP
|
cat << HLP
|
||||||
Usage:
|
Usage:
|
||||||
@ -41,23 +42,27 @@ Usage:
|
|||||||
HLP
|
HLP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# safety net, just in case -> we want to be in the starting
|
if [ ${KEEP} -eq 0 ]; then
|
||||||
# directory before removing whatever self-generated stuff
|
# safety net, just in case -> we want to be in the starting
|
||||||
cd "${START_DIR_DONT_CHANGE}" || exit 15
|
# directory before removing whatever self-generated stuff
|
||||||
chmod +w -R ${GEN_DATA_DIR}
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||||
rm -rf ${GEN_DATA_DIR}
|
cd "${START_DIR_DONT_CHANGE}" || exit 15
|
||||||
printf "${SELF}: Removed %s\n" ${GEN_DATA_DIR}
|
chmod +w -R ${GEN_DATA_DIR}
|
||||||
|
rm -rf ${GEN_DATA_DIR}
|
||||||
|
printf "${SELF}: Removed %s\n" ${GEN_DATA_DIR}
|
||||||
|
else
|
||||||
|
printf "${SELF}: ${GEN_DATA_DIR} does not exist. Nothing to clean.\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "${SELF}: Leaving %s\n" ${GEN_DATA_DIR}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# cleanup
|
# cleanup
|
||||||
if [ "${1}" == "-cleanup" ]; then
|
if [ "${1}" == "-cleanup" ]; then
|
||||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
cleanup
|
||||||
cleanup
|
|
||||||
else
|
|
||||||
printf "${SELF}: ${GEN_DATA_DIR} does not exist.\n"
|
|
||||||
fi
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -113,9 +118,7 @@ else
|
|||||||
mkdir "${GEN_DATA_DIR}"
|
mkdir "${GEN_DATA_DIR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# All must be set at this point
|
||||||
|
|
||||||
# all must be set at this point
|
|
||||||
printf "${SELF}: Config items:"
|
printf "${SELF}: Config items:"
|
||||||
printf "\n\txorriso_cmd=${RELENG_XORRISO}\n\tIN_dir=${RELENG_DIR}\n\tOUT_image=${RELENG_IMG}.iso"
|
printf "\n\txorriso_cmd=${RELENG_XORRISO}\n\tIN_dir=${RELENG_DIR}\n\tOUT_image=${RELENG_IMG}.iso"
|
||||||
printf "\n\tIN_isolinux=${RELENG_ISOLINUX_BIN}\n\tOUT_bootcat=${RELENG_BOOT_CAT}\n"
|
printf "\n\tIN_isolinux=${RELENG_ISOLINUX_BIN}\n\tOUT_bootcat=${RELENG_BOOT_CAT}\n"
|
||||||
@ -126,6 +129,7 @@ RES="${RELENG_IMG}.iso ${RELENG_IMG}.new ${RELENG_IMG}.md5 ${RELENG_IMG}.jigdo $
|
|||||||
if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then
|
if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then
|
||||||
printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild."
|
printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit and rebuild."
|
||||||
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
||||||
|
cleanup
|
||||||
exit 9
|
exit 9
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -144,6 +148,7 @@ if [ ! -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\n${SELF}: FAIL: wget returned code: $WGET_RET\n"
|
echo -e "\n${SELF}: FAIL: wget returned code: $WGET_RET\n"
|
||||||
|
cleanup
|
||||||
exit 10
|
exit 10
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -154,6 +159,7 @@ fi
|
|||||||
# check for extraction directory existence
|
# check for extraction directory existence
|
||||||
if [ -d "${IMG_EXTRACT_DIR}" ]; then
|
if [ -d "${IMG_EXTRACT_DIR}" ]; then
|
||||||
printf "\n${SELF}: Found ${IMG_EXTRACT_DIR}. Please cleanup.\n"
|
printf "\n${SELF}: Found ${IMG_EXTRACT_DIR}. Please cleanup.\n"
|
||||||
|
cleanup
|
||||||
exit 11
|
exit 11
|
||||||
else
|
else
|
||||||
mkdir "${IMG_EXTRACT_DIR}"
|
mkdir "${IMG_EXTRACT_DIR}"
|
||||||
@ -181,6 +187,7 @@ if [ -x "${MKFS_MSDOS}" ]; then
|
|||||||
else
|
else
|
||||||
printf "\n${SELF}: Not found: "${MKFS_MSDOS}". Install dosfstools."
|
printf "\n${SELF}: Not found: "${MKFS_MSDOS}". Install dosfstools."
|
||||||
printf "\n${SELF}: http://www.daniel-baumann.ch/software/dosfstools/\n"
|
printf "\n${SELF}: http://www.daniel-baumann.ch/software/dosfstools/\n"
|
||||||
|
cleanup
|
||||||
exit 12
|
exit 12
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -207,6 +214,7 @@ CMD+="\
|
|||||||
"
|
"
|
||||||
else
|
else
|
||||||
printf "\n${SELF}: FAIL to compose the boot section.\n"
|
printf "\n${SELF}: FAIL to compose the boot section.\n"
|
||||||
|
cleanup
|
||||||
exit 13
|
exit 13
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -225,6 +233,7 @@ if which jigdo-gen-md5-list >/dev/null 2>&1; then
|
|||||||
else
|
else
|
||||||
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit."
|
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit."
|
||||||
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
||||||
|
cleanup
|
||||||
exit 14
|
exit 14
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -257,6 +266,7 @@ if which jigit-mkimage >/dev/null 2>&1; then
|
|||||||
else
|
else
|
||||||
printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
|
printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
|
||||||
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
||||||
|
cleanup
|
||||||
exit 15
|
exit 15
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -273,11 +283,7 @@ case ${DIFF_RET} in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# sort out the cruft
|
# sort out the cruft
|
||||||
if [ ${KEEP} -eq 0 ]; then
|
cleanup
|
||||||
cleanup
|
|
||||||
else
|
|
||||||
printf "${SELF}: Leaving %s\n" ${GEN_DATA_DIR}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# last hints
|
# last hints
|
||||||
printf "\n${SELF}: HINT: manual checks remained to be done:\n"
|
printf "\n${SELF}: HINT: manual checks remained to be done:\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user