- round up ramdisk_size to nearest kilobyte to avoid kernel memory
contamination if the size of the cpio archives is not a perfect
multiple of 1024!
# Root of the ISO and USB images
overlay=$(mktemp -d /tmp/overlay.XXXXXX)
install -d -m 755 $overlay
# Root of the ISO and USB images
overlay=$(mktemp -d /tmp/overlay.XXXXXX)
install -d -m 755 $overlay
-trap "rm -rf $overlay" ERR
+trap "rm -rf $overlay" ERR INT
# Create version files
echo "* Creating version files"
# Create version files
echo "* Creating version files"
(cd $overlay && find . | cpio --quiet -c -o) | gzip -9 >$isofs/overlay.img
rm -rf $overlay
(cd $overlay && find . | cpio --quiet -c -o) | gzip -9 >$isofs/overlay.img
rm -rf $overlay
# Calculate ramdisk size (total uncompressed size of both archives)
ramdisk_size=$(gzip -l $isofs/bootcd.img $isofs/overlay.img | tail -1 | awk '{ print $2; }') # bytes
# Calculate ramdisk size (total uncompressed size of both archives)
ramdisk_size=$(gzip -l $isofs/bootcd.img $isofs/overlay.img | tail -1 | awk '{ print $2; }') # bytes
-ramdisk_size=$(($ramdisk_size / 1024)) # kilobytes
+ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
# Write isolinux configuration
echo "$FULL_VERSION_STRING" >$isofs/pl_version
# Write isolinux configuration
echo "$FULL_VERSION_STRING" >$isofs/pl_version
# Mount it
tmp=$(mktemp -d /tmp/bootcd.XXXXXX)
mount -o loop "$usb" $tmp
# Mount it
tmp=$(mktemp -d /tmp/bootcd.XXXXXX)
mount -o loop "$usb" $tmp
-trap "umount $tmp; rm -rf $tmp" ERR
+trap "umount $tmp; rm -rf $tmp" ERR INT
# Populate it
echo "* Populating USB image"
# Populate it
echo "* Populating USB image"
mv $tmp/isolinux.cfg $tmp/syslinux.cfg
umount $tmp
rmdir $tmp
mv $tmp/isolinux.cfg $tmp/syslinux.cfg
umount $tmp
rmdir $tmp
echo "* Making USB image bootable"
$srcdir/syslinux/unix/syslinux "$usb"
echo "* Making USB image bootable"
$srcdir/syslinux/unix/syslinux "$usb"