vinix-ports / vinix-desktop-init / PKGBUILD.vile
60 lines · 59 sloc · 3.08 KB · d7ac018690d796b9dbbe34d117a9a38fc1de38b1
Raw
1selected := get-environment-variable("VPAC_TARGET_ARCH")
2arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
3arm := string=?("aarch64", arch)
4revision := "c34a6707e1d8d3a23d0b1bfe6e6dbb16290e4f75"
5repo := string-append("vinix-", revision)
6support := string-append(repo, "/build-support")
7raw := string-append("https://raw.githubusercontent.com/vlang/vinix/", revision)
8
9defpkgbuild(vinix-desktop-init,
10 #:pkgname, "vinix-desktop-init",
11 #:pkgver, "20261128",
12 #:pkgrel, if arm { 2 } else { 1 },
13 #:pkgdesc, "Vinix desktop PID 1 for the default release image",
14 #:arch, [#:x86-64, #:aarch64],
15 #:url, "https://github.com/vlang/vinix",
16 #:license, "GPL-2.0-only",
17 #:depends, ["busybox", "zsh", "vinix-filesystem"],
18 #:provides, ["init"],
19 #:conflicts, ["busybox-init"],
20 #:source, if arm {
21 list(string-append(repo, ".tar.gz::https://codeload.github.com/vlang/vinix/tar.gz/", revision), "check-init.py")
22 } else {
23 list(string-append(raw, "/build-support/init-amd64/desktop-init"), string-append(raw, "/LICENSE"))
24 },
25 #:sha256sums, if arm {
26 list("e57193f3e7f0f6f578c0dae03789bf0616c88c7b1fb87c11b141c760a97cce6e",
27 "4457061065c264efa2308fbb8f8162395b5b96c838baddcc02af7430bd5dbbd9")
28 } else {
29 list("167b40c6491947b9ddb5330fa7cf1e02d5a636eb6569ee3d6c6150d4d0fd94a4",
30 "8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643")
31 },
32 #:build, fn() {
33 if arm {
34 init := string-append(support, "/init-aarch64")
35 host-libraries := get-environment-variable("VINIX_HOST_LIBRARY_PATH")
36 run("env", string-append("LIBRARY_PATH=", if string?(host-libraries) { host-libraries } else { "" }),
37 string-append(support, "/run-v-tool.sh"), string-append(init, "/compile_init.v"),
38 "desktop", string-append(srcdir(), "/desktop-init.c"))
39 ; The raw syscall implementation supplies its own stdio and memory ABI.
40 ; Use Clang's freestanding headers for stdint and stddef.
41 run("clang", "--target=aarch64-linux-none", "-nostdlibinc",
42 "-nostdlib", "-ffreestanding", "-O2",
43 "-fno-stack-protector", "-fno-builtin", "-ffunction-sections", "-fdata-sections",
44 "-I", init, "-c", "desktop-init.c", "-o", "desktop-init.o")
45 run("clang", "--target=aarch64-linux-none", "-c", string-append(init, "/syscall_abi.S"), "-o", "syscall_abi.o")
46 run("ld.lld", "-m", "aarch64elf", "--nostdlib", "-static", "--gc-sections", "-z", "max-page-size=16384",
47 "-o", "desktop-init", "desktop-init.o", "syscall_abi.o")
48 }
49 },
50 #:check, fn() {
51 if arm { run("python3", "check-init.py") } else { run("sh", "-n", "desktop-init") }
52 },
53 #:package, fn() {
54 run("install", "-Dm755", "desktop-init", string-append(pkgdir(), "/sbin/init"))
55 if arm {
56 run("install", "-Dm755", "desktop-init", string-append(pkgdir(), "/usr/libexec/vinix-desktop-init"))
57 }
58 license-file := if arm { string-append(repo, "/LICENSE") } else { "LICENSE" }
59 run("install", "-Dm644", license-file, string-append(pkgdir(), "/usr/share/licenses/vinix-desktop-init/LICENSE"))
60 })
61