#!/bin/sh # Author: Didier Spaier, Paris, France # # Before running this script, adapt MIRROR and PATHTOISO below to your # installation as well as other environments variables # # CWD=$(pwd) SLACKVERSION="current" OLDSLACKVERSION="14.2" SLINTVERSION="14.2.1.3" TAG="" TAGVERSION=${SLINTVERSION}$TAG KVER=4.19.30 usage() { printf %b "Usage: $0" exit } if [ $# -ne 0 ]; then usage; fi PATHTOISO=/data/images_iso/slint64-${TAGVERSION}.iso SLINTREPO=/storage/repo/x86_64/slint-testing/slint SOURCE=/storage/repo/x86_64/slint-testing/source MIRROR=/data/slackware64-$SLACKVERSION SCRIPTS=/storage/repo/x86_64/slint-testing/source/localization/scripts KERNELMODULES=source/kernel/kernel-modules*txz DATESTAMP=`date -u +%Y%m%d` if [ ! $UID -eq 0 ]; then printf "%b" "Please execute this script as root.\n" exit fi TMP=$(mktemp -d) || exit 1 ISO=/data/iso64 . $SCRIPTS/SeTlocales if [ ! -f $ISO/slint/DONOTREMOVEME.TXT ]; then echo "The file $ISO/slint/DONOTREMOVEME.TXT is missing," echo "thus I can't check that the package tree fits the target system." exit fi if ! grep "Slint version: ${SLINTVERSION}" $ISO/slint/DONOTREMOVEME.TXT 1>/dev/null; then echo "Mismatch between the versions of the package tree and target system" exit fi if ! grep "System: 64" $ISO/slint/DONOTREMOVEME.TXT 1>/dev/null; then echo "Mismatch (32-bit vs 64-bit) between the package tree and the target system." exit fi # Put some docs at the root of the tree sed "s//$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 # Copy to $ISO/{EFI,isolinux,kernels} rm -rf $ISO/{EFI,isolinux} mkdir -p $ISO/isolinux mkdir -p $ISO/EFI/BOOT cp source/EFI/BOOT/grub.cfg $ISO/EFI/BOOT/ cp source/EFI/BOOT/osdetect.cfg $ISO/EFI/BOOT/ cp source/EFI/BOOT/tools.cfg $ISO/EFI/BOOT/ cp source/EFI/BOOT/grub-embedded.cfg $ISO/EFI/BOOT/ cp source/kernel/kernel-huge-${KVER}-x86_64-1/boot/vmlinuz-huge-$KVER \ $ISO/isolinux/linux (cd $ISO/EFI/BOOT/ grub-mkimage --format=x86_64-efi --output=$ISO/EFI/BOOT/bootx64.efi \ --config=grub-embedded.cfg --compression=xz --prefix=/EFI/BOOT \ play part_gpt part_msdos fat ext2 hfs hfsplus iso9660 udf ufs1 ufs2 \ zfs chain linux boot appleldr configfile normal regexp minicmd \ reboot halt search search_fs_file search_fs_uuid search_label \ gfxterm gfxmenu efi_gop efi_uga all_video loadbios gzio echo true \ probe loadenv bitmap_scale font cat help ls png jpeg tga test \ at_keyboard usb_keyboard ) cp source/isolinux/{f1.txt,isolinux.bin,BEEP,vesamenu.c32} $ISO/isolinux iconv -f UTF-8 -t CP437 -o $ISO/isolinux/isolinux.cfg source/isolinux/isolinux-vesamenu.cfg.64 # Third step: prepare and put in $TMP stuff needed for internationalization # ========================================== # printf "%b" "\nPreparation in progress..." mkdir $TMP/initrd ( cd $TMP/initrd gunzip -cd < $CWD/source/initrd/initrd.img-14.2 | \ cpio -i -d -m -H newc --no-absolute-filenames ) rm -r $TMP/initrd/lib/modules # Let's replace the firmware files by those shipped in the initrd of # Slacwkare64-current that includes the same kernel modules that we will # include in this installer's initrd. # Make sure this firmware matches the kernel shipped in this initrd # TODO: save the firmware outside the local mirror next time as we won't # use a kernel that has been released just a few hours ago, to be safe. INITRD2=$MIRROR/isolinux/initrd.img TMP2=$(mktemp -d) || exit 1 mkdir $TMP2/initrd ( cd $TMP2/initrd xz -cd < $CWD/source/initrd/initrd.img | \ cpio -i -d -m -H newc --no-absolute-filenames ) rm -r $TMP/initrd/lib/firmware cp -r $TMP2/initrd/lib/firmware $TMP/initrd/lib rm -r $TMP2 # End of the modification to replace /lib/firmware in initrd of the # Slint installer. # cp source/util-linux/util-linux-2.27.1-x86_64-1/sbin/wipefs \ $TMP/initrd/usr/sbin chmod 755 $TMP/initrd/usr/sbin/wipefs # TODO: cheery pick the libs we need instead of installing whole # packages, to save some space /sbin/installpkg --root $TMP/initrd $(find $SLINTREPO -name brltty.installer*.t?z) /sbin/installpkg --root $TMP/initrd $(find $SLINTREPO -name installer-translations*.t?z) # libexpat.so.1 is requested by brltty.installer /sbin/installpkg --root $TMP/initrd $(find $ISO -name expat*.t?z) # libcre2.32.so.0 is requested by brltty.installer /sbin/installpkg --root $TMP/initrd $(find $ISO -name pcre2*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name strace*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name spkg*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name json-c*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name libsndfile*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name orc-0*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name alsa-lib*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name alsa-utils*.t?z) # alsamixer needs libformw.so.5 shipped in the ncurses package. #/sbin/installpkg --root $TMP/initrd $(find $ISO -name nnnn*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name ncurses*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name portaudio*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name flac*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name libogg*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name libvorbis*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name pcaudiolib*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name sonic*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name espeak-*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name espeakup*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name libyaml*.t?z) /sbin/installpkg --root $TMP/initrd $(find $ISO -name liblouis*.t?z) 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=$(/dev/null echo "--- Kernel modules have been compressed ---" echo "--- Running depmod ---"- echo "/sbin/depmod -b $TMP/initrd $KVER" /sbin/depmod -b $TMP/initrd $KVER echo "--- depmod has be run ---" mkdir -p $TMP/initrd/usr/share/fonts cp fonts/* $TMP/initrd/usr/share/fonts # Copying new and modified files in $ISO/isolinux/ # We'll include a font (encoded in CP437), as if no font is set, text files are # displayed using native font (confirmed by Gene Cumm on syslinux mailing list), # but native (or hardware) code page can differ upon country, according to: # http://www.drdos.net/documentation/usergeng/17ugch17.htm cp -p source/isolinux/ter-i16b.psf $ISO/isolinux # Copying new and modified files in $TMP/initrd/ for i in $(<$CWD/source/scripts); do mkdir -p $TMP/initrd/$(dirname $i) cp -p $SCRIPTS/$(basename $i) $TMP/initrd/$(dirname $i) chmod 0755 $TMP/initrd/$(dirname $i)/$(basename $i) done # 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 tar xf $ISO/slint/gettext-0*.t?z tar xf $ISO/slint/gettext-tools-*.t?z # We need these programs to display translations cp -a usr/bin/{envsubst,gettext*} initrd/usr/bin # To use spkg, we need xzdec shipped in the xz package tar xf $ISO/slint/xz-*.t?z cp usr/bin/xzdec initrd/bin # In addition to the program dialog, we'll need its translation files for # included languages tar xf $ISO/slint/dialog-*.t?z # we'll need the translation files associated to programs like cfdisk for # included languages tar xf $ISO/slint/util-linux-*.t?z # we will include gconv-modules and all libraries in /usr/lib64/gconv # associated to encodings of PO files mkdir -p initrd/usr/lib64/gconv glibc-solibs tar xf $ISO/slint/glibc-solibs-*.t?z for i in gconv-modules ISO8859-1.so ISO8859-15.so ISO8859-2.so KOI8-R.so; do cp -a usr/lib64/gconv/$i initrd/usr/lib64/gconv done tar xf $ISO/slint/glibc-i18n-*.t?z # Let's ship nano, a newbie friendly text editor, and its dependency # libmagic. tar xf $ISO/slint/file-*t?z tar xf $ISO/slint/nano-*t?z cp usr/lib64/libmagic.so.1.0.0 initrd/usr/lib64 cp usr/bin/nano initrd/bin # Copying /usr/lib64/locale//* and the (generated) MO files in: $TMP/initrd mkdir -p initrd/usr/lib64/locale for Locale in $(<$CWD/source/locales_list_sorted_by_name); do ll_TT=$(echo $Locale|cut -c 1-5) ll=$(echo $Locale|cut -c 1-2) SeTCode SeTLocaleDir # Let's include the files gettext needs in /usr/lib64/locale to work. # I could have included (generated) locale_archive instead to save # some space on the initrd, but this would have prevented the user to # run this script on a machine with a different ARCH than the target. # Just in case I change my mind (PS. I did :-) # We'll also include translation files for programs used during installation # coming from packages unpacked above # We'll compile the locale definitions taken from the host system. #localedef --add-to-archive /usr/lib64/locale/${ll_TT} \ # --prefix=$TMP/initrd 1>/dev/null mkdir -p initrd/usr/share/locale/$LocaleDir/LC_MESSAGES cp -r usr/lib64/locale/$Locale \ initrd/usr/lib64/locale if [ -f usr/share/locale/$LocaleDir/LC_MESSAGES/gettext-runtime.mo ]; then cp usr/share/locale/$LocaleDir/LC_MESSAGES/gettext-runtime.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES elif [ -f usr/share/locale/$ll/LC_MESSAGES/gettext-runtime.mo ]; then cp usr/share/locale/$ll/LC_MESSAGES/gettext-runtime.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES fi if [ -f usr/share/locale/$LocaleDir/LC_MESSAGES/dialog.mo ]; then cp usr/share/locale/$LocaleDir/LC_MESSAGES/dialog.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES elif [ -f usr/share/locale/$ll/LC_MESSAGES/dialog.mo ]; then cp usr/share/locale/$ll/LC_MESSAGES/dialog.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES fi if [ -f usr/share/locale/$LocaleDir/LC_MESSAGES/util-linux.mo ]; then cp usr/share/locale/$LocaleDir/LC_MESSAGES/util-linux.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES elif [ -f usr/share/locale/$ll/LC_MESSAGES/util-linux.mo ]; then cp usr/share/locale/$ll/LC_MESSAGES/util-linux.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES fi if [ -f usr/share/locale/$LocaleDir/LC_MESSAGES/nano.mo ]; then cp usr/share/locale/$LocaleDir/LC_MESSAGES/nano.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES elif [ -f usr/share/locale/$ll/LC_MESSAGES/nano.mo ]; then cp usr/share/locale/$ll/LC_MESSAGES/nano.mo \ initrd/usr/share/locale/$LocaleDir/LC_MESSAGES fi done # 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 chown -R root:root $ISO/isolinux # Register the target cp $ISO/slint/DONOTREMOVEME.TXT $TMP/initrd/.target rm $TMP/initrd/.installer-version # Build the initrd ( cd $TMP/initrd # find . -print | cpio -o --owner root:root -H newc | gzip -9 > $ISO/isolinux/initrd.img find . | cpio -o -H newc | xz -9fv -C crc32 > $ISO/isolinux/initrd.img ) mv $ISO/isolinux/initrd.img $ISO/isolinux/initrd # Fifth step: build the ISO file # ================ ( cd $ISO # size=$(BLOCKSIZE=1M du -s EFI|sed "s/\([[:digit:]][[:digit:]]\).*/\1/") # rsize=$(( $size + 1 )) dd if=/dev/zero of=efiboot.img bs=1M count=2 # Format the image as FAT16: mkfs.fat efiboot.img # Create a temporary mount point: MOUNTPOINT=$(mktemp -d) # Mount the image there: mount -o loop efiboot.img $MOUNTPOINT # Copy the the whole EFI directory to the mountpoint as elilo needs to # find everything it deals with there. # On the other hand, no need to include EFI in the ISO. cp -a EFI $MOUNTPOINT # Unmount and clean up: umount $MOUNTPOINT rmdir $MOUNTPOINT # Move the efiboot.img to ../../isolinux: mv efiboot.img $ISO/isolinux # Now $ISO contains all files to be put on the ISO image, so we can # complete $ISO/CONTENT.TXT with the file tree sed -i "s//64-${SLINTVERSION}$SUFFIX/g" CONTENT.TXT tree >> CONTENT.TXT EFIOPTIONS="-eltorito-alt-boot -e isolinux/efiboot.img -isohybrid-gpt-basdat -no-emul-boot" xorriso -as mkisofs \ -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \ -hide-rr-moved \ -U \ -V "ISO64_CURRENT" \ -J \ -joliet-long \ -r \ -v \ -x kernels \ -o $PATHTOISO \ -b isolinux/isolinux.bin \ -c isolinux/boot.cat \ -no-emul-boot \ -boot-info-table $EFIOPTIONS . \ ) 2>${PATHTOISO%iso}log.txt chown -R `stat -c %U:%G $CWD` $PATHTOISO ${PATHTOISO%iso}log.txt $ISO printf "%b" "** Completed. *** If writing the ISO was successful an hybrid DVD/USB image: $PATHTOISO is ready.\n" echo "Check the directory $TMP" #rm -r $TMP