moving to decomposition of existing image, and re-using its contents

This commit is contained in:
George Danchev 2011-07-03 07:46:21 +00:00
parent 5360404f82
commit c7a1e08afb
1 changed files with 89 additions and 59 deletions

View File

@ -4,18 +4,27 @@ set -e
START_DIR_DONT_CHANGE=`pwd` START_DIR_DONT_CHANGE=`pwd`
SELF=$(basename "$0") SELF=$(basename "$0")
# required config items # required config items
RELENG_XORRISO=""
RELENG_DIR=""
RELENG_IMG=""
# optional config items
RELENG_ISOLINUX_BIN=""
RELENG_BOOT_CAT=""
CONFFILE=$HOME/.libburnia-releng/${SELF}.conf CONFFILE=$HOME/.libburnia-releng/${SELF}.conf
GEN_DATA_DIR=releng_generated_data/${SELF} 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 KEEP=0
RES="" RES=""
REMOTE_URL="http://cdimage.debian.org/cdimage/daily-builds/daily/current/i386/iso-cd"
REMOTE_IMG="debian-testing-i386-businesscard.iso"
print_help() { print_help() {
cat << HLP cat << HLP
Usage: Usage:
@ -24,9 +33,6 @@ Usage:
# using a config file ${CONFFILE} # using a config file ${CONFFILE}
${SELF} -rc [-keep] ${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 # cleanup test generated data directory and exit
${SELF} -cleanup ${SELF} -cleanup
HLP HLP
@ -56,16 +62,6 @@ if [ "${1}" == "-rc" ]; then
echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4 echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4
fi fi
if [ "${2}" == "-keep" ]; then KEEP=1; 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 # the rest
else else
print_help && exit 5 print_help && exit 5
@ -90,11 +86,6 @@ if [ ! -x "${RELENG_XORRISO}" ]; then
exit 8 exit 8
fi 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 # all must be set at this point
printf "${SELF}: Config items:" printf "${SELF}: Config items:"
printf "\n\txorriso_cmd=${RELENG_XORRISO}\n\tIN_dir=${RELENG_DIR}\n\tOUT_image=${RELENG_IMG}.iso" 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 # remove cruft from previous runs
# rm -f ${RES} # rm -f ${RES}
# grab an MBR # grab remote ISO image, to decompose
# dd if=some.iso bs=1K count=32 of=somembr.sysarea if [ ! -f "${TMP_DATA_DIR}"/"${REMOTE_IMG}" ]; then
printf "\n${SELF}: Downloading ${REMOTE_URL}/${REMOTE_IMG}\n"
# create FAT partition wget --no-check-certificate -T20 -t3 -O \
# /sbin/mkfs.msdos -n Bla -C fatpart.fat 8192 "${TMP_DATA_DIR}"/"${REMOTE_IMG}" "${REMOTE_URL}"/"${REMOTE_IMG}"
WGET_RET="$?"
# create MD5 list in base64 format case ${WGET_RET} in
if which jigdo-gen-md5-list >/dev/null 2>&1; then 0)
printf "${SELF}: Creating MD5 list in hex format..." echo -e "\n${SELF}: Downloading successfully completed.\n"
jigdo-gen-md5-list ${RELENG_DIR} > ${GEN_DATA_DIR}/${RELENG_IMG}.md5 ;;
printf "Done.\n" *)
echo -e "\n${SELF}: FAIL: wget returned code: $WGET_RET\n"
exit 10
;;
esac
else else
printf "\n${SELF}: Not found: jigdo-gen-md5-list. Install jigit." printf "\n${SELF}: Found image: ${GEN_DATA_DIR}/${REMOTE_IMG}\n"
printf "\n${SELF}: See http://www.einval.com/~steve/software/JTE/\n"
exit 11
fi 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} \ CMD="${RELENG_XORRISO} \
-as mkisofs \ -as mkisofs \
-quiet \ -quiet \
@ -140,42 +152,60 @@ CMD="${RELENG_XORRISO} \
-J -joliet-long \ -J -joliet-long \
" "
# boot section TODO # BOOT section
#if [ "${RELENG_ISOLINUX_BIN}" -a "${RELENG_BOOT_CAT}" ]; then if [ -f "${RELENG_ISOLINUX_BIN}" ]; then
#CMD+=\ CMD+="\
# -b ${RELENG_ISOLINUX_BIN} \ # NOTE: boot/isolinux/isolinux.bin -b ${RELENG_ISOLINUX_BIN} \
# -c ${RELENG_BOOT_CAT} \ # NOTE: boot/boot.cat -c ${RELENG_BOOT_CAT} \
# -no-emul-boot -boot-load-size 4 -boot-info-table \ -no-emul-boot -boot-load-size 4 -boot-info-table \
# -isohybrid-mbr somembr.sysarea \ # TODO: figure out where to grab one -isohybrid-mbr ${ISOHYBRID_MBR} \
# -partition_offset 16 \ -partition_offset 16 \
# -append_partition 2 0x01 fatpart.fat \ # TODO: create one unconditionally? -append_partition 2 0x01 ${APPEND_PART} \
#fi "
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+="\ CMD+="\
-jigdo-template-compress gzip \ -jigdo-template-compress gzip \
-checksum_algorithm_iso md5,sha1,sha256,sha512 \ -checksum_algorithm_iso md5,sha1,sha256,sha512 \
-checksum_algorithm_template md5,sha1,sha256,sha512 \ -checksum_algorithm_template md5,sha1,sha256,sha512 \
-jigdo-jigdo ${GEN_DATA_DIR}/${RELENG_IMG}.jigdo \ -jigdo-jigdo ${JIGDO_JIGDO} \
-jigdo-template ${GEN_DATA_DIR}/${RELENG_IMG}.template \ -jigdo-template ${JIGDO_TEMPLATE} \
-jigdo-map Debian=${RELENG_DIR} \ -jigdo-map ${JIGDO_MAP} \
-md5-list ${GEN_DATA_DIR}/${RELENG_IMG}.md5 \ -md5-list ${JIGDO_GEN_MD5} \
-jigdo-min-file-size 1024 \ -jigdo-min-file-size 1024 \
" "
CMD+="${RELENG_DIR}" CMD+="${RELENG_DIR}"
# run it # Run the whole compound command
echo -e "${SELF}: 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 imange this time from jigdo files
if which jigit-mkimage >/dev/null 2>&1; then if which jigit-mkimage >/dev/null 2>&1; then
printf "${SELF}: Creating new ISO from jigdo files..." printf "${SELF}: Creating new ISO from jigdo files..."
jigit-mkimage \ jigit-mkimage \
-t ${GEN_DATA_DIR}/${RELENG_IMG}.template \ -t ${JIGDO_TEMPLATE} \
-j ${GEN_DATA_DIR}/${RELENG_IMG}.jigdo \ -j ${JIGDO_JIGDO} \
-m Debian=${RELENG_DIR} \ -m ${JIGDO_MAP} \
-o ${GEN_DATA_DIR}/${RELENG_IMG}.new -o ${GEN_DATA_DIR}/${RELENG_IMG}.new
printf "Done.\n" printf "Done.\n"
else else