From 5a9f1804dca0c242bfca45c67eb3c26941f99f91 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sun, 5 Nov 2023 22:18:51 +1100 Subject: [PATCH] Reworked to allow 2 sources; kernel and busybix from daedalus and syslinux from ceres. --- mkit.sh | 70 +++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/mkit.sh b/mkit.sh index 4012566..eed589a 100755 --- a/mkit.sh +++ b/mkit.sh @@ -10,39 +10,51 @@ set -e echo '### Step 1. Download original Packages file from the source' -REPO="deb.devuan.org/merged" -SUITE="daedalus" -SECTION="main" +REPOS=( deb.devuan.org/{merged_daedalus_main,merged_ceres_main} ) ARCH="amd64" MBR=dos # gpt -PKGFILE=${REPO//\//_}_${SUITE}_${SECTION}_binary-${ARCH}_Packages -if [ ! -r $PKGFILE ] ; then - wget -qO - http://$REPO/dists/$SUITE/$SECTION/binary-$ARCH/Packages.xz | \ - xzcat - > ${PKGFILE} -fi +for REPO in ${REPOS[@]} ; do + W=( ${REPO//_/ } ) + SUITE=${W[1]} + SECTION=${W[2]} + + PKGFILE=${W[0]/\//_}_${SUITE}_${SECTION}_binary-${ARCH}_Packages + if [ ! -r $PKGFILE ] ; then + XZSRC="http://${W[0]}/dists/$SUITE/$SECTION/binary-$ARCH/Packages.xz" + echo "$XZSRC" + wget -qO - $XZSRC | xzcat - > ${PKGFILE} + fi -echo '# Reduce Packages file into two maps for finding filename and depends' -echo "# ..creating mapdepends.txt and mapfile.txt" -awk ' -BEGIN { print "###" > "mapdepends.txt"; print "###" > "mapfile.txt"; } + echo '# Reduce Packages file into two maps for filename and depends' + echo "# ..creating mapdepends.txt and mapfile.txt" + awk ' + BEGIN { print "###" >> "mapdepends.txt"; print "###" >> "mapfile.txt"; } $1=="Package:" {P=$2; next} $1=="Pre-Depends:" {print P,$0 >> "mapdepends.txt";next } $1=="Depends:" {print P,$0 >> "mapdepends.txt";next } $1=="Filename:" {print P,$2 >> "mapfile.txt";next } ' ${PKGFILE} +done -# Function to find the filename (or an map file) for a given package +# Function to find the filename for a given package in the given mapfile maplookup() { - awk -v P="$1" '$1==P {$1="" ;print; exit}' ${2-mapfile.txt} | \ - sed 's/ //' + local FN=${3:-tail} + echo "maplookup $1 $2" >&2 + grep "^$1 " $2 >&2 + grep "^$1 " $2 | $FN -n 1 | sed 's/[^ ]* //' } # Function to download a deb file and return its name debfile() { - local F="$(maplookup $1 mapfile.txt)" + local FN=${2-tail} + local F="$(maplookup $1 mapfile.txt $FN)" if [ ! -e "${F##*/}" ] ; then - wget -q "http://$REPO/$F" || return 1 + for REPO in ${REPOS[@]} ; do + echo "download http://${REPO%%_*}/$F" >&2 + wget -q "http://${REPO%%_*}/$F" && break + ls -l $(basename $F) >&2 + done || return 1 fi echo "${F##*/}" } @@ -55,7 +67,7 @@ debextract() { # Deteremine which kernel to use; this is echo "# Determine kernel" -KERNEL="$(maplookup linux-image-amd64 mapdepends.txt | \ +KERNEL="$(maplookup linux-image-amd64 mapdepends.txt head | \ sed 's/.*\(linux-image[^ ]*\).*/\1/')" echo "# ... $KERNEL" @@ -68,7 +80,7 @@ rm -fr initrd echo "# Extract busybox, and fluff it up" mkdir initrd -debextract initrd $(debfile busybox-static) +debextract initrd $(debfile busybox-static head) for L in $(initrd/bin/busybox --listfull) ; do mkdir -p $(dirname initrd/$L) case "$L" in @@ -84,7 +96,7 @@ echo "# Extract the kernel package ($KERNEL)" echo "# .. and syslinux stuff if needed" if [ ! -d kernel ] ; then mkdir kernel - debextract kernel $(debfile $KERNEL) + debextract kernel $(debfile $KERNEL head) debextract kernel $(debfile syslinux) debextract kernel $(debfile syslinux-common) debextract kernel $(debfile syslinux-efi) @@ -101,7 +113,7 @@ MODULES=( nls_cp437 nls_ascii fat vfat crc32c_generic jbd2 mbcache crc16 ext4 usb-storage usbcore usb-common xhci-pci xhci-hcd - isofs + isofs exfat loop # input psmouse evdev # network @@ -162,15 +174,8 @@ mke2fs -t ext4 -E $EXT -F bootimage.raw 15M mcopy $IMG initrd.gz :: mcopy $IMG kernel/boot/vm* ::/vmlinuz -mcopy $IMG bootmenu.cfg ::/ mcopy $IMG splash.png ::/ -echo "# Set up legacy boot" -cat < syslinux-legacy.cfg -path /boot/syslinux/bios -include /bootmenu.cfg -EOF - mmd $IMG ::/boot mmd $IMG ::/boot/syslinux mmd $IMG ::/boot/syslinux/bios @@ -180,12 +185,6 @@ mcopy $IMG syslinux-legacy.cfg ::/syslinux.cfg syslinux --install --offset=${IMG#*@@} bootimage.raw -echo "# Set up UEFI boot" -cat < syslinux-uefi.cfg -path /EFI/BOOT/efi64 -include /bootmenu.cfg -EOF - mmd $IMG ::/EFI mmd $IMG ::/EFI/BOOT mcopy $IMG kernel/usr/lib/SYSLINUX.EFI/efi64/syslinux.efi \ @@ -194,9 +193,6 @@ mcopy $IMG \ kernel/usr/lib/syslinux/modules/efi64/* ::/EFI/BOOT mcopy $IMG syslinux-uefi.cfg ::/EFI/BOOT/syslinux.cfg -#echo "# Set up isolinux boot" -#mcopy $IMG kernel/usr/lib/ISOLINUX/isolinux.bin ::/ - case "$MBR" in dos) MBRBIN=mbr.bin ;; gpt) -- 2.39.2