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-23 16:22:17 +00:00
|
|
|
# required config items
|
2011-06-23 10:34:39 +00:00
|
|
|
XOR=""
|
|
|
|
DIR=""
|
|
|
|
IMG=""
|
2011-06-23 16:22:17 +00:00
|
|
|
# optional config items
|
2011-06-23 10:34:39 +00:00
|
|
|
ISOLINUX_BIN=""
|
|
|
|
BOOT_CAT=""
|
2011-06-23 11:01:39 +00:00
|
|
|
CONFFILE=$HOME/releng_build_isojigdo.conf
|
2011-06-23 10:34:39 +00:00
|
|
|
CLEAN=0
|
|
|
|
|
|
|
|
print_help() {
|
|
|
|
cat << HLP
|
|
|
|
Usage:
|
|
|
|
$0 -help
|
|
|
|
# using a config file ${CONFFILE}
|
|
|
|
$0 -rc [-clean]
|
|
|
|
config file content:
|
|
|
|
XOR=/path/to/xorriso
|
|
|
|
DIR=/path/to/input_dir
|
|
|
|
IMG=/path/to/out_image
|
|
|
|
ISOLINUX_BIN=/path/to/isolinux.bin
|
|
|
|
BOOT_CAT=/path/to/boot.cat
|
|
|
|
# without using a config file
|
|
|
|
$0 xorriso_cmd IN_dir OUT_image [IN_isolinux] [IN_bootcat] [-clean]
|
|
|
|
HLP
|
|
|
|
}
|
|
|
|
|
|
|
|
# help
|
|
|
|
if [ ! "${1}" -o "${1}" == "-help" ]; then print_help && exit 0; fi
|
|
|
|
# config file
|
|
|
|
if [ "${1}" == "-rc" ]; then
|
2011-06-23 14:48:36 +00:00
|
|
|
if [ -e ${CONFFILE} ]; then
|
|
|
|
. ${CONFFILE}
|
|
|
|
printf "$0: Using config file %s\n" ${CONFFILE}
|
|
|
|
else
|
|
|
|
echo -e "\n$0: Config file ${CONFFILE} not found.\n" && exit 1
|
2011-06-23 10:34:39 +00:00
|
|
|
fi
|
|
|
|
if [ "${2}" == "-clean" ]; then CLEAN=1; fi
|
|
|
|
# command line args
|
|
|
|
elif [ "${3}" ]; then
|
|
|
|
XOR="${1}"
|
|
|
|
DIR="${2}"
|
|
|
|
IMG="${3}"
|
|
|
|
if [ "{4}" ]; then
|
|
|
|
ISOLINUX_BIN="${4}"
|
|
|
|
if [ "{5}" ]; then BOOT_CAT="${5}"; fi
|
|
|
|
if [ "${4}" == "-clean" -o "${5}" == "-clean" -o "${6}" == "-clean" ]; then CLEAN=1; fi
|
|
|
|
fi
|
|
|
|
# the rest
|
|
|
|
else
|
|
|
|
print_help && exit 0
|
2011-06-22 14:43:06 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-23 14:48:36 +00:00
|
|
|
if [ "${XOR}" == "" -o "${DIR}" == "" -o "${IMG}" == "" ]; then
|
|
|
|
echo -e "\n$0: xorriso_cmd IN_dir and OUT_image are required\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-22 14:43:06 +00:00
|
|
|
|
2011-06-24 07:13:30 +00:00
|
|
|
if [ ! -x "${XOR}" ]; then
|
|
|
|
printf "$0: Not found or not an executable: $XOR\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-06-23 14:48:36 +00:00
|
|
|
# all must be set at this point
|
|
|
|
printf "$0: Config items:"
|
|
|
|
printf "\n\txorriso_cmd=${XOR}\n\tIN_dir=${DIR}\n\tOUT_image=${IMG}.iso"
|
|
|
|
printf "\n\tIN_isolinux=${ISOLINUX_BIN}\n\tIN_bootcat=${BOOT_CAT}\n"
|
|
|
|
RES="${IMG}.iso ${IMG}.new ${IMG}.md5 ${IMG}.jigdo ${IMG}.template"
|
2011-06-23 10:34:39 +00:00
|
|
|
############################################################
|
|
|
|
main() {
|
2011-06-24 12:53:07 +00:00
|
|
|
# version details, incl. underlying libraries
|
|
|
|
"${XOR}" -version
|
|
|
|
|
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
|
|
|
|
printf "$0: Creating MD5 list in hex format..."
|
|
|
|
jigdo-gen-md5-list ${DIR} > ${IMG}.md5
|
|
|
|
printf "Done.\n"
|
|
|
|
else
|
2011-06-23 14:48:36 +00:00
|
|
|
printf "\n$0: Not found: jigdo-gen-md5-list. Install jigit.\n"
|
2011-06-23 11:01:39 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 20:20:00 +00:00
|
|
|
# build the command - general section
|
|
|
|
CMD="${XOR} \
|
|
|
|
-as mkisofs \
|
2011-06-23 14:48:36 +00:00
|
|
|
-quiet \
|
2011-06-22 20:20:00 +00:00
|
|
|
-o ${IMG}.iso \
|
|
|
|
-R \
|
|
|
|
-V ISOJIGDO \
|
|
|
|
-partition_offset 16 \
|
|
|
|
-J -joliet-long \
|
|
|
|
"
|
2011-06-23 10:34:39 +00:00
|
|
|
# boot section TODO
|
2011-06-22 20:32:09 +00:00
|
|
|
#if [ "${5}" -a "${6}" ]; then
|
|
|
|
#CMD+=\
|
|
|
|
# -b boot/isolinux/isolinux.bin \ # $5
|
|
|
|
# -c boot/boot.cat \ # $6
|
|
|
|
# -no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
|
|
# -isohybrid-mbr somembr.sysarea \ # TODO: figure out where to grab one
|
|
|
|
# -partition_offset 16 \
|
|
|
|
# -append_partition 2 0x01 fatpart.fat \
|
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 \
|
|
|
|
-jigdo-jigdo ${IMG}.jigdo \
|
|
|
|
-jigdo-template ${IMG}.template \
|
|
|
|
-jigdo-map Debian=${DIR} \
|
|
|
|
-md5-list ${IMG}.md5 \
|
|
|
|
-jigdo-min-file-size 1024 \
|
|
|
|
"
|
|
|
|
|
|
|
|
CMD+="${DIR}"
|
|
|
|
|
|
|
|
# run it
|
2011-06-23 11:01:39 +00:00
|
|
|
echo -e "$0: 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
|
|
|
|
printf "$0: Creating new ISO from jigdo files..."
|
|
|
|
jigit-mkimage \
|
|
|
|
-t ${IMG}.template \
|
|
|
|
-j ${IMG}.jigdo \
|
|
|
|
-m Debian=${DIR} \
|
|
|
|
-o ${IMG}.new
|
|
|
|
printf "Done.\n"
|
|
|
|
else
|
|
|
|
printf "\n$0: Not found: jigit-mkimage. Install jigit.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2011-06-22 14:43:06 +00:00
|
|
|
|
2011-06-23 16:09:47 +00:00
|
|
|
# trap the exit code of diff and let the Universe explode
|
2011-06-22 14:43:06 +00:00
|
|
|
diff ${IMG}.iso ${IMG}.new
|
2011-06-23 16:09:47 +00:00
|
|
|
DIFF_RET="$?"
|
|
|
|
case ${DIFF_RET} in
|
|
|
|
0)
|
|
|
|
echo -e "$0: diff ${IMG}.iso ${IMG}.new matched.\n"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -e "$0: ATTN: diff returned code: $DIFF_RET\n"
|
|
|
|
;;
|
|
|
|
esac
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-06-22 14:43:06 +00:00
|
|
|
# sort out the cruft
|
2011-06-23 10:34:39 +00:00
|
|
|
if [ ${CLEAN} -eq 1 ]; 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-23 16:25:15 +00:00
|
|
|
cd "${START_DIR_DONT_CHANGE}" || exit 1
|
2011-06-22 14:43:06 +00:00
|
|
|
rm -f ${RES}
|
2011-06-23 14:48:36 +00:00
|
|
|
printf "$0: removed %s\n" ${RES}
|
2011-06-22 14:43:06 +00:00
|
|
|
else
|
2011-06-23 14:48:36 +00:00
|
|
|
printf "$0: left %s\n" ${RES}
|
2011-06-22 14:43:06 +00:00
|
|
|
fi
|
2011-06-23 11:14:41 +00:00
|
|
|
|
|
|
|
# last hints
|
2011-06-23 14:48:36 +00:00
|
|
|
printf "\n$0: 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"
|
2011-06-23 16:09:47 +00:00
|
|
|
printf " * xorriso -indev ${IMG}.iso -pvd_info\n"
|
2011-06-23 14:48:36 +00:00
|
|
|
printf " * fdisk -lu ${IMG}.iso\n"
|
2011-06-23 11:14:41 +00:00
|
|
|
|
2011-06-23 10:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
main
|