BusyBox: package the release applets and bootstrap init separately
@@ -1,9 +1,11 @@
11# Vinix ports
22
33Each port contains a native vpac recipe and its local build inputs. The
4-bootstrap packages build Vinix's patched musl and a static BusyBox. BusyBox
5-owns the shell, init and applet symlinks. See [the release profiles](PROFILES.md)
6-for the Alpine components that need Vinix equivalents on each architecture.
4+bootstrap packages build Vinix's patched musl and a static BusyBox. The
5+`busybox-bootstrap` package supplies the initial shell, init and utilities.
6+The release `busybox` package uses `ssl-client` for HTTPS. Bootstrap images
7+using that release package install `busybox-init` to run it as PID 1.
8+See [the release profiles](PROFILES.md) for each architecture.
79The [bootstrap order](BOOTSTRAP.md) lists the toolchain, networking and desktop prerequisites.
810
911To reproduce the v3.21 input inventory for either release, compile the
@@ -33,7 +35,7 @@ install both into an empty SDK through vpac and compile BusyBox against it.
3335
3436```sh
3537work=$(mktemp -d)
36-cp -R musl linux-headers busybox "$work/"
38+cp -R musl linux-headers busybox-bootstrap "$work/"
3739export MAKEFLAGS=-j2 CMAKE_BUILD_PARALLEL_LEVEL=2
3840v -o "$work/feed" tests/feed.v
3941v -o "$work/vinix-cc" tools/vinix-cc.v
@@ -47,7 +49,7 @@ vpac --native-build "$work/linux-headers/PKGBUILD.vile" "$work/headers.txt"
49export VPAC_MAKEPKG_ROOT="$work/sdk/root"
150export VPAC_MAKEPKG_DB="$work/sdk/db"
251export VINIX_SYSROOT="$VPAC_MAKEPKG_ROOT"
3-vpac --native-build "$work/busybox/PKGBUILD.vile" "$work/busybox.txt"
52+vpac --native-build "$work/busybox-bootstrap/PKGBUILD.vile" "$work/busybox.txt"
453```
554
655The manifests contain the paths to the completed archives. Musl includes its
@@ -57,7 +59,7 @@ To install both packages by name into a new root, publish a new test feed:
5759
5860```sh
5961"$work/feed" publish "$work/test-keys" "$work/repo" x86_64 "$(cat "$work/musl.txt")" "$(cat "$work/busybox.txt")"
60-"$work/feed" install "$work/test-keys" "$work/repo" x86_64 "$work/client" musl busybox
62+"$work/feed" install "$work/test-keys" "$work/repo" x86_64 "$work/client" musl busybox-bootstrap
6163installed_root="$work/client/root"
6264v -o "$work/installed-root" tests/installed-root.v
6365"$work/installed-root" x86_64 "$work/client"
@@ -0,0 +1,70 @@
1+; Kbuild runs the target compiler from the BusyBox source directory. The
2+; relative link keeps the sysroot's path out of make's split command words.
3+selected-arch := get-environment-variable("VPAC_TARGET_ARCH")
4+host-arch := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
5+target-arch := if string?(selected-arch) { selected-arch } else { host-arch }
6+musl-build-dep := if string=?(target-arch, "aarch64") { "musl>=1.2.6-4" } else { "musl>=1.2.6-3" }
7+cross-prefix := get-environment-variable("CROSS_COMPILE")
8+prefix := if string?(cross-prefix) { cross-prefix } else { "" }
9+target-cc := string-append("CC=", prefix, "gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs")
10+run-target := if string=?(host-arch, target-arch) { list() } else { list(string-append("qemu-", target-arch)) }
11+
12+defpkgbuild(busybox-bootstrap,
13+ #:pkgname, "busybox-bootstrap",
14+ #:pkgver, "1.38.0",
15+ #:pkgrel, 1,
16+ #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix",
17+ #:arch, [#:x86-64, #:aarch64],
18+ #:url, "https://busybox.net/",
19+ #:license, "GPL-2.0-only",
20+ #:conflicts, ["busybox"],
21+ #:makedepends, [musl-build-dep, "linux-headers"],
22+ #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", "bootstrap.config"],
23+ #:sha256sums, ["34f9ea6ff8636f2c9241153b9114eefa9e65674a45318ae1ef95bb5f31c53bb2",
24+ "9d8c4fb8ebad6ddbf058e151d807a90ce7687643626e0e4b5357e587718dec00"],
25+
26+ #:prepare, fn() {
27+ root := get-environment-variable("VPAC_MAKEPKG_ROOT")
28+ if not(string?(root)) {
29+ display("Set VPAC_MAKEPKG_ROOT to the absolute path of the installed Vinix build root.")
30+ newline()
31+ run("false")
32+ }
33+ run("test", "-f", string-append(root, "/usr/lib/musl-gcc-sysroot.specs"))
34+ run("ln", "-s", root, "vinix-sysroot")
35+
36+ ; Start with everything disabled. BusyBox allnoconfig overrides explicit
37+ ; KCONFIG_ALLCONFIG selections, so enable the selected options afterwards.
38+ run("make", "-C", "busybox-1.38.0", "allnoconfig")
39+ run("cp", "bootstrap.config", "enable.sed")
40+ run("sed", "-i", "-e", "/^#/d", "-e",
41+ "s/^\\(CONFIG_[A-Z0-9_]*\\)=y$/s|^# \\1 is not set$|\\1=y|/", "enable.sed")
42+ run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig")
43+ run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig")
44+ run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig")
45+ run("sed", "-i", "s|^CONFIG_UNAME_OSNAME=.*|CONFIG_UNAME_OSNAME=\"Vinix\"|", "busybox-1.38.0/.config")
46+ run("grep", "-Fx", "CONFIG_UNAME_OSNAME=\"Vinix\"", "busybox-1.38.0/.config")
47+ },
48+ #:build, fn() {
49+ run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
50+ "make", "-C", "busybox-1.38.0", target-cc, "busybox")
51+ },
52+ #:check, fn() {
53+ ; Check what the final executable actually linked, and the dependencies
54+ ; emitted when compiling ash. Keep the proof in the build transcript.
55+ for-each(fn(file) {
56+ run("grep", "-Fx", string-append("LOAD ../vinix-sysroot/usr/lib/", file),
57+ "busybox-1.38.0/busybox_unstripped.map")
58+ }, list("Scrt1.o", "crti.o", "libc.a", "crtn.o"))
59+ run("grep", "-F", "../vinix-sysroot/usr/include/stdio.h", "busybox-1.38.0/shell/.ash.o.cmd")
60+ run("grep", "-F", "../vinix-sysroot/usr/include/linux/vt.h", "busybox-1.38.0/init/.init.o.cmd")
61+ apply(run, append(run-target, list("busybox-1.38.0/busybox", "ash", "-n", "/dev/null")))
62+ apply(run, append(run-target, list("busybox-1.38.0/busybox", "true")))
63+ },
64+ #:package, fn() {
65+ run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
66+ "make", "-C", "busybox-1.38.0", target-cc,
67+ string-append("CONFIG_PREFIX=", pkgdir()), "install")
68+ run("install", "-Dm644", "busybox-1.38.0/LICENSE",
69+ string-append(pkgdir(), "/usr/share/licenses/busybox-bootstrap/LICENSE"))
70+ })
@@ -0,0 +1,22 @@
1+selected := get-environment-variable("VPAC_TARGET_ARCH")
2+host := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
3+arch := if string?(selected) { selected } else { host }
4+runner := if string=?(host, arch) { list() } else { list(string-append("qemu-", arch)) }
5+
6+defpkgbuild(busybox-init,
7+ #:pkgname, "busybox-init",
8+ #:pkgver, "1.38.0",
9+ #:pkgrel, 1,
10+ #:pkgdesc, "BusyBox PID 1 for Vinix bootstrap images",
11+ #:arch, [#:any],
12+ #:license, "GPL-2.0-only",
13+ #:url, "https://busybox.net/",
14+ #:depends, ["busybox=1.38.0-5"],
15+ #:check, fn() {
16+ binary := string-append(get-environment-variable("VPAC_MAKEPKG_ROOT"), "/bin/busybox")
17+ apply(run, append(runner, list(binary, "--help", "init")))
18+ },
19+ #:package, fn() {
20+ run("install", "-d", string-append(pkgdir(), "/sbin"))
21+ run("ln", "-s", "../bin/busybox", string-append(pkgdir(), "/sbin/init"))
22+ })
@@ -3,23 +3,37 @@
33selected-arch := get-environment-variable("VPAC_TARGET_ARCH")
44host-arch := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
55target-arch := if string?(selected-arch) { selected-arch } else { host-arch }
6+musl-build-dep := if string=?(target-arch, "aarch64") { "musl>=1.2.6-4" } else { "musl>=1.2.6-1" }
67cross-prefix := get-environment-variable("CROSS_COMPILE")
78prefix := if string?(cross-prefix) { cross-prefix } else { "" }
89target-cc := string-append("CC=", prefix, "gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs")
910run-target := if string=?(host-arch, target-arch) { list() } else { list(string-append("qemu-", target-arch)) }
11+; Vinix's published Alpine 3.21 miniroot uses this exact aports revision.
12+aports := "https://raw.githubusercontent.com/alpinelinux/aports/284d827a2793963e6dcf88324bd1eb81adff579c/main/busybox/"
1013
1114defpkgbuild(busybox,
1215 #:pkgname, "busybox",
1316 #:pkgver, "1.38.0",
14- #:pkgrel, 4,
15- #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix",
17+ #:pkgrel, 5,
18+ #:pkgdesc, "Static shell and Unix utilities for the Vinix release",
1619 #:arch, [#:x86-64, #:aarch64],
1720 #:url, "https://busybox.net/",
1821 #:license, "GPL-2.0-only",
19- #:makedepends, ["musl=1.2.6-1", "linux-headers"],
20- #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", "bootstrap.config"],
22+ #:depends, ["ssl-client"],
23+ #:makedepends, [musl-build-dep, "linux-headers"],
24+ #:backup, ["etc/securetty", "etc/udhcpc/udhcpc.conf", "etc/logrotate.d/acpid"],
25+ #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", string-append(aports, "busyboxconfig"),
26+ string-append(aports, "dad.if-up"), string-append(aports, "acpid.logrotate"),
27+ string-append(aports, "udhcpc.conf"), string-append(aports, "securetty"), string-append(aports, "default.script"),
28+ string-append(aports, "0009-properly-fix-wget-https-support.patch")],
2129 #:sha256sums, ["34f9ea6ff8636f2c9241153b9114eefa9e65674a45318ae1ef95bb5f31c53bb2",
22- "9d8c4fb8ebad6ddbf058e151d807a90ce7687643626e0e4b5357e587718dec00"],
30+ "72a2f2316d06fac2606cc9642018fc7377879c0b0241fc76aa6c9239c810bdf7",
31+ "2fd20d1bc67d9ee711990002b24f156635a73f56b8935b2f76592938817fa4e7",
32+ "d608a3b7715886b5735def0cc50a6359fd364fac2e0e0a459c588c04be471031",
33+ "5b372209e01cda07c87b8afa6d1ab3d7e8daf18a1f2332d744203a6dc289eb1a",
34+ "713fcea5109728883b9147e822429133fcc8b5e253afd3c2a197b10cd0bc3b4d",
35+ "c4e5a7c4783a7a73dec48dee009ee687015d2de7ff86b269679b95bef2c60e13",
36+ "4be0a9d28acaa4c117c694a4816fad4a2d3f78e224676dfc2d1407d3ad0dc17a"],
2337
2438 #:prepare, fn() {
2539 root := get-environment-variable("VPAC_MAKEPKG_ROOT")
@@ -31,17 +45,17 @@ defpkgbuild(busybox,
3145 run("test", "-f", string-append(root, "/usr/lib/musl-gcc-sysroot.specs"))
3246 run("ln", "-s", root, "vinix-sysroot")
3347
34- ; Start with everything disabled. BusyBox allnoconfig overrides explicit
35- ; KCONFIG_ALLCONFIG selections, so enable the selected options afterwards.
36- run("make", "-C", "busybox-1.38.0", "allnoconfig")
37- run("cp", "bootstrap.config", "enable.sed")
38- run("sed", "-i", "-e", "/^#/d", "-e",
39- "s/^\\(CONFIG_[A-Z0-9_]*\\)=y$/s|^# \\1 is not set$|\\1=y|/", "enable.sed")
40- run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig")
41- run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig")
48+ run("patch", "--batch", "--fuzz=0", "-p1", "-d", "busybox-1.38.0", "-i", "../0009-properly-fix-wget-https-support.patch")
49+ run("cp", "busyboxconfig", "busybox-1.38.0/vinix.defconfig")
50+ run("sed", "-i", "-e", "s|^# CONFIG_STATIC is not set$|CONFIG_STATIC=y|",
51+ "-e", "s|^# CONFIG_INSTALL_APPLET_SYMLINKS is not set$|CONFIG_INSTALL_APPLET_SYMLINKS=y|",
52+ "-e", "s|^CONFIG_INSTALL_APPLET_DONT=y$|# CONFIG_INSTALL_APPLET_DONT is not set|",
53+ "-e", "$a # CONFIG_SSL_SERVER is not set",
54+ "-e", "s|^CONFIG_UNAME_OSNAME=.*|CONFIG_UNAME_OSNAME=\"Vinix\"|", "busybox-1.38.0/vinix.defconfig")
4255 run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig")
43- run("sed", "-i", "s|^CONFIG_UNAME_OSNAME=.*|CONFIG_UNAME_OSNAME=\"Vinix\"|", "busybox-1.38.0/.config")
44- run("grep", "-Fx", "CONFIG_UNAME_OSNAME=\"Vinix\"", "busybox-1.38.0/.config")
56+ for-each(fn(option) { run("grep", "-Fx", option, "busybox-1.38.0/.config") },
57+ list("CONFIG_UNAME_OSNAME=\"Vinix\"", "CONFIG_STATIC=y", "CONFIG_RUN_PARTS=y", "CONFIG_FEATURE_USE_INITTAB=y",
58+ "CONFIG_FEATURE_WGET_HTTPS=y", "# CONFIG_SSL_CLIENT is not set", "# CONFIG_TLS is not set"))
4559 },
4660 #:build, fn() {
4761 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
@@ -63,6 +77,46 @@ defpkgbuild(busybox,
6377 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
6478 "make", "-C", "busybox-1.38.0", target-cc,
6579 string-append("CONFIG_PREFIX=", pkgdir()), "install")
80+ run("test", "-L", string-append(pkgdir(), "/bin/run-parts"))
81+ run("mkdir", "empty-hooks")
82+ apply(run, append(run-target, list(string-append(pkgdir(), "/bin/run-parts"), "--test", "empty-hooks")))
83+ run("install", "-Dm644", "busybox-1.38.0/busybox.links", string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
84+ run("sed", "-i", "s|^/||", string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
85+ ; The desktop supplies its own PID 1. Bootstrap images install busybox-init.
86+ run("rm", string-append(pkgdir(), "/sbin/init"))
87+ run("sed", "-i", "\\|^sbin/init$|d", string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
88+ ; The release's bzip2, ncurses, binutils, xz and vim packages own these commands.
89+ ; The corresponding applets remain available through /bin/busybox.
90+ for-each(fn(name) {
91+ path := string-append("usr/bin/", name)
92+ run("test", "-L", string-append(pkgdir(), "/", path))
93+ run("rm", string-append(pkgdir(), "/", path))
94+ run("sed", "-i", string-append("\\|^", path, "$|d"), string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
95+ }, list("bunzip2", "bzcat", "bzip2", "clear", "reset", "strings", "lzcat", "lzma", "unlzma", "unxz", "xzcat", "xxd"))
96+ ; Alpine 3.21's nologin, cpio and vi applets use these paths.
97+ run("ln", "-s", "../bin/busybox", string-append(pkgdir(), "/sbin/nologin"))
98+ for-each(fn(name) {
99+ run("ln", "-s", "../../bin/busybox", string-append(pkgdir(), "/usr/bin/", name))
100+ }, list("cpio", "vi"))
101+ for-each(fn(path) {
102+ run("sed", "-i", string-append("$a ", path), string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
103+ }, list("sbin/nologin", "usr/bin/cpio", "usr/bin/vi"))
104+ ; The published ARM root also exposes these applets under /bin.
105+ if string=?(target-arch, "aarch64") {
106+ for-each(fn(name) {
107+ run("test", "-L", string-append(pkgdir(), "/usr/bin/", name))
108+ run("ln", "-s", "busybox", string-append(pkgdir(), "/bin/", name))
109+ run("sed", "-i", string-append("$a bin/", name), string-append(pkgdir(), "/etc/busybox-paths.d/busybox"))
110+ }, list("awk", "basename", "cmp", "comm", "cut", "dirname", "du", "env", "expr", "find", "head", "id",
111+ "printf", "readlink", "seq", "sort", "tail", "tee", "tr", "uniq", "wc", "which", "whoami", "xargs"))
112+ }
113+ run("install", "-Dm644", "securetty", string-append(pkgdir(), "/etc/securetty"))
114+ run("install", "-Dm644", "udhcpc.conf", string-append(pkgdir(), "/etc/udhcpc/udhcpc.conf"))
115+ run("install", "-Dm644", "acpid.logrotate", string-append(pkgdir(), "/etc/logrotate.d/acpid"))
116+ run("install", "-Dm755", "default.script", string-append(pkgdir(), "/usr/share/udhcpc/default.script"))
117+ for-each(fn(dir) { run("install", "-d", string-append(pkgdir(), "/etc/network/", dir)) },
118+ list("if-down.d", "if-post-down.d", "if-pre-down.d", "if-up.d", "if-post-up.d", "if-pre-up.d"))
119+ run("install", "-Dm775", "dad.if-up", string-append(pkgdir(), "/etc/network/if-up.d/dad"))
66120 run("install", "-Dm644", "busybox-1.38.0/LICENSE",
67121 string-append(pkgdir(), "/usr/share/licenses/busybox/LICENSE"))
68122 })
@@ -0,0 +1,32 @@
1+#!/bin/sh
2+# BusyBox init runs this from the signed release package root.
3+set -eu
4+export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C
5+trap '/sbin/poweroff -f' EXIT
6+
7+test "$(uname -s)" = Vinix
8+test "$(uname -o)" = Vinix
9+machine=$(uname -m)
10+count=0
11+while IFS= read -r applet; do
12+ test -L "/$applet"
13+ test "$(readlink -f "/$applet")" = /bin/busybox
14+ count=$((count + 1))
15+done </etc/busybox-paths.d/busybox
16+test "$count" -gt 280
17+test -x /usr/bin/ssl_client
18+
19+mkdir -p /tmp/busybox-release/hooks
20+cd /tmp/busybox-release
21+printf '#!/bin/sh\necho ran > /tmp/busybox-release/result\n' >hooks/01-check
22+chmod 755 hooks/01-check
23+test "$(/bin/run-parts --test hooks)" = hooks/01-check
24+/bin/run-parts hooks
25+test "$(cat result)" = ran
26+
27+if [ "$machine" = aarch64 ]; then
28+ test "$(/bin/env /bin/awk 'BEGIN { print 6 * 7 }')" = 42
29+ test "$(/bin/find hooks -name 01-check)" = hooks/01-check
30+fi
31+echo "Vinix $machine verified $count installed BusyBox links and ran a hook"
32+echo 'VPAC FIXTURE GUEST PASS'