defpkgbuild(file, #:pkgname, "file", #:pkgver, "5.46", #:pkgrel, 1, #:pkgdesc, "Identify file formats with the compiled magic database", #:url, "https://www.darwinsys.com/file/", #:license, "BSD-2-Clause", #:arch, [#:x86-64, #:aarch64], #:depends, ["musl"], #:source, ["https://astron.com/pub/file/file-5.46.tar.gz", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/file/file-5.46-pr-579-net147-fix-stack-overrun.patch", "check.py"], #:sha256sums, ["c9cc77c7c560c543135edc555af609d5619dbef011997e988ce40a3d75d86088", "c1f9f7c7195a09d8f5f846624665f74d27990b0d71fcf812d5bb0a55e2f25cdc", "04af1f3aa45014a42bd59133ffc4bc5fea37e72affee1fb2c8a4b4a0ec15ad34"], #:prepare, fn() { for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "file-5.46", "-p1", "-i", string-append(srcdir(), "/", patch)) }, list("file-5.46-pr-579-net147-fix-stack-overrun.patch")) }, #:build, fn() { ; The magic database compiler must run on the builder and match the target version. run("mkdir", "native") run("env", "-C", "native", "CC=cc", "../file-5.46/configure", "--disable-shared", "--disable-zlib", "--disable-bzlib", "--disable-xzlib", "--disable-zstdlib", "--disable-lzlib") run("make", "-C", "native/src", "all") run("vinix-configure", "file-5.46/configure", "--enable-static", "--disable-zlib", "--disable-bzlib", "--disable-xzlib", "--disable-zstdlib", "--disable-lzlib") run("make", string-append("FILE_COMPILE=", srcdir(), "/native/src/file")) }, #:check, fn() { run("make", string-append("FILE_COMPILE=", srcdir(), "/native/src/file"), string-append("DESTDIR=", srcdir(), "/checked"), "install") run("python3", "check.py") }, #:package, fn() { run("make", string-append("FILE_COMPILE=", srcdir(), "/native/src/file"), string-append("DESTDIR=", pkgdir()), "install") run("find", pkgdir(), "-name", "*.la", "-delete") run("install", "-Dm644", "file-5.46/COPYING", string-append(pkgdir(), "/usr/share/licenses/file/COPYING")) })