2011-06-22 14:43:06 +00:00
|
|
|
#!/bin/bash
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-07-11 09:40:23 +00:00
|
|
|
# Copyright 2011 Thomas Schmitt <scdbackup@gmx.net>
|
|
|
|
# Copyright 2011 George Danchev <danchev@spnet.net>
|
2011-07-15 06:05:57 +00:00
|
|
|
# Licensed under GNU GPL version 2 or later
|
2011-07-11 09:40:23 +00:00
|
|
|
|
2011-06-22 13:33:10 +00:00
|
|
|
set -e
|
|
|
|
|
2011-07-13 11:24:32 +00:00
|
|
|
not_in_releng_exit() {
|
|
|
|
printf "\nPlease execute the tests from releng directory.\n\n"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
. inc/releng_getopts.inc || not_in_releng_exit
|
2011-07-08 13:05:21 +00:00
|
|
|
|
2011-07-20 12:23:40 +00:00
|
|
|
print_specific_help() {
|
|
|
|
cat << HLP
|
|
|
|
Specific options:
|
|
|
|
none yet.
|
|
|
|
Overview:
|
|
|
|
Match the resulting ISO image representation
|
|
|
|
against the jigdo representation.
|
|
|
|
HLP
|
|
|
|
}
|
2011-07-18 17:22:59 +00:00
|
|
|
|
|
|
|
if test "$SPECIFIC_HELP" = 1; then
|
2011-07-20 12:23:40 +00:00
|
|
|
print_specific_help
|
2011-07-18 17:22:59 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-07-08 13:05:21 +00:00
|
|
|
if [ ! -x $RELENG_XORRISO ]; then
|
|
|
|
print_help
|
|
|
|
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 30
|
2011-07-08 13:05:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check data dir, if any and after checking -x xorriso
|
|
|
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
|
|
|
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
2011-08-29 12:48:48 +00:00
|
|
|
printf "\n${SELF}: use './${SELF} -c' to remove.\n"
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 1
|
2011-07-08 13:05:21 +00:00
|
|
|
else
|
|
|
|
mkdir "${GEN_DATA_DIR}"
|
|
|
|
fi
|
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
TMP_DATA_DIR=releng_generated_data
|
2011-07-03 14:25:08 +00:00
|
|
|
IMG_EXTRACT_DIR=${GEN_DATA_DIR}/${SELF}_extracted_tree
|
2011-07-03 07:46:21 +00:00
|
|
|
RELENG_DIR="${IMG_EXTRACT_DIR}"
|
2011-07-03 08:23:49 +00:00
|
|
|
RELENG_ISOLINUX_BIN="isolinux/isolinux.bin"
|
2011-07-03 07:46:21 +00:00
|
|
|
RELENG_BOOT_CAT="isolinux/boot.cat"
|
2011-07-03 18:54:48 +00:00
|
|
|
RELENG_IMG=t1
|
2011-06-26 23:44:51 +00:00
|
|
|
RES=""
|
2012-07-14 15:38:27 +00:00
|
|
|
REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/i386/iso-cd"
|
2011-07-03 07:46:21 +00:00
|
|
|
REMOTE_IMG="debian-testing-i386-businesscard.iso"
|
|
|
|
|
2011-07-09 08:23:58 +00:00
|
|
|
# check for required items
|
2011-08-10 09:16:03 +00:00
|
|
|
if [ "${RELENG_XORRISO}" = "" -o "${RELENG_DIR}" = "" -o "${RELENG_IMG}" = "" ]; then
|
2011-07-03 15:07:36 +00:00
|
|
|
echo -e "\n${SELF}: xorriso_cmd IN_dir and OUT_image are required\n"
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 2
|
2011-07-03 15:07:36 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-03 18:31:10 +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-07-09 09:49:10 +00:00
|
|
|
# "${RELENG_XORRISO}" -version
|
2011-06-24 12:53:07 +00:00
|
|
|
|
2011-07-09 08:23:58 +00:00
|
|
|
# check whether the binary support JTE
|
|
|
|
set +e
|
2011-08-10 09:16:03 +00:00
|
|
|
RETSTR_VER_JTE=`"${RELENG_XORRISO}" --version 2>/dev/null | grep "libjte * in use"`
|
2011-07-09 08:23:58 +00:00
|
|
|
RETCODE_VER_JTE="$?"
|
|
|
|
set -e
|
|
|
|
case ${RETCODE_VER_JTE} in
|
|
|
|
0)
|
|
|
|
printf "\n${SELF}: Found JTE support with ${RELENG_XORRISO} : ${RETSTR_VER_JTE}"
|
|
|
|
;;
|
|
|
|
*)
|
2011-08-05 15:43:58 +00:00
|
|
|
printf "\nFAIL : ${SELF} : Not found JTE support in ${RELENG_XORRISO}. Quit."
|
2011-07-09 09:49:10 +00:00
|
|
|
printf "\n${SELF}: JTE not supported with this xorriso build. Install jigit >=1.18 and rebuild."
|
|
|
|
printf "\n${SELF}: http://www.einval.com/~steve/software/JTE/\n"
|
|
|
|
cleanup
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 4
|
|
|
|
;;
|
|
|
|
esac
|
2011-06-22 13:33:10 +00:00
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
# grab remote ISO image, to decompose
|
|
|
|
if [ ! -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
|
|
|
|
printf "\n${SELF}: Downloading ${REMOTE_URL}/${REMOTE_IMG}\n"
|
2011-08-10 09:16:03 +00:00
|
|
|
if wget -V >/dev/null 2>&1
|
|
|
|
then
|
2011-08-29 12:48:48 +00:00
|
|
|
set +e
|
2011-08-10 09:16:03 +00:00
|
|
|
wget --no-check-certificate -T20 -t3 \
|
|
|
|
-O "${TMP_DATA_DIR}"/"${REMOTE_IMG}" "${REMOTE_URL}"/"${REMOTE_IMG}"
|
|
|
|
WGET_RET="$?"
|
2011-08-29 12:48:48 +00:00
|
|
|
set -e
|
2011-08-10 09:16:03 +00:00
|
|
|
elif fetch -T 20 -o "${TMP_DATA_DIR}"/"${REMOTE_IMG}" \
|
|
|
|
"${REMOTE_URL}"/"${REMOTE_IMG}"
|
|
|
|
then
|
|
|
|
WGET_RET=0
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "FAIL: ${SELF} : Neither wget nor fetch are present and willing to work"
|
|
|
|
cleanup
|
|
|
|
exit 10
|
|
|
|
fi
|
2011-07-03 07:46:21 +00:00
|
|
|
case ${WGET_RET} in
|
|
|
|
0)
|
|
|
|
echo -e "\n${SELF}: Downloading successfully completed.\n"
|
|
|
|
;;
|
|
|
|
*)
|
2011-08-05 15:43:58 +00:00
|
|
|
echo -e "\nFAIL : ${SELF} : wget returned code: $WGET_RET\n"
|
2011-08-29 12:48:48 +00:00
|
|
|
rm "${TMP_DATA_DIR}"/"${REMOTE_IMG}"
|
2011-07-03 18:31:10 +00:00
|
|
|
cleanup
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 5
|
2011-07-03 07:46:21 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
2011-07-03 10:11:23 +00:00
|
|
|
printf "\n${SELF}: Found ISO image: ${TMP_DATA_DIR}/${REMOTE_IMG}\n"
|
2011-07-03 07:46:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check for extraction directory existence
|
2011-07-03 09:04:09 +00:00
|
|
|
if [ -d "${IMG_EXTRACT_DIR}" ]; then
|
|
|
|
printf "\n${SELF}: Found ${IMG_EXTRACT_DIR}. Please cleanup.\n"
|
2011-07-03 18:31:10 +00:00
|
|
|
cleanup
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 6
|
2011-07-03 09:04:09 +00:00
|
|
|
else
|
2011-07-03 07:46:21 +00:00
|
|
|
mkdir "${IMG_EXTRACT_DIR}"
|
|
|
|
fi
|
2011-07-03 09:04:09 +00:00
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
# extract image content
|
2011-07-03 10:11:23 +00:00
|
|
|
CMD_EXTRACT="${RELENG_XORRISO} -indev ${TMP_DATA_DIR}/${REMOTE_IMG} \
|
2011-07-03 07:46:21 +00:00
|
|
|
-osirrox on:auto_chmod_on \
|
2011-07-03 10:11:23 +00:00
|
|
|
-extract / ${IMG_EXTRACT_DIR} \
|
|
|
|
"
|
2011-07-03 20:05:05 +00:00
|
|
|
|
|
|
|
# TODO: drop set +e|-e block, catch exit code instead when
|
|
|
|
# the boot catalog warnings get completely resolved.
|
2011-07-03 10:11:23 +00:00
|
|
|
echo -e "${SELF}: Extracting ISO image:\n${CMD_EXTRACT}\n"
|
|
|
|
set +e
|
|
|
|
${CMD_EXTRACT}
|
2011-07-03 07:46:21 +00:00
|
|
|
set -e
|
|
|
|
|
2011-06-22 20:32:09 +00:00
|
|
|
# grab an MBR
|
2011-07-03 08:57:30 +00:00
|
|
|
ISOHYBRID_MBR="${GEN_DATA_DIR}/isohybrid.mbr"
|
2011-07-03 07:46:21 +00:00
|
|
|
dd if="${TMP_DATA_DIR}/${REMOTE_IMG}" bs=1K count=32 of="${ISOHYBRID_MBR}"
|
2011-06-22 20:32:09 +00:00
|
|
|
|
2011-06-22 20:20:00 +00:00
|
|
|
# create FAT partition
|
2011-07-03 08:57:30 +00:00
|
|
|
APPEND_PART="${GEN_DATA_DIR}/fatpart.fat"
|
2011-07-03 17:07:56 +00:00
|
|
|
MKFS_MSDOS="/sbin/mkfs.msdos"
|
|
|
|
if [ -x "${MKFS_MSDOS}" ]; then
|
|
|
|
"${MKFS_MSDOS}" -n Bla -C "${APPEND_PART}" 8192
|
2011-08-10 09:16:03 +00:00
|
|
|
APPEND_PART_CMD="-append_partition 2 0x01 ${APPEND_PART}"
|
2011-07-03 17:07:56 +00:00
|
|
|
else
|
2011-08-10 09:16:03 +00:00
|
|
|
APPEND_PART_CMD=
|
|
|
|
|
|
|
|
# printf "\nFAIL : ${SELF} : Not found: ${MKFS_MSDOS}"
|
|
|
|
# printf "\n${SELF}: Not found: "${MKFS_MSDOS}". Install dosfstools."
|
|
|
|
# printf "\n${SELF}: http://www.daniel-baumann.ch/software/dosfstools/\n"
|
|
|
|
# cleanup
|
|
|
|
# exit 7
|
2011-07-03 17:07:56 +00:00
|
|
|
fi
|
2011-06-22 20:20:00 +00:00
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
# 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-07-03 07:46:21 +00:00
|
|
|
# BOOT section
|
2011-08-10 09:16:03 +00:00
|
|
|
if [ -f "${IMG_EXTRACT_DIR}"/"${RELENG_ISOLINUX_BIN}" -a -f "${ISOHYBRID_MBR}" ]
|
|
|
|
then
|
|
|
|
CMD="$CMD \
|
2011-07-03 07:46:21 +00:00
|
|
|
-b ${RELENG_ISOLINUX_BIN} \
|
|
|
|
-c ${RELENG_BOOT_CAT} \
|
|
|
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
|
|
|
-isohybrid-mbr ${ISOHYBRID_MBR} \
|
|
|
|
-partition_offset 16 \
|
|
|
|
"
|
2011-07-03 07:52:17 +00:00
|
|
|
else
|
|
|
|
printf "\n${SELF}: FAIL to compose the boot section.\n"
|
2011-07-03 18:31:10 +00:00
|
|
|
cleanup
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 8
|
2011-07-03 07:46:21 +00:00
|
|
|
fi
|
2011-08-10 09:16:03 +00:00
|
|
|
if [ -n "${APPEND_PART_CMD}" -a -f "${APPEND_PART}" ]; then
|
|
|
|
CMD="$CMD \
|
|
|
|
${APPEND_PART_CMD}
|
|
|
|
"
|
|
|
|
fi
|
2011-07-03 07:46:21 +00:00
|
|
|
|
|
|
|
# JIGDO section
|
2011-07-03 08:57:30 +00:00
|
|
|
JIGDO_JIGDO=${GEN_DATA_DIR}/${RELENG_IMG}.jigdo
|
|
|
|
JIGDO_TEMPLATE=${GEN_DATA_DIR}/${RELENG_IMG}.template
|
2011-08-10 09:16:03 +00:00
|
|
|
|
|
|
|
JIGDO_MAP_RHV=$(cd ${RELENG_DIR} 2>/dev/null && pwd)
|
|
|
|
|
2011-07-03 16:45:16 +00:00
|
|
|
JIGDO_MAP="Debian=${JIGDO_MAP_RHV}/"
|
2011-07-03 07:46:21 +00:00
|
|
|
|
|
|
|
# create jigdo MD5 list in base64 format
|
2011-07-03 08:57:30 +00:00
|
|
|
JIGDO_GEN_MD5=${GEN_DATA_DIR}/${RELENG_IMG}.md5
|
2011-08-29 17:43:15 +00:00
|
|
|
|
|
|
|
printf "${SELF}: Creating MD5 list in hex format in ${JIGDO_GEN_MD5}..."
|
|
|
|
set +e
|
|
|
|
./jigdo-gen-md5-list ${RELENG_DIR} > ${JIGDO_GEN_MD5}
|
|
|
|
ret=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if test "$ret" = 0
|
|
|
|
then
|
|
|
|
printf "Done.\n"
|
2011-07-03 07:46:21 +00:00
|
|
|
else
|
2011-08-29 17:43:15 +00:00
|
|
|
printf "\nFAIL : ${SELF}: ./jigdo-gen-md5-list returns $ret"
|
|
|
|
cleanup
|
|
|
|
exit 9
|
2011-07-03 07:46:21 +00:00
|
|
|
fi
|
2011-08-29 17:43:15 +00:00
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
|
2011-08-10 09:16:03 +00:00
|
|
|
CMD="$CMD \
|
2011-06-22 20:20:00 +00:00
|
|
|
-jigdo-template-compress gzip \
|
|
|
|
-checksum_algorithm_iso md5,sha1,sha256,sha512 \
|
|
|
|
-checksum_algorithm_template md5,sha1,sha256,sha512 \
|
2011-07-03 07:46:21 +00:00
|
|
|
-jigdo-jigdo ${JIGDO_JIGDO} \
|
|
|
|
-jigdo-template ${JIGDO_TEMPLATE} \
|
|
|
|
-jigdo-map ${JIGDO_MAP} \
|
|
|
|
-md5-list ${JIGDO_GEN_MD5} \
|
2011-06-22 20:20:00 +00:00
|
|
|
-jigdo-min-file-size 1024 \
|
|
|
|
"
|
|
|
|
|
2011-08-10 09:16:03 +00:00
|
|
|
CMD="$CMD ${RELENG_DIR}"
|
2011-06-22 20:20:00 +00:00
|
|
|
|
2011-07-03 07:46:21 +00:00
|
|
|
# Run the whole compound command
|
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-07-03 07:46:21 +00:00
|
|
|
# Create another imange this time 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-07-03 07:46:21 +00:00
|
|
|
-t ${JIGDO_TEMPLATE} \
|
|
|
|
-j ${JIGDO_JIGDO} \
|
|
|
|
-m ${JIGDO_MAP} \
|
2011-06-28 16:20:31 +00:00
|
|
|
-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."
|
2011-07-03 18:41:13 +00:00
|
|
|
printf "\n${SELF}: http://www.einval.com/~steve/software/JTE/\n"
|
2011-07-03 18:31:10 +00:00
|
|
|
cleanup
|
2011-07-09 08:23:58 +00:00
|
|
|
exit 10
|
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-07-03 18:54:48 +00:00
|
|
|
echo -e "${SELF}: Match: diff ${GEN_DATA_DIR}/${RELENG_IMG}.iso ${GEN_DATA_DIR}/${RELENG_IMG}.new"
|
2011-06-23 16:09:47 +00:00
|
|
|
;;
|
|
|
|
*)
|
2011-08-05 15:43:58 +00:00
|
|
|
echo -e "FAIL : ${SELF} : 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-07-03 18:31:10 +00:00
|
|
|
cleanup
|
2011-06-23 11:14:41 +00:00
|
|
|
|
2011-07-03 19:11:13 +00:00
|
|
|
# warn about downloaded image left behind
|
|
|
|
if [ -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
|
|
|
|
printf "${SELF}: Leaving "
|
|
|
|
ls -sh "${TMP_DATA_DIR}"/"${REMOTE_IMG}"
|
|
|
|
fi
|
|
|
|
|
2011-06-23 11:14:41 +00:00
|
|
|
# last hints
|
2011-07-24 14:56:36 +00:00
|
|
|
if [ -d ${GEN_DATA_DIR} ]; then
|
|
|
|
printf "\n${SELF}: HINT: manual checks remained to be done:\n"
|
|
|
|
printf " * ${GEN_DATA_DIR}/${RELENG_IMG}.iso boots from USB stick and/or optical media.\n"
|
|
|
|
printf " * appended FAT partition is mountable.\n"
|
|
|
|
printf " * xorriso -indev ${GEN_DATA_DIR}/${RELENG_IMG}.iso -pvd_info\n"
|
|
|
|
printf " * fdisk -lu ${GEN_DATA_DIR}/${RELENG_IMG}.iso\n"
|
|
|
|
fi
|
2011-06-23 11:14:41 +00:00
|
|
|
|
2011-06-25 16:58:16 +00:00
|
|
|
exit 0
|