| 1 | defpkgbuild(busybox, |
| 2 | #:pkgname, "busybox", |
| 3 | #:pkgver, "1.38.0", |
| 4 | #:pkgrel, 1, |
| 5 | #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix", |
| 6 | #:arch, [#:x86-64], |
| 7 | #:url, "https://busybox.net/", |
| 8 | #:license, "GPL-2.0-only", |
| 9 | #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", "bootstrap.config"], |
| 10 | #:sha256sums, ["34f9ea6ff8636f2c9241153b9114eefa9e65674a45318ae1ef95bb5f31c53bb2", |
| 11 | "9d8c4fb8ebad6ddbf058e151d807a90ce7687643626e0e4b5357e587718dec00"], |
| 12 | |
| 13 | #:prepare, fn() { |
| 14 | ; Start with everything disabled. BusyBox allnoconfig overrides explicit |
| 15 | ; KCONFIG_ALLCONFIG selections, so enable the selected options afterwards. |
| 16 | run("make", "-C", "busybox-1.38.0", "allnoconfig") |
| 17 | run("cp", "bootstrap.config", "enable.sed") |
| 18 | run("sed", "-i", "-e", "/^#/d", "-e", |
| 19 | "s/^\\(CONFIG_[A-Z0-9_]*\\)=y$/s|^# \\1 is not set$|\\1=y|/", "enable.sed") |
| 20 | run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig") |
| 21 | run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig") |
| 22 | run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig") |
| 23 | |
| 24 | ; The musl-gcc wrapper uses its own libc headers. Only the kernel UAPI |
| 25 | ; directories are needed from linux-libc-dev on the x86-64 builder. |
| 26 | run("mkdir", "uapi") |
| 27 | run("ln", "-s", "/usr/include/linux", "uapi/linux") |
| 28 | run("ln", "-s", "/usr/include/asm-generic", "uapi/asm-generic") |
| 29 | if file-exists?("/usr/include/asm") { |
| 30 | run("ln", "-s", "/usr/include/asm", "uapi/asm") |
| 31 | } else { |
| 32 | run("ln", "-s", "/usr/include/x86_64-linux-gnu/asm", "uapi/asm") |
| 33 | } |
| 34 | }, |
| 35 | #:build, fn() { |
| 36 | run("make", "-C", "busybox-1.38.0", "CC=musl-gcc", "EXTRA_CFLAGS=-I../uapi") |
| 37 | }, |
| 38 | #:check, fn() { |
| 39 | run("busybox-1.38.0/busybox", "ash", "-n", "/dev/null") |
| 40 | run("busybox-1.38.0/busybox", "true") |
| 41 | }, |
| 42 | #:package, fn() { |
| 43 | run("make", "-C", "busybox-1.38.0", "CC=musl-gcc", "EXTRA_CFLAGS=-I../uapi", |
| 44 | string-append("CONFIG_PREFIX=", pkgdir()), "install") |
| 45 | run("install", "-Dm644", "busybox-1.38.0/LICENSE", |
| 46 | string-append(pkgdir(), "/usr/share/licenses/busybox/LICENSE")) |
| 47 | }) |
| 48 | |