#! /bin/sh -x

# This script requires your OS' standard genisoimage package (for mkzftree)
# and a very recent version of mkisofs (provided here).  Your OS' standard
# mkisofs will almost certainly not suffice to make an EFI-bootable CD.

export PATH=/bin:/usr/bin

tar -cf - isff_cd | tar -C /tmp -xf -
rm -f /tmp/isff_cd/install.img
mkzftree -F /srv/releases/nuc32-4.6.1.img /tmp/isff_cd/install.img
dd if=/srv/releases/nuc32-4.6.1.img of=/tmp/isff_cd/boot/isffupgr.img \
	bs=1048576 count=24 status=noxfer
#$(readlink -f $PWD)/mkisofs -o /tmp/tlxos_nuc32_installer-4.6.1.iso -r \
#	-A 'ThinLinX Pty Ltd' -V 'NUC32_461' -hide-rr-moved -z -b \
#	/boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
#	-boot-info-table -c boot.cat -eltorito-platform 0xEF -eltorito-boot \
#	/boot/isffupgr.img -no-emul-boot /tmp/isff_cd
#$(readlink -f $PWD)/isohybrid -u /tmp/tlxos_nuc32_installer-4.6.1.iso
#xorrisofs -o /tmp/tlxos_nuc32_installer-4.6.1.iso \
#	-r -hide-rr-moved -p 'ThinLinX Pty Ltd' -V 'NUC32_461' -z -b \
#	boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
#	-boot-info-table -c boot.cat --boot-catalog-hide \
#	-eltorito-alt-boot -e boot/isffupgr.img -no-emul-boot \
#	-isohybrid-mbr $(readlink -f $PWD)/isohdpfx.bin -isohybrid-gpt-basdat \
#	/tmp/isff_cd
xorrisofs -o /tmp/tlxos_nuc32_installer-4.6.1.iso \
	-r -hide-rr-moved -p 'ThinLinX Pty Ltd' -V 'NUC32_461' -z \
	-e boot/isffupgr.img -no-emul-boot \
	-isohybrid-mbr $(readlink -f $PWD)/isohdpfx.bin -isohybrid-gpt-basdat \
	/tmp/isff_cd
#	--efi-boot boot/isffupgr.img -no-emul-boot \
#	-efi-boot-part --efi-boot-image /tmp/isff_cd
#rm -r /tmp/isff_cd
