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