nilmbuntu/buildiso.sh
2013-08-19 17:31:43 -04:00

58 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# build the iso
. config || exit 0
set -x
set -e
if ! [ "$1" == "skip" ] ; then
# copy kernel if changed
if [ ${FS}/initrd.img -nt ${ISO}/casper/initrd.lz ] ; then
sudo cp ${FS}/vmlinuz ${ISO}/casper/vmlinuz
sudo sh -c "zcat ${FS}/initrd.img | lzma > ${ISO}/casper/initrd.lz"
fi
# manifests
sudo chmod +w ${ISO}/casper/filesystem.manifest
sudo chroot ${FS} dpkg-query -W --showformat='${Package} ${Version}\n' \
| sudo tee ${ISO}/casper/filesystem.manifest >/dev/null
# squashfs
sudo rm -f ${ISO}/casper/filesystem.squashfs
sudo mksquashfs ${FS} ${ISO}/casper/filesystem.squashfs
printf $(sudo du -sx --block-size=1 ${FS} | cut -f1) \
| sudo tee ${ISO}/casper/filesystem.size
fi
# md5sums
sudo rm -f md5sum.txt
sudo find ${ISO} -type f -print0 \
| sudo xargs -0 md5sum \
| sed -e "s, ${ISO}, .," \
| grep -v isolinux/boot.cat \
| grep -v isolinux/isolinux.bin \
| grep -v md5sum.txt \
| sudo tee ${ISO}/md5sum.txt >/dev/null
sudo chown -R ${USER} ${ISO}
# build CD
xorriso -as mkisofs \
-D -r -V "NilmDBuntu ${VERSION}" -cache-inodes -J -l \
-input-charset utf-8 -o ${OUTPUT} \
-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 \
${ISO}
# fix iso for hybrid booting
isohybrid ${OUTPUT}
set +x
echo "Burn it with:"
echo " growisofs -dvd-compat -Z /dev/dvd=${OUTPUT}"
echo "or write directly to a USB key"