logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://hacktivis.me/git/bootstrap-initrd.git
commit: ed3ccd34f4b87d726d51086d091eae2b84c942a7
parent 51ed41991cf9dc50c4c1468907e2f8396259b9af
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 16 May 2024 04:45:53 +0200

Switch to OpenBSD yacc

Diffstat:

MREADME.md8+++++---
Mdistfiles.SHA512SUM2+-
Mfetch.sh3++-
Minit.sh13+++++++++++--
Mmake-root.sh15+++++++++++++--
5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -51,13 +51,15 @@ Meanwhile: - mksh: ./Build.sh, so needs an existing shell - AT&T ksh: Way too big to even try, might as well try Perl -### yacc -The reference implementation of yacc, only needs a C Compiler to build. (Unlike byacc and bison) +### OpenBSD yacc +Portable version done by Dr. Brian Robert Callahan aka ibara, of OpenBSD. + +Uses a BSD-style configure script, trivial to diff between versions and adjust hardcoded compiler flags (no utilities to run said script yet). Meanwhile: - bison: autoconf, way too early - byacc: autoconf -- <https://github.com/ibara/yacc/>: configure script but generated Makefile is simple enough to be a single command with few hardcoded defines +- [yacc from compilertools.net](https://web.archive.org/web/20220511161030/http://dinosaur.compilertools.net/): Domain expired years ago and turns out Gentoo was the only distro still providing it ### utils-std My own software, which explicitly allows to bootstrap with an incomplete POSIX environment such as this one. diff --git a/distfiles.SHA512SUM b/distfiles.SHA512SUM @@ -72,5 +72,5 @@ b89b489fbee7c19a21175ad61168d250856801175fa000261b35202312148ee8e7b6cb1994d04250 ccb62313eaf2fb149ba3a372ab6a0cccde2fc23e2193843f457b9ed181b832fddb34fe23b18ec3005aefb7d1137fcb440fb57462b9414734f3b1a90183d3db36 distfiles/tiny-curl-8.4.0.tar.gz 4c5fb10c864d748b02e4da01c0e23bca72866755c1aeaa97d872a26454228cb5bb134f91cc1b883951eab99360ce44acd994ae69a3c1bde23007259b5da25f42 distfiles/utils-std-8266037.tar.gz 149f980338bea3d66de1ff5994b2b236ae1773135eda68b62b009df0c9dcdf5467f8cb2c06da95a71b6556d60bd3d21f475feced34d5dfdb80ee95416a2f9737 distfiles/xz-5.4.2.tar.gz -6adb51c5f07e8084a86688589f52d9eee0183fb4d77508e36621a6b0ba91a5c4195feb87db3401ec69560554f71f2f6984dec01266e41e0fd54fa72ef1780e80 distfiles/yacc-1.9.1.tar.Z +e186a8fc01871414574fd5e90e8ce87a45bcf40aa0d7276bd90a301ee8c312be3a0adb580fc2c8b6653fbeeda1ce4dfdd078095a5fc77e70263e5e940414dc54 distfiles/yacc-oyacc-6.6.tar.gz 580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f distfiles/zlib-1.3.1.tar.gz diff --git a/fetch.sh b/fetch.sh @@ -3,7 +3,6 @@ URLS=" https://hacktivis.me/releases/utils-std/utils-std-8266037.tar.gz https://www.crufty.net/ftp/pub/sjg/bmake-20240508.tar.gz https://www.crufty.net/ftp/pub/sjg/mk-20240408.tar.gz - https://distfiles.gentoo.org/distfiles/ec/yacc-1.9.1.tar.Z https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz https://zlib.net/zlib-1.3.1.tar.gz https://www.zlib.net/pigz/pigz-2.8.tar.gz @@ -61,6 +60,8 @@ test -e nawk-20240422.tar.gz || curl ${CURL_OPTS} -o nawk-20240422.tar.gz https: test -e loksh-7.3.tar.gz || curl ${CURL_OPTS} -o loksh-7.3.tar.gz https://github.com/dimkr/loksh/archive/refs/tags/7.3.tar.gz test -e lolibc-f6e9da7.tar.gz || curl ${CURL_OPTS} -o lolibc-f6e9da7.tar.gz https://github.com/dimkr/lolibc/archive/f6e9da7.tar.gz +test -e yacc-oyacc-6.6.tar.gz || curl ${CURL_OPTS} -o yacc-oyacc-6.6.tar.gz https://github.com/ibara/yacc/archive/refs/tags/oyacc-6.6.tar.gz + test -e gettext-tiny-0.3.2.tar.gz || curl ${CURL_OPTS} -o gettext-tiny-0.3.2.tar.gz https://github.com/sabotage-linux/gettext-tiny/archive/refs/tags/v0.3.2.tar.gz # suckless.org doesn't provides snapshots of sbase (yet?) diff --git a/init.sh b/init.sh @@ -121,13 +121,22 @@ build_sbase_sed() { $CC -D_DEFAULT_SOURCE -D_NETBSD_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_FILE_OFFSET_BITS=64 -Os -o /bin/sed sed.c libutil/*.c libutf/*.c } +build_oyacc() { + cd /yacc-oyacc-*/ + + # config.h wrote in make-root.sh due to lack of cat + + $CC $CFLAGS \ + -D_GNU_SOURCE -D__unused= \ + -o /bin/yacc *.c +} + set -ex -o pipefail export CC=tcc export CFLAGS="-Os -Wall -Wextra" -cd /yacc-*/ -$CC $CFLAGS -o /bin/yacc *.c +build_oyacc cd /utils-std-*/ M4="true" loksh ./makeless.sh diff --git a/make-root.sh b/make-root.sh @@ -6,10 +6,10 @@ tarballs=" lolibc-f6e9da7.tar.gz loksh-7.3.tar.gz + yacc-oyacc-6.6.tar.gz utils-std-8266037.tar.gz mk-20240408.tar.gz bmake-20240508.tar.gz - yacc-1.9.1.tar.Z nawk-20240422.tar.gz bzip2-1.0.8.tar.gz zlib-1.3.1.tar.gz @@ -88,7 +88,6 @@ cd "$out_base" || die "Failed: cd $out_base" for i in $tarballs; do tar xof "${WORKDIR}/distfiles/$i" || die "Failed extracting $i" done -rm yacc-1.9.1/yacc || die for i in $distfiles; do cp "${WORKDIR}/distfiles/$i" ./ || die "Failed copying $i" @@ -137,6 +136,18 @@ sed -i -e '1a#include <limits.h>' -e 's;_PW_NAME_LEN;LOGIN_NAME_MAX;' loksh-*/ma gen_loksh_tcc_h > loksh_tcc.h +oyacc=$(echo ./yacc-oyacc-*/) +cat >"${oyacc}/config.h" <<EOF +// __dead and __dead2 are absent in musl +#define __dead __attribute__((__no_return__)) + +// HAVE_PROGNAME: Absent in musl +#define HAVE_ASPRINTF +// HAVE_PLEDGE: Absent in musl +#define HAVE_REALLOCARRAY +#define HAVE_STRLCPY +EOF + 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"