| 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 | v-arch := if string=?("aarch64", arch) { "arm64" } else { "x64" } |
| 4 | |
| 5 | defpkgbuild(vpac, |
| 6 | #:pkgname, "vpac", |
| 7 | #:pkgver, "1.0.0", |
| 8 | #:pkgrel, 2, |
| 9 | #:pkgdesc, "Vinix package manager and native Vile package builder", |
| 10 | #:arch, [#:x86-64, #:aarch64], |
| 11 | #:url, "https://gitly.divio.city/me/vpac", |
| 12 | #:license, "GPL-3.0-only", |
| 13 | #:depends, ["musl", "gc", "curl", "libarchive", "libgpg-error", "gpgme", "gnupg", "libseccomp", "vinix-accounts>=0.1.0-2"], |
| 14 | #:makedepends, ["linux-headers"], |
| 15 | #:backup, ["etc/vpac.d/config.vile"], |
| 16 | ; Native makepkg checks out each full commit after cloning its public repository. |
| 17 | #:source, ["vpac-src::git+https://gitly.divio.city/me/vpac.git#commit=e7147c7fac0dc130fe03c7accf07c75a88188d3d", |
| 18 | "nspkg::git+https://gitly.divio.city/me/nspkg.git#commit=c01b0795d1db56c7bce2539b2c46b110637fdc1a", |
| 19 | "stutter::git+https://gitly.divio.city/me/stutter.git#commit=29b47cb4b818f95a5308d3c086bd7933b7c176bd", |
| 20 | "vile::git+https://git.vorelabs.dev/diviocity/vile.git#commit=76646891b77a3d5c6af4a1e42b122cd61dc1654b", |
| 21 | "config.vile.in", "check-config.py", "vinix-landlock.patch"], |
| 22 | #:sha256sums, ["SKIP", "SKIP", "SKIP", "SKIP", "da473de43c4b1232145dee708df4762a1b26f930bb5693053b19a763df462bf4", |
| 23 | "eb72a7f3ce972cfe0b653984324332cf119d778e723d7e659b3a49494cc883ea", |
| 24 | "7c0e1262f5d7b65a1c95b4efb5ea00e2fab9f0ef4f27b304f359858e564aa212"], |
| 25 | #:prepare, fn() { |
| 26 | run("mkdir", "modules") |
| 27 | run("mv", "nspkg", "stutter", "vile", "modules/") |
| 28 | run("patch", "--batch", "--fuzz=0", "-d", "modules/nspkg", "-p1", "-i", |
| 29 | string-append(srcdir(), "/vinix-landlock.patch")) |
| 30 | run("cp", "config.vile.in", "config.vile") |
| 31 | run("sed", "-i", string-append("s/@ARCH@/", arch, "/g"), "config.vile") |
| 32 | }, |
| 33 | #:build, fn() { |
| 34 | paths := string-append(srcdir(), "/vpac-src|", srcdir(), "/modules|", srcdir(), "/modules/vile|@vlib") |
| 35 | ; Embed the Vile assets while keeping the generated C inside the bootstrap build budget. |
| 36 | ; The V driver runs on the build host. Match the target libc even when the host uses glibc. |
| 37 | run("v", "-prod", "-no-prod-options", "-cflags", "-O0", "-no-parallel", "-no-retry-compilation", |
| 38 | "-os", "linux", "-arch", v-arch, "-cc", "vinix-cc", |
| 39 | "-gc", "boehm", "-d", "musl", "-d", "dynamic_boehm", "-d", "nspkg_libcurl", |
| 40 | "-path", paths, "-o", "vpac-target", "vpac-src/src") |
| 41 | }, |
| 42 | #:check, fn() { |
| 43 | run("python3", "check-config.py") |
| 44 | }, |
| 45 | #:package, fn() { |
| 46 | run("install", "-Dm755", "vpac-target", string-append(pkgdir(), "/usr/bin/vpac")) |
| 47 | run("install", "-Dm644", "config.vile", string-append(pkgdir(), "/etc/vpac.d/config.vile")) |
| 48 | run("install", "-d", string-append(pkgdir(), "/var/lib/vpac"), string-append(pkgdir(), "/var/cache/vpac/pkg"), |
| 49 | string-append(pkgdir(), "/etc/vpac.d/hooks"), string-append(pkgdir(), "/var/log")) |
| 50 | run("install", "-d", "-m700", string-append(pkgdir(), "/etc/vpac.d/gnupg")) |
| 51 | }) |
| 52 | |