#!/bin/sh

# Run this script in the isolinux directory to generate a full installation
# ISO in /tmp. This may be written to a USB flash drive, or burned onto
# optical media (if the media has enough space to hold it).

if [ ! -d ../isolinux ]; then
  echo "Run this script in the Slackware tree's 'isolinux' directory."
  exit 1
fi

if [ -d ../slackware64 ]; then
  SLACKNAME="slackware64"
else
  SLACKNAME="slackware"
fi

# Find the Slackware version from the installer:
if [ -r ../source/installer/installer.SlackBuild ]; then
  SLACKVERSION="$(grep "^INSTALLERVERSION=" ../source/installer/installer.SlackBuild | cut -f 2 -d \")"
else # guess
  SLACKVERSION="666"
fi

rm -f /tmp/${SLACKNAME}-${SLACKVERSION}-full-install.img

( cd ..
  xorriso -as mkisofs \
    -iso-level 3 \
    -full-iso9660-filenames \
    -R -J -A "$SLACKNAME $SLACKVERSION full install" \
    -hide-rr-moved \
    -v -d -N \
    -eltorito-boot isolinux/isolinux.bin \
    -eltorito-catalog isolinux/boot.cat \
    -no-emul-boot -boot-load-size 4 -boot-info-table \
    -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \
    -eltorito-alt-boot \
    -e isolinux/efiboot.img \
    -no-emul-boot -isohybrid-gpt-basdat \
    -m 'source/' \
    -volid "SlackDVD" \
    -output /tmp/${SLACKNAME}-${SLACKVERSION}-full-install.img \
  .
)
