X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=mkit.sh;h=4012566984b7ecc7a311c656b340468ab9f84d9b;hb=21f9db54a75be7e654cfdef72727158fd57ac332;hp=e8dc6574ae53b3e76416d7e799dcb544ed9adda9;hpb=f606888533e8b5f92770f318367f63ad0c0f7cd3;p=rrq%2Ftiniest.git diff --git a/mkit.sh b/mkit.sh index e8dc657..4012566 100755 --- a/mkit.sh +++ b/mkit.sh @@ -9,21 +9,21 @@ set -e -### Step 1. Download original .deb file from the source +echo '### Step 1. Download original Packages file from the source' REPO="deb.devuan.org/merged" SUITE="daedalus" SECTION="main" ARCH="amd64" -MBR=gpt # or dos +MBR=dos # gpt PKGFILE=${REPO//\//_}_${SUITE}_${SECTION}_binary-${ARCH}_Packages if [ ! -r $PKGFILE ] ; then - wget -O - http://$REPO/dists/$SUITE/$SECTION/binary-$ARCH/Packages.xz | \ + wget -qO - http://$REPO/dists/$SUITE/$SECTION/binary-$ARCH/Packages.xz | \ xzcat - > ${PKGFILE} fi -# Reduce that Packages file into two maps for finding filename and depends -echo "# Creating mapdepends.txt and mapfile.txt" +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"; } $1=="Package:" {P=$2; next} @@ -42,7 +42,7 @@ maplookup() { debfile() { local F="$(maplookup $1 mapfile.txt)" if [ ! -e "${F##*/}" ] ; then - wget "http://$REPO/$F" || return 1 + wget -q "http://$REPO/$F" || return 1 fi echo "${F##*/}" } @@ -54,12 +54,12 @@ debextract() { } # Deteremine which kernel to use; this is -echo -n "# Determining kernel: " +echo "# Determine kernel" KERNEL="$(maplookup linux-image-amd64 mapdepends.txt | \ sed 's/.*\(linux-image[^ ]*\).*/\1/')" -echo $KERNEL +echo "# ... $KERNEL" -### Step 2. Create and populate the initrd, and packit up. +echo '### Step 2. Create and populate the initrd, and packit up.' # The initrd contains only a few kernel modules for coping with a # later pivoting onto a "full" filesystem. @@ -100,8 +100,8 @@ MODULES=( t10-pi sd_mod sg nls_cp437 nls_ascii fat vfat crc32c_generic jbd2 mbcache crc16 ext4 + usb-storage usbcore usb-common xhci-pci xhci-hcd isofs - overlay # input psmouse evdev # network @@ -129,28 +129,17 @@ depmod -F initrd/System.map-$V -b initrd $V $MOODLES echo "# setup a scripted init. The kernel runs this via the #! interpreter" rm -f initrd/sbin/init # just in case -cat < initrd/init -#!/bin/sh -echo -echo -echo "Hi there, tiniest lover!" - -mkdir /proc -mount -t proc proc /proc -mount -t devtmpfs devtmpfs /dev -mkdir /dev/pts -mount -t devpts devpts /dev/pts -mkdir /sys -mount -t sysfs sysfs /sys -$(for m in ${MODULES[@]} ; do echo modprobe $m ; done) -exec /bin/sh -EOF +cp init/init initrd/init chmod a+x initrd/init +echo "# Declare password-less root" +mkdir -p initrd/etc +echo 'root::0:0:root:/root:/bin/bash' > initrd/etc/passwd + echo "# Now pack up that initrd as initrd.gz" ( cd initrd ; find . | fakeroot cpio -H newc -o | gzip ) >initrd.gz -### Step 3. create a 32 Mb fat filesystem with bios and UEFI boot +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 @@ -166,9 +155,10 @@ EOF mkfs.fat -n TINIEST --offset 2048 -F 16 bootimage.raw IMG="-i bootimage.raw@@$((2048*512))" -# Add an ext2 filesystem at offset 61440*512 +# Add an ext2 filesystem at offset 34816*512 # Copy initrd.gz and kernel into the fat filesystem root -mke2fs -t ext4 -E offset=$((34816*512)) -F bootimage.raw 15M +EXT=offset=$((34816*512)) +mke2fs -t ext4 -E $EXT -F bootimage.raw 15M mcopy $IMG initrd.gz :: mcopy $IMG kernel/boot/vm* ::/vmlinuz @@ -188,6 +178,8 @@ mcopy $IMG \ kernel/usr/lib/syslinux/modules/bios/* ::/boot/syslinux/bios 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 @@ -196,15 +188,14 @@ EOF mmd $IMG ::/EFI mmd $IMG ::/EFI/BOOT -mmd $IMG ::/EFI/BOOT/efi64 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 syslinux-uefi.cfg ::/EFI/BOOT/syslx64.cfg +mcopy $IMG syslinux-uefi.cfg ::/EFI/BOOT/syslinux.cfg - -syslinux --install --offset=${IMG#*@@} bootimage.raw +#echo "# Set up isolinux boot" +#mcopy $IMG kernel/usr/lib/ISOLINUX/isolinux.bin ::/ case "$MBR" in dos) MBRBIN=mbr.bin ;; @@ -218,4 +209,12 @@ esac dd conv=notrunc of=bootimage.raw bs=440 count=1 \ if=kernel/usr/lib/syslinux/mbr/$MBRBIN +echo "# populate the extra partition" +if [ -d extra ] ; then + mkdir -p X + fuse2fs -o fakeroot -o$EXT bootimage.raw X + rsync -r extra/. X/. + umount X +fi + exit