logo

bootstrap-initrd

Linux initrd generator to bootstrap a POSIX-ish system from a reasonably small binary seed git clone https://hacktivis.me/git/make-initrd.git
commit: 32070e1ed114b4ead056b5467f925c0df68f7e1f
parent 27a82d03736dae297ea97288453568cdb96ef117
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 28 Apr 2024 20:14:25 +0200

Add bzip2

Diffstat:

MREADME.md5+++++
Minit.sh16++++++++++++++++
Mmake-initrd.sh4++++
3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -49,6 +49,11 @@ Reference implementation and AFAIK the one used in BSDs, can be built with only ### bmake NetBSD make(1) made portable, uses an autotools configure script but much simpler than the GNU Make one. +### bzip2 +Builds with C Compiler + bmake. +Meanwhile: +- pbzip2: Requires C++ compiler + ## Launching in QEMU ``` $ qemu-system-x86_64 -enable-kvm -cpu host -m 1536 -kernel /boot/vmlinuz-6.6.21-gentoo -initrd /tmp/initramfs-tcc.cpio.xz -append 'init=/init console=ttyS0 panic=1' -nographic -no-reboot diff --git a/init.sh b/init.sh @@ -45,6 +45,20 @@ build_bmake() { || die "failed to install mk files" } +build_bzip2() { + cd /bzip2-*/ + bmake -f Makefile-libbz2_so CC=$CC || die + ln -s libbz2.so.1.0.8 libbz2.so + bmake -f Makefile bzip2 CC=$CC || die + + ln libbz2.so.1.0.8 /lib/libbz2.so.1.0.8 + ln -s libbz2.so.1.0.8 /lib/libbz2.so + ln -s libbz2.so.1.0.8 /lib/libbz2.so.1.0 + ln bzip2 /bin/bzip2 + ln -s bzip2 /bin/bunzip2 + ln -s bzip2 /bin/bzcat +} + set -ex -o pipefail export CC=tcc @@ -84,6 +98,8 @@ chmod +x /bin/hostname build_bmake +build_bzip2 + cd / rescueshell diff --git a/make-initrd.sh b/make-initrd.sh @@ -12,6 +12,7 @@ tarballs=" byacc-20240109.tgz nawk-20240422.tar.gz loksh-7.3.tar.xz + bzip2-1.0.8.tar.gz " WORKDIR="$(pwd)" name_base="initramfs-tcc" @@ -91,6 +92,9 @@ sed -i -e '1a#include <limits.h>' -e 's;_PW_NAME_LEN;LOGIN_NAME_MAX;' loksh-*/ma gen_loksh_tcc_h > loksh_tcc.h +sed -i -e 's;bzip2-shared;bzip2;' bzip2-*/Makefile-libbz2_so || die "Failed patching /bzip2-*/Makefile-libbz2_so" +sed -i -e 's;all: libbz2.a;all: libbz2.so;' -e 's;bzip2: libbz2.a;bzip2: libbz2.so;' bzip2-*/Makefile || die "Failed patching /bzip2-*/Makefile" + deblob -n find . -print0 | cpio --null -o --format=newc | xz -9 --check=crc32 > "${out_base}.cpio.xz"