Build scanelf and the musl utilities used by the base filesystem
@@ -0,0 +1,44 @@
1+selected := get-environment-variable("VPAC_TARGET_ARCH")
2+arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
3+
4+defpkgbuild(musl-utils,
5+ #:pkgname, "musl-utils",
6+ #:pkgver, "1.2.6",
7+ #:pkgrel, 1,
8+ #:pkgdesc, "System configuration, account, encoding and shared library tools for musl",
9+ #:arch, [#:x86-64, #:aarch64],
10+ #:url, "https://musl.libc.org/",
11+ #:license, "MIT AND BSD-2-Clause AND GPL-2.0-or-later",
12+ #:depends, ["musl", "busybox", "scanelf"],
13+ #:source, ["https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/getent.c",
14+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/getconf.c",
15+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/iconv.c",
16+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/musl/ldconfig",
17+ "ldd.in", "check.vsh"],
18+ #:sha256sums, ["b25f32d306d542246e9358ef65cd67c12b3e3a77656bc467853d3b0c76b5fbbd",
19+ "d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c",
20+ "f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7",
21+ "7065021e04a5060957b5c6907af671a7028230d91927fb0c25892cadd9312b7c",
22+ "8424ae8c0513846b9f8ee1948f8e7f26cde7dd63a83f3513e66c3e59c204e615",
23+ "b79e9cc82736849ea8696f34b985b3b2d4046caace81ce676dde0573e19efaf4"],
24+ #:build, fn() {
25+ for-each(fn(name) {
26+ run("vinix-cc", "-Os", string-append(name, ".c"), "-o", name)
27+ }, list("getent", "getconf", "iconv"))
28+ run("cp", "ldd.in", "ldd")
29+ run("sed", "-i", string-append("s/@ARCH@/", arch, "/"), "ldd")
30+ },
31+ #:check, fn() {
32+ run("v", "run", "check.vsh")
33+ run("grep", "-F", string-append("/lib/ld-musl-", arch, ".so.1 --list"), "ldd")
34+ run("sh", "-n", "ldconfig")
35+ },
36+ #:package, fn() {
37+ for-each(fn(name) {
38+ run("install", "-Dm755", name, string-append(pkgdir(), "/usr/bin/", name))
39+ }, list("getent", "getconf", "iconv", "ldd"))
40+ run("install", "-Dm755", "ldconfig", string-append(pkgdir(), "/sbin/ldconfig"))
41+ for-each(fn(file) {
42+ run("install", "-Dm644", file, string-append(pkgdir(), "/usr/share/licenses/musl-utils/", file))
43+ }, list("getent.c", "getconf.c", "iconv.c"))
44+ })
@@ -0,0 +1,18 @@
1+import os
2+
3+fn run_tool(args []string) !string {
4+ mut cmd := ['vinix-run']
5+ cmd << args
6+ result := os.exec(cmd)
7+ if result.exit_code != 0 {
8+ return error('${args[0]}: ${result.output}')
9+ }
10+ return result.output
11+}
12+
13+page_size := run_tool(['./getconf', 'PAGESIZE'])!.trim_space().int()
14+assert page_size > 0 && (page_size & (page_size - 1)) == 0
15+passwd := run_tool(['./getent', 'passwd', '0'])!.trim_space().split(':')
16+assert passwd.len >= 4 && passwd[2] == '0'
17+os.write_file_array('latin1.txt', [u8(0xe9)])!
18+assert run_tool(['./iconv', '-f', 'ISO-8859-1', '-t', 'UTF-8', 'latin1.txt'])! == 'é'
@@ -0,0 +1,2 @@
1+#!/bin/sh
2+exec /lib/ld-musl-@ARCH@.so.1 --list "$@"
@@ -0,0 +1,26 @@
1+; The release minirootfs uses the scanelf output of pax-utils.
2+defpkgbuild(scanelf,
3+ #:pkgname, "scanelf",
4+ #:pkgver, "1.3.8",
5+ #:pkgrel, 1,
6+ #:pkgdesc, "Inspect ELF metadata and shared library names",
7+ #:arch, [#:x86-64, #:aarch64],
8+ #:url, "https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities",
9+ #:license, "GPL-2.0-only",
10+ #:depends, ["musl"],
11+ #:makedepends, ["linux-headers"],
12+ #:source, ["https://dev.gentoo.org/~sam/distfiles/app-misc/pax-utils/pax-utils-1.3.8.tar.xz"],
13+ #:sha256sums, ["12a168d1aeae2626efdbde3979da88a60ca80bb38e1db565e95ee441ff1d5a0c"],
14+ #:build, fn() {
15+ run("vinix-meson", "pax-utils-1.3.8", "build", "-Dlddtree_implementation=none",
16+ "-Duse_seccomp=false", "-Duse_libcap=disabled", "-Dbuild_manpages=disabled", "-Dtests=false")
17+ run("meson", "compile", "-C", "build", "-j2", "scanelf")
18+ },
19+ #:check, fn() {
20+ run("vinix-run", "build/scanelf", "-n", "-i", "build/scanelf")
21+ },
22+ #:package, fn() {
23+ run("install", "-Dm755", "build/scanelf", string-append(pkgdir(), "/usr/bin/scanelf"))
24+ run("install", "-Dm644", "pax-utils-1.3.8/man/scanelf.1", string-append(pkgdir(), "/usr/share/man/man1/scanelf.1"))
25+ run("install", "-Dm644", "pax-utils-1.3.8/COPYING", string-append(pkgdir(), "/usr/share/licenses/scanelf/COPYING"))
26+ })