use basename for self
This commit is contained in:
parent
556f9282dc
commit
43e9635bf3
@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
START_DIR_DONT_CHANGE=`pwd`
|
||||
|
||||
SELF=$(basename "$0")
|
||||
# required config items
|
||||
XOR=""
|
||||
DIR=""
|
||||
@ -13,22 +13,22 @@ ISOLINUX_BIN=""
|
||||
BOOT_CAT=""
|
||||
CONFFILE=$HOME/releng_build_isojigdo.conf
|
||||
KEEP=0
|
||||
GEN_DATA_DIR=$0.result
|
||||
GEN_DATA_DIR=${SELF}.result
|
||||
RES=""
|
||||
|
||||
print_help() {
|
||||
cat << HLP
|
||||
Usage:
|
||||
$0 -help
|
||||
${SELF} -help
|
||||
|
||||
# using a config file ${CONFFILE}
|
||||
$0 -rc [-keep]
|
||||
${SELF} -rc [-keep]
|
||||
|
||||
# without using a config file
|
||||
$0 xorriso_cmd IN_dir OUT_image [IN_isolinux] [OUT_bootcat] [-keep]
|
||||
${SELF} xorriso_cmd IN_dir OUT_image [IN_isolinux] [OUT_bootcat] [-keep]
|
||||
|
||||
# cleanup test generated data directory and exit
|
||||
$0 -cleanup
|
||||
${SELF} -cleanup
|
||||
HLP
|
||||
}
|
||||
|
||||
@ -38,9 +38,9 @@ if [ "${1}" == "-cleanup" ]; then
|
||||
cd "${START_DIR_DONT_CHANGE}" || exit 80
|
||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||
rm -rf ${GEN_DATA_DIR}
|
||||
printf "$0: removed %s\n" ${GEN_DATA_DIR}
|
||||
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
|
||||
else
|
||||
printf "$0: ${GEN_DATA_DIR} does not exist.\n"
|
||||
printf "${SELF}: ${GEN_DATA_DIR} does not exist.\n"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
@ -51,9 +51,9 @@ if [ ! "${1}" ]; then print_help && exit 10; fi
|
||||
if [ "${1}" == "-rc" ]; then
|
||||
if [ -e ${CONFFILE} ]; then
|
||||
. ${CONFFILE}
|
||||
printf "$0: Using config file %s\n" ${CONFFILE}
|
||||
printf "${SELF}: Using config file %s\n" ${CONFFILE}
|
||||
else
|
||||
echo -e "\n$0: Config file ${CONFFILE} not found.\n" && exit 20
|
||||
echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 20
|
||||
fi
|
||||
if [ "${2}" == "-keep" ]; then KEEP=1; fi
|
||||
# command line args
|
||||
@ -73,25 +73,25 @@ fi
|
||||
|
||||
# data dir
|
||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||
printf "\n$0: directory %s exists!" ${GEN_DATA_DIR}
|
||||
printf "\n$0: use '$0 -cleanup' to remove.\n"
|
||||
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
||||
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
|
||||
exit 2
|
||||
else
|
||||
mkdir "${GEN_DATA_DIR}"
|
||||
fi
|
||||
|
||||
if [ "${XOR}" == "" -o "${DIR}" == "" -o "${IMG}" == "" ]; then
|
||||
echo -e "\n$0: xorriso_cmd IN_dir and OUT_image are required\n"
|
||||
echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n"
|
||||
exit 40
|
||||
fi
|
||||
|
||||
if [ ! -x "${XOR}" ]; then
|
||||
printf "$0: Not found or not an executable: $XOR\n"
|
||||
printf "${SELF}: Not found or not an executable: $XOR\n"
|
||||
exit 50
|
||||
fi
|
||||
|
||||
# all must be set at this point
|
||||
printf "$0: Config items:"
|
||||
printf "${SELF}: Config items:"
|
||||
printf "\n\txorriso_cmd=${XOR}\n\tIN_dir=${DIR}\n\tOUT_image=${IMG}.iso"
|
||||
printf "\n\tIN_isolinux=${ISOLINUX_BIN}\n\tOUT_bootcat=${BOOT_CAT}\n"
|
||||
RES="${IMG}.iso ${IMG}.new ${IMG}.md5 ${IMG}.jigdo ${IMG}.template"
|
||||
@ -99,8 +99,8 @@ RES="${IMG}.iso ${IMG}.new ${IMG}.md5 ${IMG}.jigdo ${IMG}.template"
|
||||
# xorriso version details, incl. underlying libraries
|
||||
"${XOR}" -version
|
||||
if ! "${XOR}" -version | grep libjte >/dev/null 2>&1; then
|
||||
printf "\n$0: JTE not supported with this xorriso build. Install jigit and rebuild."
|
||||
printf "\n$0: See http://www.einval.com/~steve/software/JTE/\n"
|
||||
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"
|
||||
exit 51
|
||||
fi
|
||||
|
||||
@ -115,12 +115,12 @@ fi
|
||||
|
||||
# create MD5 list in base64 format
|
||||
if which jigdo-gen-md5-list >/dev/null 2>&1; then
|
||||
printf "$0: Creating MD5 list in hex format..."
|
||||
printf "${SELF}: Creating MD5 list in hex format..."
|
||||
jigdo-gen-md5-list ${DIR} > ${GEN_DATA_DIR}/${IMG}.md5
|
||||
printf "Done.\n"
|
||||
else
|
||||
printf "\n$0: Not found: jigdo-gen-md5-list. Install jigit."
|
||||
printf "\n$0: See http://www.einval.com/~steve/software/JTE/\n"
|
||||
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit."
|
||||
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
||||
exit 60
|
||||
fi
|
||||
|
||||
@ -161,12 +161,12 @@ CMD+="\
|
||||
CMD+="${DIR}"
|
||||
|
||||
# run it
|
||||
echo -e "$0: Creating ISO and jigdo representations:\n$CMD\n"
|
||||
echo -e "${SELF}: Creating ISO and jigdo representations:\n$CMD\n"
|
||||
${CMD}
|
||||
|
||||
# create another one from jigdo files
|
||||
if which jigit-mkimage >/dev/null 2>&1; then
|
||||
printf "$0: Creating new ISO from jigdo files..."
|
||||
printf "${SELF}: Creating new ISO from jigdo files..."
|
||||
jigit-mkimage \
|
||||
-t ${GEN_DATA_DIR}/${IMG}.template \
|
||||
-j ${GEN_DATA_DIR}/${IMG}.jigdo \
|
||||
@ -174,8 +174,8 @@ if which jigit-mkimage >/dev/null 2>&1; then
|
||||
-o ${GEN_DATA_DIR}/${IMG}.new
|
||||
printf "Done.\n"
|
||||
else
|
||||
printf "\n$0: Not found: jigit-mkimage. Install jigit."
|
||||
printf "\n$0: See http://www.einval.com/~steve/software/JTE/\n"
|
||||
printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
|
||||
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
||||
exit 70
|
||||
fi
|
||||
|
||||
@ -184,10 +184,10 @@ diff ${GEN_DATA_DIR}/${IMG}.iso ${GEN_DATA_DIR}/${IMG}.new
|
||||
DIFF_RET="$?"
|
||||
case ${DIFF_RET} in
|
||||
0)
|
||||
echo -e "$0: diff ${GEN_DATA_DIR}/${IMG}.iso ${GEN_DATA_DIR}/${IMG}.new matched.\n"
|
||||
echo -e "${SELF}: diff ${GEN_DATA_DIR}/${IMG}.iso ${GEN_DATA_DIR}/${IMG}.new matched.\n"
|
||||
;;
|
||||
*)
|
||||
echo -e "$0: FAIL: diff returned code: $DIFF_RET\n"
|
||||
echo -e "${SELF}: FAIL: diff returned code: $DIFF_RET\n"
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -197,13 +197,13 @@ if [ ${KEEP} -eq 0 ]; then
|
||||
# directory before removing whatever self-generated stuff
|
||||
cd "${START_DIR_DONT_CHANGE}" || exit 80
|
||||
rm -rf ${GEN_DATA_DIR}
|
||||
printf "$0: removed %s\n" ${GEN_DATA_DIR}
|
||||
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
|
||||
else
|
||||
printf "$0: leaving %s\n" ${GEN_DATA_DIR}
|
||||
printf "${SELF}: leaving %s\n" ${GEN_DATA_DIR}
|
||||
fi
|
||||
|
||||
# last hints
|
||||
printf "\n$0: HINT: manual checks remained to be done:\n"
|
||||
printf "\n${SELF}: HINT: manual checks remained to be done:\n"
|
||||
printf " * ${IMG}.img boots from USB stick and/or optical media.\n"
|
||||
printf " * appended FAT partition is mountable.\n"
|
||||
printf " * xorriso -indev ${IMG}.iso -pvd_info\n"
|
||||
|
Loading…
Reference in New Issue
Block a user