nilmbuntu/buildiso.sh

82 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2013-08-17 22:28:49 -04:00
#!/bin/bash
2016-06-27 16:55:40 -04:00
# Build the iso.
# Some parts of this (particularly the xorriso command lines) come from
# the ubuntu-cdimage project:
# http://bazaar.launchpad.net/~ubuntu-cdimage/debian-cd/ubuntu/
2016-06-26 02:41:38 -04:00
# make sure this was run as root
if [ $UID -ne 0 ] ; then
echo "Need to be root; trying sudo"
exec sudo env BUILD_CONFIG=$BUILD_CONFIG $0 "$@"
fi
2013-08-17 22:28:49 -04:00
. config || exit 0
set -x
set -e
2016-06-27 16:16:18 -04:00
INITRD=${FS}/initrd.img
VMLINUZ=$(readlink -f ${FS}/vmlinuz)
VMLINUZ_EFI=${VMLINUZ}.efi.signed
2013-08-19 11:58:48 -04:00
2016-06-27 16:16:18 -04:00
if ! [ "$1" == "justiso" ] ; then
if ! [ -r ${INITRD} -a -r ${VMLINUZ} -a -r ${VMLINUZ_EFI} ] ; then
set +x
2016-06-27 16:55:40 -04:00
echo "== Missing kernel and/or initrd. Either upgrade or reinstall"
echo "== the kernel inside the image to get the right files."
2016-06-27 16:16:18 -04:00
exit 1
fi
# Recompress initrd if changed
if [ ${INITRD} -nt ${ISO}/casper/initrd.lz ] ; then
sh -c "zcat ${INITRD} | lzma > ${ISO}/casper/initrd.lz"
fi
# Get kernel and signed EFI kernel
cp ${VMLINUZ} ${ISO}/casper/vmlinuz
cp ${VMLINUZ_EFI} ${ISO}/casper/vmlinuz.efi
2013-08-17 22:28:49 -04:00
2016-06-27 16:16:18 -04:00
# manifests
chmod +w ${ISO}/casper/filesystem.manifest
chroot ${FS} dpkg-query -W --showformat='${Package} ${Version}\n' \
| tee ${ISO}/casper/filesystem.manifest >/dev/null
2013-08-17 22:28:49 -04:00
2016-06-27 16:16:18 -04:00
# squashfs
rm -f ${ISO}/casper/filesystem.squashfs
mksquashfs ${FS} ${ISO}/casper/filesystem.squashfs
printf $(du -sx --block-size=1 ${FS} | cut -f1) \
| tee ${ISO}/casper/filesystem.size
2013-08-17 22:28:49 -04:00
2013-08-19 11:58:48 -04:00
fi
2013-08-17 22:28:49 -04:00
# md5sums
2016-06-26 02:41:38 -04:00
rm -f md5sum.txt
find ${ISO} -type f -print0 \
| xargs -0 md5sum \
2013-08-19 17:31:43 -04:00
| sed -e "s, ${ISO}, .," \
2013-08-17 22:28:49 -04:00
| grep -v isolinux/boot.cat \
2013-08-19 17:31:43 -04:00
| grep -v isolinux/isolinux.bin \
2013-08-19 14:25:05 -04:00
| grep -v md5sum.txt \
2016-06-26 02:41:38 -04:00
| tee ${ISO}/md5sum.txt >/dev/null
2013-08-17 22:28:49 -04:00
2016-06-26 02:41:38 -04:00
chown -R ${NONPRIV_UID} ${ISO}
2013-08-17 22:28:49 -04:00
# build CD
xorriso -as mkisofs \
2016-06-26 02:41:38 -04:00
-joliet -full-iso9660-filenames \
-rational-rock \
-V "NILMbuntu ${VERSION}" \
-input-charset utf-8 -output ${OUTPUT} \
2013-08-17 22:28:49 -04:00
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
2016-06-26 02:41:38 -04:00
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
${ISO}
2013-08-18 20:53:22 -04:00
2013-08-19 16:09:38 -04:00
set +x
2013-08-19 15:27:25 -04:00
echo "Burn it with:"
echo " growisofs -dvd-compat -Z /dev/dvd=${OUTPUT}"
echo "or write directly to a USB key"