Correction for better excalibur building
authorRalph Ronnquist <rrq@rrq.au>
Mon, 28 Apr 2025 05:51:12 +0000 (15:51 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Mon, 28 Apr 2025 05:51:12 +0000 (15:51 +1000)
mkit.sh

diff --git a/mkit.sh b/mkit.sh
index c52cba285137ce3862b8f39abc0862e0cf356dc4..2bb7ed53a291d87869c0c16e4c9338ae905139ad 100755 (executable)
--- a/mkit.sh
+++ b/mkit.sh
@@ -17,7 +17,7 @@ DEPFILE=save/mapdepends.txt
 
 REPOS=(
     deb.devuan.org/merged_excalibur_main
-    deb.devuan.org/merged_ceres_main
+    #deb.devuan.org/merged_ceres_main
 )
 ARCH="amd64"
 MBR=dos # gpt
@@ -52,7 +52,7 @@ $1=="Filename:" {print P,$2 >> MAP;next }
 done
 
 # Append any additional saved deb files
-for DEB in save/*.deb ; do
+for DEB in $(ls save/*.deb 2>/dev/null); do
     P="${DEB%%_*}"
     P="${P#save/}"
     echo "$P save/$DEB" >> $MAPFILE
@@ -208,13 +208,11 @@ echo "# Include some kernel modules in the initrd"
 MODULES=(
     # disk
     scsi_common scsi_mod libata ata_piix ata_generic cdrom sr_mod
-    crc32-pclmul crct10dif_common crc-t10dif crc64 crc64-rocksoft
-    t10-pi sd_mod sg
-    nls_cp437 nls_ascii fat vfat
-    crc32c_generic jbd2 mbcache crc16 ext4
+    crc32-pclmul crc32c_generic crc16
+    #crct10dif_common crc-t10dif crc64 crc64-rocksoft t10-pi
+    sd_mod sg nls_cp437 nls_ascii fat vfat jbd2 mbcache ext4
     usb-storage usbcore usb-common xhci-pci xhci-hcd
-    isofs exfat loop
-    efivarfs
+    isofs exfat loop efivarfs
     # input
     psmouse evdev
     # network
@@ -263,44 +261,56 @@ echo '### Step 3. create a 32  Mb fat filesystem with bios and UEFI boot'
 rm -f bootimage.raw
 dd if=/dev/zero of=bootimage.raw bs=32M count=1
 
+EFILDR="kernel/usr/lib/SYSLINUX.EFI/efi64/syslinux.efi"
+EFIMODS="kernel/usr/lib/syslinux/modules/efi64/*"
+LCYMODS="kernel/usr/lib/syslinux/modules/bios/*"
+VMLINUZ="kernel/boot/vm*"
+
+SIZE=$(du -c $EFILDR $EFIMODS $LCYMODS $VMLINUZ \
+         initrd.gz splash.png syslinux-legacy.cfg \
+         muffin.lua syslinux-uefi.cfg | sed '$!d;s|\s.*||' )
+echo "du = $SIZE kb"
+SIZE=$(( ( ( 2 * SIZE + 4096 ) / 2048 ) * 2048 ))
+echo "SIZE = $SIZE sectors"
+
 # Prepare a gpt/dos partition table with a first partition marked as EFI
 sfdisk bootimage.raw <<EOF
 label: $MBR
 
-2048 32767 U *
+2048 $SIZE U *
 - - L
 EOF
 
-# Add a fat filesystem at 2048 61440
-mkfs.fat -n TINIEST --offset 2048 -F 16 bootimage.raw
+# Add a fat filesystem at 2048 
+mkfs.fat -n TINIEST --offset 2048 bootimage.raw
 IMG="-i bootimage.raw@@$((2048*512))"
 
-# Add an ext2 filesystem at offset 34816*512
+# Add an ext2 filesystem at offset 
 # Copy initrd.gz and kernel into the fat filesystem root
-EXT=offset=$((34816*512))
-mke2fs -t ext4 -E $EXT -F bootimage.raw 15M
-
-mcopy $IMG initrd.gz ::
-mcopy $IMG kernel/boot/vm* ::/vmlinuz
-mcopy $IMG splash.png ::/
+PART2=( $(fdisk -lo START,SECTORS bootimage.raw | sed '$!d') )
+EXT=offset=$(( ${PART2[0]} * 512 ))
+echo mke2fs -t ext4 -E $EXT -F bootimage.raw $(( ${PART2[1]} / 2 ))
+mke2fs -t ext4 -E $EXT -F bootimage.raw $(( ${PART2[1]} / 2 ))
 
+# Note that this is unsafe copying that might spill outside the partition
+mmd $IMG ::/EFI
+mmd $IMG ::/EFI/BOOT
 mmd $IMG ::/boot
 mmd $IMG ::/boot/syslinux
 mmd $IMG ::/boot/syslinux/bios
-mcopy $IMG \
-      kernel/usr/lib/syslinux/modules/bios/* ::/boot/syslinux/bios
+
+mcopy $IMG initrd.gz           ::/
+mcopy $IMG $VMLINUZ            ::/vmlinuz
+mcopy $IMG splash.png          ::/
 mcopy $IMG syslinux-legacy.cfg ::/syslinux.cfg
 
-syslinux --install --offset=${IMG#*@@} bootimage.raw
-mmd $IMG ::/EFI
-mmd $IMG ::/EFI/BOOT
-mcopy $IMG kernel/usr/lib/SYSLINUX.EFI/efi64/syslinux.efi \
-      ::/EFI/BOOT/bootx64.efi
-mcopy $IMG \
-      kernel/usr/lib/syslinux/modules/efi64/* ::/EFI/BOOT
+mcopy $IMG muffin.lua        ::/EFI/BOOT/muffin.lua
+mcopy $IMG $EFILDR           ::/EFI/BOOT/bootx64.efi
 mcopy $IMG syslinux-uefi.cfg ::/EFI/BOOT/syslinux.cfg
-## Add lua boot script
-mcopy $IMG muffin.lua ::/EFI/BOOT/muffin.lua
+mcopy $IMG $EFIMODS          ::/EFI/BOOT/
+
+mcopy $IMG $LCYMODS          ::/boot/syslinux/bios/
+syslinux --install --offset=${IMG#*@@} bootimage.raw
 
 case "$MBR" in
     dos) MBRBIN=mbr.bin ;;