From 9ee21aa0b847109f8d59db54697a95c4a304285c Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 00:04:33 +0100 Subject: [PATCH] Build scanelf and the musl utilities used by the base filesystem --- musl-utils/PKGBUILD.vile | 44 ++++++++++++++++++++++++++++++++++++++++ musl-utils/check.vsh | 18 ++++++++++++++++ musl-utils/ldd.in | 2 ++ scanelf/PKGBUILD.vile | 26 ++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 musl-utils/PKGBUILD.vile create mode 100644 musl-utils/check.vsh create mode 100644 musl-utils/ldd.in create mode 100644 scanelf/PKGBUILD.vile diff --git a/musl-utils/PKGBUILD.vile b/musl-utils/PKGBUILD.vile new file mode 100644 index 0000000..e3dca08 --- /dev/null +++ b/musl-utils/PKGBUILD.vile @@ -0,0 +1,44 @@ +selected := get-environment-variable("VPAC_TARGET_ARCH") +arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" } + +defpkgbuild(musl-utils, + #:pkgname, "musl-utils", + #:pkgver, "1.2.6", + #:pkgrel, 1, + #:pkgdesc, "System configuration, account, encoding and shared library tools for musl", + #:arch, [#:x86-64, #:aarch64], + #:url, "https://musl.libc.org/", + #:license, "MIT AND BSD-2-Clause AND GPL-2.0-or-later", + #:depends, ["musl", "busybox", "scanelf"], + #:source, ["https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/getent.c", + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/getconf.c", + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/musl/iconv.c", + "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/musl/ldconfig", + "ldd.in", "check.vsh"], + #:sha256sums, ["b25f32d306d542246e9358ef65cd67c12b3e3a77656bc467853d3b0c76b5fbbd", + "d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c", + "f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7", + "7065021e04a5060957b5c6907af671a7028230d91927fb0c25892cadd9312b7c", + "8424ae8c0513846b9f8ee1948f8e7f26cde7dd63a83f3513e66c3e59c204e615", + "b79e9cc82736849ea8696f34b985b3b2d4046caace81ce676dde0573e19efaf4"], + #:build, fn() { + for-each(fn(name) { + run("vinix-cc", "-Os", string-append(name, ".c"), "-o", name) + }, list("getent", "getconf", "iconv")) + run("cp", "ldd.in", "ldd") + run("sed", "-i", string-append("s/@ARCH@/", arch, "/"), "ldd") + }, + #:check, fn() { + run("v", "run", "check.vsh") + run("grep", "-F", string-append("/lib/ld-musl-", arch, ".so.1 --list"), "ldd") + run("sh", "-n", "ldconfig") + }, + #:package, fn() { + for-each(fn(name) { + run("install", "-Dm755", name, string-append(pkgdir(), "/usr/bin/", name)) + }, list("getent", "getconf", "iconv", "ldd")) + run("install", "-Dm755", "ldconfig", string-append(pkgdir(), "/sbin/ldconfig")) + for-each(fn(file) { + run("install", "-Dm644", file, string-append(pkgdir(), "/usr/share/licenses/musl-utils/", file)) + }, list("getent.c", "getconf.c", "iconv.c")) + }) diff --git a/musl-utils/check.vsh b/musl-utils/check.vsh new file mode 100644 index 0000000..9777aca --- /dev/null +++ b/musl-utils/check.vsh @@ -0,0 +1,18 @@ +import os + +fn run_tool(args []string) !string { + mut cmd := ['vinix-run'] + cmd << args + result := os.exec(cmd) + if result.exit_code != 0 { + return error('${args[0]}: ${result.output}') + } + return result.output +} + +page_size := run_tool(['./getconf', 'PAGESIZE'])!.trim_space().int() +assert page_size > 0 && (page_size & (page_size - 1)) == 0 +passwd := run_tool(['./getent', 'passwd', '0'])!.trim_space().split(':') +assert passwd.len >= 4 && passwd[2] == '0' +os.write_file_array('latin1.txt', [u8(0xe9)])! +assert run_tool(['./iconv', '-f', 'ISO-8859-1', '-t', 'UTF-8', 'latin1.txt'])! == 'é' diff --git a/musl-utils/ldd.in b/musl-utils/ldd.in new file mode 100644 index 0000000..93ee06b --- /dev/null +++ b/musl-utils/ldd.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec /lib/ld-musl-@ARCH@.so.1 --list "$@" diff --git a/scanelf/PKGBUILD.vile b/scanelf/PKGBUILD.vile new file mode 100644 index 0000000..099c28d --- /dev/null +++ b/scanelf/PKGBUILD.vile @@ -0,0 +1,26 @@ +; The release minirootfs uses the scanelf output of pax-utils. +defpkgbuild(scanelf, + #:pkgname, "scanelf", + #:pkgver, "1.3.8", + #:pkgrel, 1, + #:pkgdesc, "Inspect ELF metadata and shared library names", + #:arch, [#:x86-64, #:aarch64], + #:url, "https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities", + #:license, "GPL-2.0-only", + #:depends, ["musl"], + #:makedepends, ["linux-headers"], + #:source, ["https://dev.gentoo.org/~sam/distfiles/app-misc/pax-utils/pax-utils-1.3.8.tar.xz"], + #:sha256sums, ["12a168d1aeae2626efdbde3979da88a60ca80bb38e1db565e95ee441ff1d5a0c"], + #:build, fn() { + run("vinix-meson", "pax-utils-1.3.8", "build", "-Dlddtree_implementation=none", + "-Duse_seccomp=false", "-Duse_libcap=disabled", "-Dbuild_manpages=disabled", "-Dtests=false") + run("meson", "compile", "-C", "build", "-j2", "scanelf") + }, + #:check, fn() { + run("vinix-run", "build/scanelf", "-n", "-i", "build/scanelf") + }, + #:package, fn() { + run("install", "-Dm755", "build/scanelf", string-append(pkgdir(), "/usr/bin/scanelf")) + run("install", "-Dm644", "pax-utils-1.3.8/man/scanelf.1", string-append(pkgdir(), "/usr/share/man/man1/scanelf.1")) + run("install", "-Dm644", "pax-utils-1.3.8/COPYING", string-append(pkgdir(), "/usr/share/licenses/scanelf/COPYING")) + }) -- 2.56.1