2011-06-22 14:43:06 +00:00
|
|
|
#!/bin/bash
|
2011-06-22 13:33:10 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2011-06-23 16:25:15 +00:00
|
|
|
START_DIR_DONT_CHANGE=`pwd`
|
2011-06-27 18:06:29 +00:00
|
|
|
SELF=$(basename "$0")
|
2011-06-23 16:22:17 +00:00
|
|
|
# required config items
|
2011-06-28 16:20:31 +00:00
|
|
|
RELENG_XORRISO=""
|
|
|
|
RELENG_DIR=""
|
|
|
|
RELENG_IMG=""
|
2011-06-23 16:22:17 +00:00
|
|
|
# optional config items
|
2011-06-28 16:20:31 +00:00
|
|
|
RELENG_ISOLINUX_BIN=""
|
|
|
|
RELENG_BOOT_CAT=""
|
2011-07-02 17:35:27 +00:00
|
|
|
CONFFILE=$HOME/.libburnia-releng/${SELF}.conf
|
2011-06-28 12:30:36 +00:00
|
|
|
GEN_DATA_DIR=releng_generated_data/${SELF}
|
2011-06-28 20:58:56 +00:00
|
|
|
KEEP=0
|
2011-06-26 23:44:51 +00:00
|
|
|
RES=""
|
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
print_help() {
|
|
|
|
cat << HLP
|
|
|
|
Usage:
|
2011-06-27 18:06:29 +00:00
|
|
|
${SELF} -help
|
2011-06-27 14:50:50 +00:00
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
# using a config file ${CONFFILE}
|
2011-06-27 18:06:29 +00:00
|
|
|
${SELF} -rc [-keep]
|
2011-06-27 14:50:50 +00:00
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
# without using a config file
|
2011-06-27 18:06:29 +00:00
|
|
|
${SELF} xorriso_cmd IN_dir OUT_image [IN_isolinux] [OUT_bootcat] [-keep]
|
2011-06-27 14:50:50 +00:00
|
|
|
|
|
|
|
# cleanup test generated data directory and exit
|
2011-06-27 18:06:29 +00:00
|
|
|
${SELF} -cleanup
|
2011-06-23 10:34:39 +00:00
|
|
|
HLP
|
|
|
|
}
|
|
|
|
|
2011-06-26 23:44:51 +00:00
|
|
|
#####################################################################
|
2011-06-27 14:50:50 +00:00
|
|
|
# cleanup
|
|
|
|
if [ "${1}" == "-cleanup" ]; then
|
|
|
|
cd "${START_DIR_DONT_CHANGE}" || exit 80
|
|
|
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
|
|
|
rm -rf ${GEN_DATA_DIR}
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
|
2011-06-27 14:50:50 +00:00
|
|
|
else
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: ${GEN_DATA_DIR} does not exist.\n"
|
2011-06-27 14:50:50 +00:00
|
|
|
fi
|
|
|
|
exit 0
|
2011-06-27 14:23:50 +00:00
|
|
|
fi
|
2011-06-27 14:50:50 +00:00
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
# help
|
2011-06-26 23:44:51 +00:00
|
|
|
if [ ! "${1}" ]; then print_help && exit 10; fi
|
2011-06-23 10:34:39 +00:00
|
|
|
# config file
|
|
|
|
if [ "${1}" == "-rc" ]; then
|
2011-06-23 14:48:36 +00:00
|
|
|
if [ -e ${CONFFILE} ]; then
|
|
|
|
. ${CONFFILE}
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: Using config file %s\n" ${CONFFILE}
|
2011-06-23 14:48:36 +00:00
|
|
|
else
|
2011-06-27 18:06:29 +00:00
|
|
|
echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 20
|
2011-06-23 10:34:39 +00:00
|
|
|
fi
|
2011-06-27 14:31:39 +00:00
|
|
|
if [ "${2}" == "-keep" ]; then KEEP=1; fi
|
2011-06-23 10:34:39 +00:00
|
|
|
# command line args
|
|
|
|
elif [ "${3}" ]; then
|
2011-06-28 16:20:31 +00:00
|
|
|
RELENG_XORRISO="${1}"
|
|
|
|
RELENG_DIR="${2}"
|
|
|
|
RELENG_IMG="${3}"
|
2011-06-25 14:25:49 +00:00
|
|
|
if [ "${4}" ]; then
|
2011-06-28 16:20:31 +00:00
|
|
|
RELENG_ISOLINUX_BIN="${4}"
|
|
|
|
if [ "${5}" ]; then RELENG_BOOT_CAT="${5}"; fi
|
2011-06-27 14:31:39 +00:00
|
|
|
if [ "${4}" == "-keep" -o "${5}" == "-keep" -o "${6}" == "-keep" ]; then KEEP=1; fi
|
2011-06-23 10:34:39 +00:00
|
|
|
fi
|
|
|
|
# the rest
|
|
|
|
else
|
2011-06-26 21:06:32 +00:00
|
|
|
print_help && exit 30
|
2011-06-22 14:43:06 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-27 14:50:50 +00:00
|
|
|
# data dir
|
|
|
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
|
|
|
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
|
2011-06-27 14:50:50 +00:00
|
|
|
exit 2
|
|
|
|
else
|
|
|
|
mkdir "${GEN_DATA_DIR}"
|
|
|
|
fi
|
|
|
|
|
2011-06-28 16:20:31 +00:00
|
|
|
if [ "${RELENG_XORRISO}" == "" -o "${RELENG_DIR}" == "" -o "${RELENG_IMG}" == "" ]; then
|
2011-06-27 18:06:29 +00:00
|
|
|
echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n"
|
2011-06-26 21:06:32 +00:00
|
|
|
exit 40
|
2011-06-23 14:48:36 +00:00
|
|
|
fi
|
2011-06-22 14:43:06 +00:00
|
|
|
|
2011-06-28 16:20:31 +00:00
|
|
|
if [ ! -x "${RELENG_XORRISO}" ]; then
|
|
|
|
printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n"
|
2011-06-26 21:06:32 +00:00
|
|
|
exit 50
|
2011-06-24 07:13:30 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-23 14:48:36 +00:00
|
|
|
# all must be set at this point
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: Config items:"
|
2011-06-28 16:20:31 +00:00
|
|
|
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"
|
|
|
|
RES="${RELENG_IMG}.iso ${RELENG_IMG}.new ${RELENG_IMG}.md5 ${RELENG_IMG}.jigdo ${RELENG_IMG}.template"
|
2011-06-26 23:44:51 +00:00
|
|
|
|
|
|
|
# xorriso version details, incl. underlying libraries
|
2011-06-28 16:20:31 +00:00
|
|
|
"${RELENG_XORRISO}" -version
|
|
|
|
if ! "${RELENG_XORRISO}" -version | grep libjte >/dev/null 2>&1; then
|
2011-06-27 18:06:29 +00:00
|
|
|
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"
|
2011-06-26 21:36:31 +00:00
|
|
|
exit 51
|
|
|
|
fi
|
2011-06-24 12:53:07 +00:00
|
|
|
|
2011-06-22 14:43:06 +00:00
|
|
|
# remove cruft from previous runs
|
|
|
|
# rm -f ${RES}
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 20:32:09 +00:00
|
|
|
# grab an MBR
|
|
|
|
# dd if=some.iso bs=1K count=32 of=somembr.sysarea
|
|
|
|
|
2011-06-22 20:20:00 +00:00
|
|
|
# create FAT partition
|
2011-06-22 20:32:09 +00:00
|
|
|
# /sbin/mkfs.msdos -n Bla -C fatpart.fat 8192
|
2011-06-22 20:20:00 +00:00
|
|
|
|
|
|
|
# create MD5 list in base64 format
|
2011-06-23 11:01:39 +00:00
|
|
|
if which jigdo-gen-md5-list >/dev/null 2>&1; then
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: Creating MD5 list in hex format..."
|
2011-06-28 16:20:31 +00:00
|
|
|
jigdo-gen-md5-list ${RELENG_DIR} > ${GEN_DATA_DIR}/${RELENG_IMG}.md5
|
2011-06-23 11:01:39 +00:00
|
|
|
printf "Done.\n"
|
|
|
|
else
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit."
|
|
|
|
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
2011-06-26 21:06:32 +00:00
|
|
|
exit 60
|
2011-06-23 11:01:39 +00:00
|
|
|
fi
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 20:20:00 +00:00
|
|
|
# build the command - general section
|
2011-06-28 16:20:31 +00:00
|
|
|
CMD="${RELENG_XORRISO} \
|
2011-06-22 20:20:00 +00:00
|
|
|
-as mkisofs \
|
2011-06-23 14:48:36 +00:00
|
|
|
-quiet \
|
2011-06-28 16:20:31 +00:00
|
|
|
-o ${GEN_DATA_DIR}/${RELENG_IMG}.iso \
|
2011-06-22 20:20:00 +00:00
|
|
|
-R \
|
|
|
|
-V ISOJIGDO \
|
|
|
|
-partition_offset 16 \
|
|
|
|
-J -joliet-long \
|
|
|
|
"
|
2011-06-25 16:11:43 +00:00
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
# boot section TODO
|
2011-06-28 16:20:31 +00:00
|
|
|
#if [ "${RELENG_ISOLINUX_BIN}" -a "${RELENG_BOOT_CAT}" ]; then
|
2011-06-22 20:32:09 +00:00
|
|
|
#CMD+=\
|
2011-06-28 16:20:31 +00:00
|
|
|
# -b ${RELENG_ISOLINUX_BIN} \ # NOTE: boot/isolinux/isolinux.bin
|
|
|
|
# -c ${RELENG_BOOT_CAT} \ # NOTE: boot/boot.cat
|
2011-06-22 20:32:09 +00:00
|
|
|
# -no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
|
|
# -isohybrid-mbr somembr.sysarea \ # TODO: figure out where to grab one
|
|
|
|
# -partition_offset 16 \
|
2011-06-25 16:11:43 +00:00
|
|
|
# -append_partition 2 0x01 fatpart.fat \ # TODO: create one unconditionally?
|
2011-06-22 20:20:00 +00:00
|
|
|
#fi
|
|
|
|
|
|
|
|
# jigdo section
|
|
|
|
CMD+="\
|
|
|
|
-jigdo-template-compress gzip \
|
|
|
|
-checksum_algorithm_iso md5,sha1,sha256,sha512 \
|
|
|
|
-checksum_algorithm_template md5,sha1,sha256,sha512 \
|
2011-06-28 16:20:31 +00:00
|
|
|
-jigdo-jigdo ${GEN_DATA_DIR}/${RELENG_IMG}.jigdo \
|
|
|
|
-jigdo-template ${GEN_DATA_DIR}/${RELENG_IMG}.template \
|
|
|
|
-jigdo-map Debian=${RELENG_DIR} \
|
|
|
|
-md5-list ${GEN_DATA_DIR}/${RELENG_IMG}.md5 \
|
2011-06-22 20:20:00 +00:00
|
|
|
-jigdo-min-file-size 1024 \
|
|
|
|
"
|
|
|
|
|
2011-06-28 16:20:31 +00:00
|
|
|
CMD+="${RELENG_DIR}"
|
2011-06-22 20:20:00 +00:00
|
|
|
|
|
|
|
# run it
|
2011-06-27 18:06:29 +00:00
|
|
|
echo -e "${SELF}: Creating ISO and jigdo representations:\n$CMD\n"
|
2011-06-22 20:20:00 +00:00
|
|
|
${CMD}
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 20:20:00 +00:00
|
|
|
# create another one from jigdo files
|
2011-06-23 16:49:42 +00:00
|
|
|
if which jigit-mkimage >/dev/null 2>&1; then
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: Creating new ISO from jigdo files..."
|
2011-06-23 16:49:42 +00:00
|
|
|
jigit-mkimage \
|
2011-06-28 16:20:31 +00:00
|
|
|
-t ${GEN_DATA_DIR}/${RELENG_IMG}.template \
|
|
|
|
-j ${GEN_DATA_DIR}/${RELENG_IMG}.jigdo \
|
|
|
|
-m Debian=${RELENG_DIR} \
|
|
|
|
-o ${GEN_DATA_DIR}/${RELENG_IMG}.new
|
2011-06-23 16:49:42 +00:00
|
|
|
printf "Done.\n"
|
|
|
|
else
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "\n${SELF}: Not found: jigit-mkimage. Install jigit."
|
|
|
|
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
|
2011-06-26 21:06:32 +00:00
|
|
|
exit 70
|
2011-06-23 16:49:42 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-23 16:09:47 +00:00
|
|
|
# trap the exit code of diff and let the Universe explode
|
2011-06-28 16:20:31 +00:00
|
|
|
diff ${GEN_DATA_DIR}/${RELENG_IMG}.iso ${GEN_DATA_DIR}/${RELENG_IMG}.new
|
2011-06-23 16:09:47 +00:00
|
|
|
DIFF_RET="$?"
|
|
|
|
case ${DIFF_RET} in
|
|
|
|
0)
|
2011-06-28 16:20:31 +00:00
|
|
|
echo -e "${SELF}: diff ${GEN_DATA_DIR}/${RELENG_IMG}.iso ${GEN_DATA_DIR}/${RELENG_IMG}.new matched.\n"
|
2011-06-23 16:09:47 +00:00
|
|
|
;;
|
|
|
|
*)
|
2011-06-27 18:06:29 +00:00
|
|
|
echo -e "${SELF}: FAIL: diff returned code: $DIFF_RET\n"
|
2011-06-23 16:09:47 +00:00
|
|
|
;;
|
|
|
|
esac
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 14:43:06 +00:00
|
|
|
# sort out the cruft
|
2011-06-27 14:31:39 +00:00
|
|
|
if [ ${KEEP} -eq 0 ]; then
|
2011-06-23 16:22:17 +00:00
|
|
|
# safety net, just in case -> we want to be in the starting
|
|
|
|
# directory before removing whatever self-generated stuff
|
2011-06-26 21:06:32 +00:00
|
|
|
cd "${START_DIR_DONT_CHANGE}" || exit 80
|
2011-06-27 14:23:50 +00:00
|
|
|
rm -rf ${GEN_DATA_DIR}
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: removed %s\n" ${GEN_DATA_DIR}
|
2011-06-22 14:43:06 +00:00
|
|
|
else
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "${SELF}: leaving %s\n" ${GEN_DATA_DIR}
|
2011-06-22 14:43:06 +00:00
|
|
|
fi
|
2011-06-23 11:14:41 +00:00
|
|
|
|
|
|
|
# last hints
|
2011-06-27 18:06:29 +00:00
|
|
|
printf "\n${SELF}: HINT: manual checks remained to be done:\n"
|
2011-06-28 16:20:31 +00:00
|
|
|
printf " * ${RELENG_IMG}.img boots from USB stick and/or optical media.\n"
|
2011-06-23 14:48:36 +00:00
|
|
|
printf " * appended FAT partition is mountable.\n"
|
2011-06-28 16:20:31 +00:00
|
|
|
printf " * xorriso -indev ${RELENG_IMG}.iso -pvd_info\n"
|
|
|
|
printf " * fdisk -lu ${RELENG_IMG}.iso\n"
|
2011-06-23 11:14:41 +00:00
|
|
|
|
2011-06-25 16:58:16 +00:00
|
|
|
exit 0
|