From 56211a7d726f54ddf87bef59ee91a3e47fedb269 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sat, 14 Sep 2024 19:51:57 +1000 Subject: [PATCH] fiddling --- build-installer.sh | 80 +++++++++++++++++++++++++++++++++++----------- initrd-init | 12 ++++++- vm.sh | 2 +- 3 files changed, 73 insertions(+), 21 deletions(-) diff --git a/build-installer.sh b/build-installer.sh index f73f059..b2ac246 100755 --- a/build-installer.sh +++ b/build-installer.sh @@ -200,6 +200,13 @@ install_order() { echo $1 } +# Helper function to for using dpkg in $INITRD +mydpkg() { + fakechroot fakeroot dpkg --force-architecture \ + --admindir=$INITRD/var/lib/dpkg --log=$INITRD/var/log/dpkg.log \ + --root=$INITRD $@ +} + # Prepare for unpacking mkdir -p $INITRD/var/log $INITRD/var/lib/dpkg @@ -210,15 +217,9 @@ for D in bin sbin lib lib64 ; do done echo "######## Installing installer ######### ${#PKGS[@]}" >&2 -# Use busybox-static rather than busybox-udeb +# Install busybox-static to have a good collection of static binaries. +# busybox-udeb may be installed and replace some of them download busybox-static $UDEBSDIR -rm $UDEBSDIR/busybox-udeb_* - -mydpkg() { - fakechroot fakeroot dpkg --force-architecture \ - --admindir=$INITRD/var/lib/dpkg --log=$INITRD/var/log/dpkg.log \ - --root=$INITRD $@ -} mydpkg --unpack $UDEBSDIR/busybox-static_*.deb $INITRD/bin/busybox --list | while read B ; do @@ -229,10 +230,13 @@ $INITRD/bin/busybox --list | while read B ; do watchdog|arping|brctl|crond|fsfreeze|i2cdetect|i2cdump| \ i2cget|i2cset|i2ctransfer|loadfont|mim|partprobe| \ rdate|telnetd|ubirename|udhcpd) - ln -s ../bin/busybox $INITRD/sbin/$B + ln $INITRD/bin/busybox $INITRD/sbin/$B + ;; + tar|dpkg|dpkg-deb) + : # ignore these ;; *) - ln -s busybox $INITRD/bin/$B + ln $INITRD/bin/busybox $INITRD/bin/$B ;; esac done @@ -250,13 +254,6 @@ Architecture: $TARGET_ARCH Version: $VERSION Description: devuan installation image -Package: busybox-udeb -Status: install ok installed -Maintainer: $TARGET_ARCH installer -Architecture: $TARGET_ARCH -Version: $VERSION -Description: not actually, but busybox-static is installed - EOF fi @@ -279,6 +276,45 @@ for DEB in $UDEBSDIR/*.udeb ; do done done +# libc6 cannot be unpacked in fakechroot .. do it by hand +ar p $UDEBSDIR/libc6_*.deb data.tar.xz | \ + tar xJf - --keep-directory-symlink -C $INITRD +cat <> $STATUS +Package: libc6 +Status: install ok installed +Maintainer: $TARGET_ARCH installer +Architecture: $TARGET_ARCH +Version: $(cd $UDEBSDIR ; echo libc6_*.deb | sed 's/^[^_]*_\([^_]*\).*$/\1/') +Description: libc6 manual + +EOF + +# Helper function to generate .list and .md5sums from a tar listing +dpkg_info_files() { + local P + cd $INITRD + sed '/^.\/$/{s|..|/.|;n};s|^\.||;s|/$||' | \ + tee "var/lib/dpkg/info/$1.list" | while read P ; do + [ -f "${P#/}" ] && md5sum ${P#/} + done > "var/lib/dpkg/info/$1.md5sums" +} +ar p $UDEBSDIR/libc6_*.deb data.tar.xz | tar tJf - | \ + dpkg_info_files "libc6:$TARGET_ARCH" + +mydpkg -E --install $UDEBSDIR/gcc-12-base_*.deb +mydpkg -E --install $UDEBSDIR/libgcc-s1_*.deb + +# dpkg via tar has wide dependecy graph +mydpkg -E --install $UDEBSDIR/libbz2-1.0_*.deb +mydpkg -E --install $UDEBSDIR/liblzma5_*.deb +mydpkg -E --install $UDEBSDIR/libmd0_*.deb +mydpkg -E --install --force-overwrite $UDEBSDIR/libpcre2-8-0_*.deb +mydpkg -E --install $UDEBSDIR/libselinux1_*.deb +mydpkg -E --install $UDEBSDIR/libzstd1_*.deb +mydpkg -E --install $UDEBSDIR/zlib1g_*.deb +mydpkg -E --install $UDEBSDIR/tar_*.deb +mydpkg -E --install $UDEBSDIR/dpkg_*.deb + # 3f This is set up for choose-mirror and console-setup echo ${DISTNAME} > $INITRD/etc/default-release mkdir $INITRD/etc/console-setup @@ -323,9 +359,16 @@ apt-ftparchive \ -o APT::FTPArchive::Release::Codename="$DISTNAME" \ -o APT::FTPArchive::Release::Architectures="$TARGET_ARCH" \ -o APT::FTPArchive::Release::Components="$SECTIONS" \ - release $MEDIA > $MEDIA/dists/$DISTNAME/Release + release $MEDIA/dists/$DISTNAME > $MEDIA/dists/$DISTNAME/Release ln -s $DISTNAME $MEDIA/dists/stable +# Final media touch-up for bootstrap-base +mkdir $MEDIA/.disk/ +touch $MEDIA/.disk/base_installable +echo full_cd > $MEDIA/.disk/cd_type +date +"Devuan GNU/Linux $DISTVERS $DISTNAME $ARCH - bespoke %Y%m%d" \ + > $MEDIA/.disk/info + # Finally prepare a squashfs of $MEDIA into $INITRD fakeroot mksquashfs $MEDIA $INITRD/pool.squashfs @@ -337,4 +380,3 @@ find $INITRD -not -name udebs -printf '%P\n' | \ cp $INITRD/boot/vmlinuz . exit 0 - diff --git a/initrd-init b/initrd-init index ee2120b..4883fa9 100755 --- a/initrd-init +++ b/initrd-init @@ -14,11 +14,21 @@ depmod echo NOW WE ARE HERE >&2 /lib/debian-installer/start-udev +# The virtio_{pci,blk} drivers suit the virt platform used by vm.sh +modprobe virtio_pci +modprobe virtio_blk + +# Set up the pool media modprobe loop modprobe squashfs losetup -f /pool.squashfs mount /dev/loop0 /cdrom exec /bin/busybox init < /dev/console > /dev/console 2>&1 -/bin/sh + +# just in case the above fails +exec /bin/sh + +# just in case the above fails +echo o > /proc/sysreq-trigger sleep 5 diff --git a/vm.sh b/vm.sh index 923f7f8..0ac4938 100755 --- a/vm.sh +++ b/vm.sh @@ -7,7 +7,7 @@ ARGS=( # boot setup -kernel vmlinuz -initrd initrd.gz - -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4" + -append "expert console=ttyAMA0 root=/dev/vda1 roottype=ext4" -serial mon:stdio -echr 0x1c # graphics setup -nographic -- 2.39.2