From 1784ffc7eb97bfe3372fa327e8a742180e519eba Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 01:41:24 +0100 Subject: [PATCH] Package musl fortify headers with a target consumer check --- fortify-headers/PKGBUILD.vile | 34 ++++++++++++++++++++++++++++++++++ fortify-headers/checked.c | 10 ++++++++++ 2 files changed, 44 insertions(+) create mode 100644 fortify-headers/PKGBUILD.vile create mode 100644 fortify-headers/checked.c diff --git a/fortify-headers/PKGBUILD.vile b/fortify-headers/PKGBUILD.vile new file mode 100644 index 0000000..6d8ec69 --- /dev/null +++ b/fortify-headers/PKGBUILD.vile @@ -0,0 +1,34 @@ +defpkgbuild(fortify-headers, + #:pkgname, "fortify-headers", + #:pkgver, "1.1", + #:pkgrel, 1, + #:pkgdesc, "Compile-time and runtime checks for musl C library calls", + #:url, "https://git.2f30.org/fortify-headers/", + #:license, "0BSD", + #:arch, [#:x86-64, #:aarch64], + #:depends, ["musl"], + #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/fortify-headers-1.1.tar.gz", + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/fortify-headers/0001-add-initial-clang-support.patch", + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/fortify-headers/0002-avoid-__extension__-with-clang.patch", + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/fortify-headers/0003-Disable-wrapping-of-ppoll.patch", + "checked.c"], + #:sha256sums, ["6ba5d860a2d2ba4c3346924b93930c34856eafe148bdbdf271ecab8065201fb6", + "41b0e73131959af228928c3a96403e9831c53033fc07494b63cc3d72252118a5", + "2e8a14f08e6d77b7ec7d78c16a16b0bd96e147bafd1d35a54fba866cf13cf336", + "356e3a8f090a4bfd21bc2ed615a7ad6c0c90c5ffd82e7c8457e63c1bda5ac82c", + "e139b9456913c83543b63b16c9972c129f620aa0169a6e8eea382664be2bd85d"], + #:prepare, fn() { + for-each(fn(patch) { + run("patch", "--batch", "--fuzz=0", "-d", "fortify-headers-1.1", "-p1", "-i", string-append(srcdir(), "/", patch)) + }, list("0001-add-initial-clang-support.patch", + "0002-avoid-__extension__-with-clang.patch", + "0003-Disable-wrapping-of-ppoll.patch")) + }, + #:check, fn() { + run("vinix-cc", "-O2", "-D_FORTIFY_SOURCE=2", "-Ifortify-headers-1.1/include", "checked.c", "-o", "checked") + run("vinix-run", "./checked", "Vinix") + }, + #:package, fn() { + run("make", "-C", "fortify-headers-1.1", "PREFIX=/usr", string-append("DESTDIR=", pkgdir()), "install") + run("install", "-Dm644", "fortify-headers-1.1/LICENSE", string-append(pkgdir(), "/usr/share/licenses/fortify-headers/LICENSE")) + }) diff --git a/fortify-headers/checked.c b/fortify-headers/checked.c new file mode 100644 index 0000000..074f4cb --- /dev/null +++ b/fortify-headers/checked.c @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char **argv) { + char text[16]; + if (argc != 2 || strlen(argv[1]) >= sizeof text) + return 1; + strcpy(text, argv[1]); + return strcmp(text, "Vinix") || puts(text) < 0; +} -- 2.56.1