From bfc1796c26370b6c669ae187d5fb4829eeb2399b Mon Sep 17 00:00:00 2001 From: George Danchev Date: Sun, 3 Jul 2011 07:46:21 +0000 Subject: [PATCH] moving to decomposition of existing image, and re-using its contents --- libisoburn/trunk/releng/releng_isojigdo | 148 ++++++++++++++---------- 1 file changed, 89 insertions(+), 59 deletions(-) diff --git a/libisoburn/trunk/releng/releng_isojigdo b/libisoburn/trunk/releng/releng_isojigdo index ec0c902e..c9970231 100755 --- a/libisoburn/trunk/releng/releng_isojigdo +++ b/libisoburn/trunk/releng/releng_isojigdo @@ -4,18 +4,27 @@ set -e START_DIR_DONT_CHANGE=`pwd` SELF=$(basename "$0") + # required config items -RELENG_XORRISO="" -RELENG_DIR="" -RELENG_IMG="" -# optional config items -RELENG_ISOLINUX_BIN="" -RELENG_BOOT_CAT="" CONFFILE=$HOME/.libburnia-releng/${SELF}.conf GEN_DATA_DIR=releng_generated_data/${SELF} +TMP_DATA_DIR=releng_generated_data +IMG_EXTRACT_DIR=${TMP_DATA_DIR}/${SELF}_extracted_tree + +# to be set by the config file +RELENG_XORRISO="" + +RELENG_DIR="${IMG_EXTRACT_DIR}" +RELENG_ISOLINUX_BIN="${IMG_EXTRACT_DIR}/isolinux/isolinux.bin" +RELENG_BOOT_CAT="isolinux/boot.cat" +RELENG_IMG=cimage + KEEP=0 RES="" +REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/current/i386/iso-cd" +REMOTE_IMG="debian-testing-i386-businesscard.iso" + print_help() { cat << HLP Usage: @@ -24,9 +33,6 @@ Usage: # using a config file ${CONFFILE} ${SELF} -rc [-keep] -# without using a config file - ${SELF} xorriso_cmd IN_dir OUT_image [IN_isolinux] [OUT_bootcat] [-keep] - # cleanup test generated data directory and exit ${SELF} -cleanup HLP @@ -56,16 +62,6 @@ if [ "${1}" == "-rc" ]; then echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4 fi if [ "${2}" == "-keep" ]; then KEEP=1; fi -# command line args -elif [ "${3}" ]; then - RELENG_XORRISO="${1}" - RELENG_DIR="${2}" - RELENG_IMG="${3}" - if [ "${4}" ]; then - RELENG_ISOLINUX_BIN="${4}" - if [ "${5}" ]; then RELENG_BOOT_CAT="${5}"; fi - if [ "${4}" == "-keep" -o "${5}" == "-keep" -o "${6}" == "-keep" ]; then KEEP=1; fi - fi # the rest else print_help && exit 5 @@ -90,11 +86,6 @@ if [ ! -x "${RELENG_XORRISO}" ]; then exit 8 fi -if [ ! -d "${RELENG_DIR}" ]; then - printf "${SELF}: $RELENG_DIR does not exist or not a directory.\n" - exit 9 -fi - # all must be set at this point printf "${SELF}: Config items:" printf "\n\txorriso_cmd=${RELENG_XORRISO}\n\tIN_dir=${RELENG_DIR}\n\tOUT_image=${RELENG_IMG}.iso" @@ -112,24 +103,45 @@ fi # remove cruft from previous runs # rm -f ${RES} -# grab an MBR -# dd if=some.iso bs=1K count=32 of=somembr.sysarea - -# create FAT partition -# /sbin/mkfs.msdos -n Bla -C fatpart.fat 8192 - -# create MD5 list in base64 format -if which jigdo-gen-md5-list >/dev/null 2>&1; then - printf "${SELF}: Creating MD5 list in hex format..." - jigdo-gen-md5-list ${RELENG_DIR} > ${GEN_DATA_DIR}/${RELENG_IMG}.md5 - printf "Done.\n" +# grab remote ISO image, to decompose +if [ ! -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then + printf "\n${SELF}: Downloading ${REMOTE_URL}/${REMOTE_IMG}\n" + wget --no-check-certificate -T20 -t3 -O \ + "${TMP_DATA_DIR}"/"${REMOTE_IMG}" "${REMOTE_URL}"/"${REMOTE_IMG}" + WGET_RET="$?" + case ${WGET_RET} in + 0) + echo -e "\n${SELF}: Downloading successfully completed.\n" + ;; + *) + echo -e "\n${SELF}: FAIL: wget returned code: $WGET_RET\n" + exit 10 + ;; + esac else - printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit." - printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" - exit 11 + printf "\n${SELF}: Found image: ${GEN_DATA_DIR}/${REMOTE_IMG}\n" fi -# build the command - general section +# check for extraction directory existence +if [ ! -d "${IMG_EXTRACT_DIR}" ]; then + mkdir "${IMG_EXTRACT_DIR}" +fi +# extract image content +set +e +"${RELENG_XORRISO}" -indev "${TMP_DATA_DIR}"/"${REMOTE_IMG}" \ + -osirrox on:auto_chmod_on \ + -extract / "${IMG_EXTRACT_DIR}" +set -e + +# grab an MBR +ISOHYBRID_MBR="${TMP_DATA_DIR}/isohybrid.mbr" +dd if="${TMP_DATA_DIR}/${REMOTE_IMG}" bs=1K count=32 of="${ISOHYBRID_MBR}" + +# create FAT partition +APPEND_PART="${TMP_DATA_DIR}/fatpart.fat" +/sbin/mkfs.msdos -n Bla -C "${APPEND_PART}" 8192 + +# GENERAL section CMD="${RELENG_XORRISO} \ -as mkisofs \ -quiet \ @@ -140,42 +152,60 @@ CMD="${RELENG_XORRISO} \ -J -joliet-long \ " -# boot section TODO -#if [ "${RELENG_ISOLINUX_BIN}" -a "${RELENG_BOOT_CAT}" ]; then -#CMD+=\ -# -b ${RELENG_ISOLINUX_BIN} \ # NOTE: boot/isolinux/isolinux.bin -# -c ${RELENG_BOOT_CAT} \ # NOTE: boot/boot.cat -# -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 \ # TODO: create one unconditionally? -#fi +# BOOT section +if [ -f "${RELENG_ISOLINUX_BIN}" ]; then +CMD+="\ + -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 \ + -append_partition 2 0x01 ${APPEND_PART} \ +" +fi + +# JIGDO section +JIGDO_JIGDO=${TMP_DATA_DIR}/${RELENG_IMG}.jigdo +JIGDO_TEMPLATE=${TMP_DATA_DIR}/${RELENG_IMG}.template +JIGDO_MAP_RHV=`realpath ${RELENG_DIR}` +JIGDO_MAP="Debian=${JIGDO_MAP_RHV}" + +# create jigdo MD5 list in base64 format +JIGDO_GEN_MD5=${TMP_DATA_DIR}/${RELENG_IMG}.md5 +if which jigdo-gen-md5-list >/dev/null 2>&1; then + printf "${SELF}: Creating MD5 list in hex format in ${JIGDO_GEN_MD5}\n" + jigdo-gen-md5-list ${RELENG_DIR} > ${JIGDO_GEN_MD5} + printf "Done.\n" +else + printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit." + printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n" + exit 11 +fi -# jigdo section CMD+="\ -jigdo-template-compress gzip \ -checksum_algorithm_iso md5,sha1,sha256,sha512 \ -checksum_algorithm_template md5,sha1,sha256,sha512 \ - -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 \ + -jigdo-jigdo ${JIGDO_JIGDO} \ + -jigdo-template ${JIGDO_TEMPLATE} \ + -jigdo-map ${JIGDO_MAP} \ + -md5-list ${JIGDO_GEN_MD5} \ -jigdo-min-file-size 1024 \ " CMD+="${RELENG_DIR}" -# run it +# Run the whole compound command echo -e "${SELF}: Creating ISO and jigdo representations:\n$CMD\n" ${CMD} -# create another one from jigdo files +# Create another imange this time from jigdo files if which jigit-mkimage >/dev/null 2>&1; then printf "${SELF}: Creating new ISO from jigdo files..." jigit-mkimage \ - -t ${GEN_DATA_DIR}/${RELENG_IMG}.template \ - -j ${GEN_DATA_DIR}/${RELENG_IMG}.jigdo \ - -m Debian=${RELENG_DIR} \ + -t ${JIGDO_TEMPLATE} \ + -j ${JIGDO_JIGDO} \ + -m ${JIGDO_MAP} \ -o ${GEN_DATA_DIR}/${RELENG_IMG}.new printf "Done.\n" else