From f041247eef888601bb00200f1b8c0772e51e61cd Mon Sep 17 00:00:00 2001 From: wesley van tilburg Date: Thu, 7 Mar 2024 21:40:33 +0100 Subject: [PATCH] Add Ti(ny) Lo(ader) build script --- tilo/build.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 tilo/build.sh diff --git a/tilo/build.sh b/tilo/build.sh new file mode 100755 index 0000000..b2a9e63 --- /dev/null +++ b/tilo/build.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +#get latest non patch release candidate kernel and busybox version +busybox_latest="$(curl -s "https://api.github.com/repos/mirror/busybox/tags" | jq -r '.[0].name' | tr "_" ".")" +kernel_latest="$(curl -s "https://api.github.com/repos/torvalds/linux/tags" | jq -r '.[] .name' | awk '$0 !~/-/' | head -n1 | cut -c2-4)" + +#backups for when hitting ratelimits during testing :) +#kernel_latest="6.7" +#busybox_latest="1.36.0" + +echo "Using kernel version: $kernel_latest" +echo "Using busybox version: $busybox_latest" + +kernel_major="$(echo "$kernel_latest" | cut -c1)" +kernel_url="https://mirrors.edge.kernel.org/pub/linux/kernel/v$kernel_major.x" + +mkdir -p src +cd src + +wget "$kernel_url/linux-$kernel_latest.tar.xz" +tar -xf linux-$kernel_latest.tar.xz +cd linux-$kernel_latest + make defconfig + make -j 8 || exit + +cd .. + +wget https://busybox.net/downloads/busybox-$busybox_latest.tar.bz2 +tar -xf busybox-$busybox_latest.tar.bz2 +cd busybox-$busybox_latest + make defconfig + sed 's/^.*CONFIG_STATIC[^_].*$/CONFIG_STATIC=y/g' -i .config + make -j$(nproc) || exit + cd .. + +cd .. + +cp src/linux-$kernel_latest/arch/x86/boot/bzImage ./ + +mkdir initrd +cd initrd + + mkdir -p bin dev proc sys + cd bin + cp ../../src/busybox-$busybox_latest/busybox ./ + for prog in $(./busybox --list); do + ln -s /bin/busybox ./$prog + done + + cd .. + + echo '#!/bin/sh' > init + echo 'mount -t sysfs sysfs /sys' >> init + echo 'mount -t proc proc /proc' >> init + echo 'mount -t devtmpfs udev /dev' >> init + echo 'sysctl -w kernel.printk="2 4 1 7"' >> init + echo 'clear' >> init + #todo: recompile to check if this fixes ctrl +c issues + echo '::respawn:-/bin/sh' >> init + #echo '/bin/sh' >> init + + chmod -R 777 . + + find . | cpio -o -H newc > ../initrd.img + +cd .. + + +