diff --git a/make.iso.preseed.sh b/make.iso.preseed.sh index c5d435a..a31fe4f 100755 --- a/make.iso.preseed.sh +++ b/make.iso.preseed.sh @@ -15,6 +15,7 @@ DEBIAN_ISO_MINI_URL="http://ftp.nl.debian.org/debian/dists/${DEBIAN_VERSION_NAME TEMP_DIR=$(mktemp -d -t new-preseed-debian-iso-XXXXXX.tmp) TEMP_ISO_DIR="${TEMP_DIR}/extracted-iso" +TEMP_INITRD_DIR="${TEMP_DIR}/initrd" DEBIAN_DL_ISO_PATH="${TEMP_DIR}/debian.iso" DEBIAN_PRESEED_ISO_PATH="$(dirname ${TEMP_DIR})/preseed-debian-${DEBIAN_VERSION_NB}-amd64.iso" @@ -85,28 +86,41 @@ command 7z x -o"${TEMP_ISO_DIR}" -- "${DEBIAN_DL_ISO_PATH}" > /dev/null rm -rf -- "${DEBIAN_DL_ISO_PATH}" # }}} # Manage initrd.gz file {{{ +mkdir -- "${TEMP_INITRD_DIR}" ## Exclude initrd.gz files from xen and gtk directories INITRD_GZ_PATH=$(find "${TEMP_ISO_DIR}" -type f \( -path '*xen*' -o -path '*gtk*' \) -prune -o -name "initrd.gz" -print -quit) -## Uncompress initrd.gz -gunzip -- "${INITRD_GZ_PATH}" || exit 1 +## Copy it to a directory +cp -- "${INITRD_GZ_PATH}" "${TEMP_INITRD_DIR}" || exit 2 -## Add preseed file to initrd -INITRD_PATH=$(find "${TEMP_ISO_DIR}" -type f \( -path '*xen*' -o -path '*gtk*' \) -prune -o -name "initrd" -print -quit) +sleep 30 -echo "${PRESEED_FILE}" | cpio --quiet -H newc -o -A -F "${INITRD_PATH}" +cd -- "${TEMP_INITRD_DIR}" > /dev/null || exit 2 +## Uncompress initrd.gz and delete it +gunzip < initrd.gz | cpio --extract --quiet --make-directories --no-absolute-filenames >> /dev/null +rm -f -- initrd.gz -## Recompress to initrd.gz -gzip -- "${INITRD_PATH}" || exit 1 +## Add preseed file +cp -- "${PRESEED_FILE}" preseed.cfg || exit 2 + +sleep 30 + +## Recompress to initrd.gz and move it back to the extracted files for ISO +find . -not -name initrd.gz | cpio --format=newc --create --quiet | gzip --best > initrd.gz +cp -- initrd.gz "${INITRD_GZ_PATH}" || exit 2 + +## Go back to previous directory and remove no longer useful files +cd - > /dev/null || exit 2 +rm -rf -- "${TEMP_INITRD_DIR}" ## Fix permissions in install directory chmod -w -R -- $(dirname -- "${INITRD_GZ_PATH}") # }}} # Generate new md5sum {{{ -cd -- "${TEMP_ISO_DIR}" || exit 2 +cd -- "${TEMP_ISO_DIR}" > /dev/null || exit 2 ## Exclude some unwanted files find . -follow -type f -not \( -name "md5sum.txt" -o -name 'mkisofs' -o -name 'Bootable_NoEmulation.img' -o -path '*isolinux*' \) -exec md5sum {} \; > ./md5sum.txt -cd - || exit 2 +cd - > /dev/null || exit 2 # }}} # Generate new bootable iso {{{ xorriso -as mkisofs -o "${DEBIAN_PRESEED_ISO_PATH}" \