vinix-ports / busybox / PKGBUILD.vile
61 lines · 57 sloc · 2.91 KB
Raw
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.
3target-cc := "CC=gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs"
4
5defpkgbuild(busybox,
6 #:pkgname, "busybox",
7 #:pkgver, "1.38.0",
8 #:pkgrel, 3,
9 #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix",
10 #:arch, [#:x86-64],
11 #:url, "https://busybox.net/",
12 #:license, "GPL-2.0-only",
13 #:makedepends, ["musl=1.2.6-1", "linux-headers"],
14 #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", "bootstrap.config"],
15 #:sha256sums, ["34f9ea6ff8636f2c9241153b9114eefa9e65674a45318ae1ef95bb5f31c53bb2",
16 "9d8c4fb8ebad6ddbf058e151d807a90ce7687643626e0e4b5357e587718dec00"],
17
18 #:prepare, fn() {
19 root := get-environment-variable("VPAC_MAKEPKG_ROOT")
20 if not(string?(root)) {
21 display("Set VPAC_MAKEPKG_ROOT to the absolute path of the installed Vinix build root.")
22 newline()
23 run("false")
24 }
25 run("test", "-f", string-append(root, "/usr/lib/musl-gcc-sysroot.specs"))
26 run("ln", "-s", root, "vinix-sysroot")
27
28 ; Start with everything disabled. BusyBox allnoconfig overrides explicit
29 ; KCONFIG_ALLCONFIG selections, so enable the selected options afterwards.
30 run("make", "-C", "busybox-1.38.0", "allnoconfig")
31 run("cp", "bootstrap.config", "enable.sed")
32 run("sed", "-i", "-e", "/^#/d", "-e",
33 "s/^\\(CONFIG_[A-Z0-9_]*\\)=y$/s|^# \\1 is not set$|\\1=y|/", "enable.sed")
34 run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig")
35 run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig")
36 run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig")
37
38 },
39 #:build, fn() {
40 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
41 "make", "-C", "busybox-1.38.0", target-cc, "busybox")
42 },
43 #:check, fn() {
44 ; Check what the final executable actually linked, and the dependencies
45 ; emitted when compiling ash. Keep the proof in the build transcript.
46 for-each(fn(file) {
47 run("grep", "-Fx", string-append("LOAD ../vinix-sysroot/usr/lib/", file),
48 "busybox-1.38.0/busybox_unstripped.map")
49 }, list("Scrt1.o", "crti.o", "libc.a", "crtn.o"))
50 run("grep", "-F", "../vinix-sysroot/usr/include/stdio.h", "busybox-1.38.0/shell/.ash.o.cmd")
51 run("grep", "-F", "../vinix-sysroot/usr/include/linux/vt.h", "busybox-1.38.0/init/.init.o.cmd")
52 run("busybox-1.38.0/busybox", "ash", "-n", "/dev/null")
53 run("busybox-1.38.0/busybox", "true")
54 },
55 #:package, fn() {
56 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
57 "make", "-C", "busybox-1.38.0", target-cc,
58 string-append("CONFIG_PREFIX=", pkgdir()), "install")
59 run("install", "-Dm644", "busybox-1.38.0/LICENSE",
60 string-append(pkgdir(), "/usr/share/licenses/busybox/LICENSE"))
61 })
62