#!/bin/sh
# shellcheck disable=SC1091
. ./01_SetVariables.sh
if [ ! "$(id -u)" -eq 0 ]; then
  echo "Please execute this script as root."
  exit
fi
# Put some docs at the root of the tree
echo "$ISOLABEL" > "$ISODIR"/slint/ISOLABEL
sed "s/<date>/$DATESTAMP/;s/+version+/slint64-${ISOVERSION}.iso/" "$ROOTDIR"/CONTENT.TXT > "$ISODIR"/CONTENT.TXT
sed "s/+version+/$SLINTVERSION/g" "$ROOTDIR"/doc/README.TXT > "$ISODIR"/README.TXT
echo "$DATESTAMP" > "$ISODIR"/DateBuilt
rm -rf "$ISODIR"/boot/grub
mkdir -p "$ISODIR"/boot/grub
cp "$ROOTDIR"/grub/grub.cfg "$ISODIR"/boot/grub/
#cp "$CWD"/grub/grub-mkrescue-sed.sh "$ISODIR"/boot/grub/
cd "$TEMPDIR" || exit 1
tar -xf "$SLINTREPO"/kernel-"$KVER"*txz boot/vmlinuz-"$KVER"
mv boot/vmlinuz-"$KVER" "$ISODIR"/linux
cd - || exit 1
(cd "$ISODIR" || exit 1
tree >> CONTENT.TXT)
