#!/bin/sh


# Put some docs at the root of the tree
sed "s/<date>/$DATESTAMP/;s/+version+/slint64-${TAGVERSION}.iso/" docs/CONTENT.TXT > $ISO/CONTENT.TXT
sed "s/+version+/$TAGVERSION/g" docs/README.TXT > $ISO/README.TXT
echo $DATESTAMP > $ISO/DateBuilt
rm -rf $ISO/boot/grub
mkdir -p $ISO/boot/grub
cp source/boot/grub/grub.cfg $ISO/boot/grub/
cp source/boot/grub/osdetect.cfg $ISO/boot/grub/
cp source/boot/grub/tools.cfg $ISO/boot/grub/
cp source/boot/grub/main.cfg $ISO/boot/grub/
cp source/boot/grub/instructions $ISO/boot/grub/
cp source/kernel/kernel-huge-${KVER}-x86_64-1/boot/vmlinuz-huge-$KVER \


chmod 755 $TMP/initrd/etc/rc.d/rc.espeakup
cp -f source/Speakup.txt $TMP/initrd
cat << 'FDF' > $TMP/initrd/usr/lib/setup/inst
#!/bin/sh
# Display the keyboard shortcuts for reviewing the screen with speakup
less /Speakup.txt
FDF
chmod 755 $TMP/initrd/usr/lib/setup/inst
cat << 'FDF' > $TMP/initrd/etc/profile.d/alias.sh
# Make sure LANG be the one chosen during installation, case occurring
[ -f /tmp/.SlintInstallationLANG ] && LANG=$(</tmp/.SlintInstallationLANG)
FDF
chmod 755 $TMP/initrd/etc/profile.d/alias.sh

# Remove INSURL as we don't provide installation through http/ftp, that
# would need a remote packages tree like on the ISO including the
# unmodified Slackware packages. Users can still provide such a tree
# copied from an ISO and export it through NFS or Samba.
rm $TMP/initrd/usr/lib/setup/INSURL
# Put in the initrd files (mostly programs and shared libaries) that we need
# in addition to those already included in the genuine Slackware initrd
( cd $TMP
	# Include the alsa-info script for debugging purposes
	cp $CWD/source/alsa/alsa-info.sh initrd/bin
#	wget --no-check-certificate -nv http://www.alsa-project.org/alsa-info.sh 2>/dev/null
	chmod 755 initrd/bin/alsa-info.sh
	# Tune /etc/rc.d/rc.alsa
	rm -f initrd/etc/rc.d/rc.alsa
	cp $CWD/source/alsa/rc.alsa initrd/etc/rc.d/
	chmod 755 initrd/etc/rc.d/rc.alsa
)
# Fourth step: install MO files, include intl packages, rebuild the initrd
# =======================================
# Install translations in the initrd
#
# We won't use Slackware color scheme, for dialog,  but our own. 
# Additionally, --noshadow will give us more usable lines and rows.
cp  $SOURCE/dialog/dialogrc $TMP/initrd/etc

grub-mkrescue -v --locales='none' --themes='' --compress=xz \
-o $PATHTOISO -iso_mbr_part_type 0x83 -partition_offset 16 -J \
--xorriso=./grub-mkrescue-sed.sh $ISO
printf "%b" "** Completed. ***

If writing the ISO was successful an hybrid DVD/USB image:
$PATHTOISO is ready.\n"
rm -r $TMP

