vinix-ports / busybox / PKGBUILD.vile
70 lines · 66 sloc · 3.32 KB · 2710d21a3af42b3548ffcaa479967cb7d934af55
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, 2,
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"],
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 ; musl supplies libc headers. Import only the Linux kernel UAPI from
39 ; the x86-64 builder until those headers have their own Vinix package.
40 run("mkdir", "uapi")
41 run("ln", "-s", "/usr/include/linux", "uapi/linux")
42 run("ln", "-s", "/usr/include/asm-generic", "uapi/asm-generic")
43 if file-exists?("/usr/include/asm") {
44 run("ln", "-s", "/usr/include/asm", "uapi/asm")
45 } else {
46 run("ln", "-s", "/usr/include/x86_64-linux-gnu/asm", "uapi/asm")
47 }
48 },
49 #:build, fn() {
50 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
51 "make", "-C", "busybox-1.38.0", target-cc, "EXTRA_CFLAGS=-I../uapi", "busybox")
52 },
53 #:check, fn() {
54 ; Check what the final executable actually linked, and the dependencies
55 ; emitted when compiling ash. Keep the proof in the build transcript.
56 for-each(fn(file) {
57 run("grep", "-Fx", string-append("LOAD ../vinix-sysroot/usr/lib/", file),
58 "busybox-1.38.0/busybox_unstripped.map")
59 }, list("Scrt1.o", "crti.o", "libc.a", "crtn.o"))
60 run("grep", "-F", "../vinix-sysroot/usr/include/stdio.h", "busybox-1.38.0/shell/.ash.o.cmd")
61 run("busybox-1.38.0/busybox", "ash", "-n", "/dev/null")
62 run("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, "EXTRA_CFLAGS=-I../uapi",
67 string-append("CONFIG_PREFIX=", pkgdir()), "install")
68 run("install", "-Dm644", "busybox-1.38.0/LICENSE",
69 string-append(pkgdir(), "/usr/share/licenses/busybox/LICENSE"))
70 })
71