internal/rosa: key-value type
All checks were successful
Test / Create distribution (push) Successful in 1m34s
Test / Sandbox (push) Successful in 4m52s
Test / Hakurei (push) Successful in 5m53s
Test / ShareFS (push) Successful in 5m56s
Test / Sandbox (race detector) (push) Successful in 6m52s
Test / Hakurei (race detector) (push) Successful in 8m8s
Test / Flake checks (push) Successful in 1m29s

This type is used very frequently. The new type is much easier to type and can receive helper methods eventually if needed.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-26 16:20:16 +09:00
parent d514d0679f
commit 2548a681e9
34 changed files with 92 additions and 85 deletions

View File

@@ -13,7 +13,7 @@ func (t Toolchain) newAttr() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), &PackageAttr{
Patches: [][2]string{
Patches: []KV{
{"libgen-basename", `From 8a80d895dfd779373363c3a4b62ecce5a549efb2 Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Date: Sat, 30 Mar 2024 10:17:10 +0100

View File

@@ -25,7 +25,7 @@ func (t Toolchain) newCMake() (pkg.Artifact, string) {
// expected to be writable in the copy made during bootstrap
Chmod: true,
Patches: [][2]string{
Patches: []KV{
{"bootstrap-test-no-openssl", `diff --git a/Tests/BootstrapTest.cmake b/Tests/BootstrapTest.cmake
index 137de78bc1..b4da52e664 100644
--- a/Tests/BootstrapTest.cmake
@@ -88,7 +88,7 @@ index 2ead810437..f85cbb8b1c 100644
OmitDefaults: true,
ConfigureName: "/usr/src/cmake/bootstrap",
Configure: [][2]string{
Configure: []KV{
{"prefix", "/system"},
{"parallel", `"$(nproc)"`},
{"--"},
@@ -125,7 +125,7 @@ type CMakeHelper struct {
Append []string
// CMake CACHE entries.
Cache [][2]string
Cache []KV
// Runs after install.
Script string
@@ -170,7 +170,7 @@ func (*CMakeHelper) wantsDir() string { return "/cure/" }
func (attr *CMakeHelper) script(name string) string {
if attr == nil {
attr = &CMakeHelper{
Cache: [][2]string{
Cache: []KV{
{"CMAKE_BUILD_TYPE", "Release"},
},
}

View File

@@ -18,7 +18,7 @@ func (t Toolchain) newCurl() (pkg.Artifact, string) {
chmod +w tests/data && rm tests/data/test459
`,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"with-openssl"},
{"with-ca-bundle", "/system/etc/ssl/certs/ca-bundle.crt"},

View File

@@ -18,7 +18,7 @@ func (t Toolchain) newDTC() (pkg.Artifact, string) {
Writable: true,
Chmod: true,
}, &MesonHelper{
Setup: [][2]string{
Setup: []KV{
{"Dyaml", "disabled"},
{"Dstatic-build", "true"},
},

View File

@@ -22,7 +22,7 @@ func (t Toolchain) newElfutils() (pkg.Artifact, string) {
// nonstandard glibc extension
SkipCheck: true,
Configure: [][2]string{
Configure: []KV{
{"enable-deterministic-archives"},
},
},

View File

@@ -25,7 +25,7 @@ func (a cureEtc) Cure(t *pkg.FContext) (err error) {
if err = os.MkdirAll(etc.String(), 0700); err != nil {
return
}
for _, f := range [][2]string{
for _, f := range []KV{
{"hosts", "127.0.0.1 localhost cure cure-net\n"},
{"passwd", `root:x:0:0:System administrator:/proc/nonexistent:/bin/sh
cure:x:1023:1023:Cure:/usr/src:/bin/sh

View File

@@ -13,7 +13,7 @@ func (t Toolchain) newFakeroot() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarBzip2,
), &PackageAttr{
Patches: [][2]string{
Patches: []KV{
{"remove-broken-docs", `diff --git a/doc/Makefile.am b/doc/Makefile.am
index f135ad9..85c784c 100644
--- a/doc/Makefile.am

View File

@@ -13,7 +13,7 @@ func (t Toolchain) newFuse() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), nil, &MesonHelper{
Setup: [][2]string{
Setup: []KV{
{"Ddefault_library", "both"},
{"Dtests", "true"},
{"Duseroot", "false"},

View File

@@ -351,7 +351,7 @@ func (t Toolchain) newBash() (pkg.Artifact, string) {
Flag: TEarly,
}, &MakeHelper{
Script: "ln -s bash /work/system/bin/sh\n",
Configure: [][2]string{
Configure: []KV{
{"without-bash-malloc"},
},
}), version
@@ -390,7 +390,7 @@ test_disable 'int main(){return 0;}' gnulib-tests/test-fchownat.c
test_disable 'int main(){return 0;}' gnulib-tests/test-lchown.c
`,
Patches: [][2]string{
Patches: []KV{
{"tests-fix-job-control", `From 21d287324aa43aa3a31f39619ade0deac7fd6013 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Tue, 24 Feb 2026 15:44:41 +0000
@@ -485,7 +485,7 @@ index 9a395416b..fbb043312 100755
Flag: TEarly,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"enable-single-binary", "symlinks"},
},
},
@@ -720,7 +720,7 @@ func (t Toolchain) newTar() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), nil, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"disable-acl"},
{"without-posix-acls"},
{"without-xattrs"},
@@ -903,7 +903,7 @@ func (t Toolchain) newGCC() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), &PackageAttr{
Patches: [][2]string{
Patches: []KV{
{"musl-off64_t-loff_t", `diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 180f5c31d74..44d7ea73f7d 100644
--- a/libgo/sysinfo.c
@@ -1062,7 +1062,7 @@ ln -s system/lib /work/
// it also saturates the CPU for a consequential amount of time.
Flag: TExclusive,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"disable-multilib"},
{"with-multilib-list", `""`},
{"enable-default-pie"},

View File

@@ -35,7 +35,7 @@ func (t Toolchain) newGLib() (pkg.Artifact, string) {
)),
},
}, &MesonHelper{
Setup: [][2]string{
Setup: []KV{
{"Ddefault_library", "both"},
},
},

View File

@@ -23,4 +23,4 @@ var hakureiSource = pkg.NewTar(pkg.NewFile(
), pkg.TarGzip)
// hakureiPatches are patches applied against the compile-time source tree.
var hakureiPatches [][2]string
var hakureiPatches []KV

View File

@@ -15,4 +15,4 @@ var hakureiSource = pkg.NewHTTPGetTar(
)
// hakureiPatches are patches applied against a hakurei release.
var hakureiPatches [][2]string
var hakureiPatches []KV

View File

@@ -90,7 +90,7 @@ exec /system/sbin/depmod -m /lib/modules "$@"
`))),
},
Patches: [][2]string{
Patches: []KV{
{"f54a91f5337cd918eb86cf600320d25b6cfd8209", `From f54a91f5337cd918eb86cf600320d25b6cfd8209 Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <nathan@kernel.org>
Date: Sat, 13 Dec 2025 19:58:10 +0900

View File

@@ -13,7 +13,7 @@ func (t Toolchain) newKmod() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), nil, &MesonHelper{
Setup: [][2]string{
Setup: []KV{
{"Dmoduledir", "/system/lib/modules"},
{"Dsysconfdir", "/system/etc"},
{"Dbashcompletiondir", "no"},

View File

@@ -17,7 +17,7 @@ func (t Toolchain) newLibseccomp() (pkg.Artifact, string) {
ln -s ../system/bin/bash /bin/
`,
Patches: [][2]string{
Patches: []KV{
{"fix-export-oob-read", `diff --git a/src/api.c b/src/api.c
index adccef3..65a277a 100644
--- a/src/api.c

View File

@@ -19,7 +19,7 @@ type llvmAttr struct {
// Concatenated with default environment for PackageAttr.Env.
env []string
// Concatenated with generated entries for CMakeHelper.Cache.
cmake [][2]string
cmake []KV
// Override CMakeHelper.Append.
append []string
// Passed through to PackageAttr.NonStage0.
@@ -30,7 +30,7 @@ type llvmAttr struct {
script string
// Patch name and body pairs.
patches [][2]string
patches []KV
}
const (
@@ -94,43 +94,45 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
var script string
cache := [][2]string{
cache := []KV{
{"CMAKE_BUILD_TYPE", "Release"},
{"LLVM_HOST_TRIPLE", `"${ROSA_TRIPLE}"`},
{"LLVM_DEFAULT_TARGET_TRIPLE", `"${ROSA_TRIPLE}"`},
}
if len(projects) > 0 {
cache = append(cache,
[2]string{"LLVM_ENABLE_PROJECTS", `"${ROSA_LLVM_PROJECTS}"`})
cache = append(cache, []KV{
{"LLVM_ENABLE_PROJECTS", `"${ROSA_LLVM_PROJECTS}"`},
}...)
}
if len(runtimes) > 0 {
cache = append(cache,
[2]string{"LLVM_ENABLE_RUNTIMES", `"${ROSA_LLVM_RUNTIMES}"`})
cache = append(cache, []KV{
{"LLVM_ENABLE_RUNTIMES", `"${ROSA_LLVM_RUNTIMES}"`},
}...)
}
cmakeAppend := []string{"llvm"}
if attr.append != nil {
cmakeAppend = attr.append
} else {
cache = append(cache,
[2]string{"LLVM_ENABLE_LIBCXX", "ON"},
[2]string{"LLVM_USE_LINKER", "lld"},
cache = append(cache, []KV{
{"LLVM_ENABLE_LIBCXX", "ON"},
{"LLVM_USE_LINKER", "lld"},
[2]string{"LLVM_INSTALL_BINUTILS_SYMLINKS", "ON"},
[2]string{"LLVM_INSTALL_CCTOOLS_SYMLINKS", "ON"},
{"LLVM_INSTALL_BINUTILS_SYMLINKS", "ON"},
{"LLVM_INSTALL_CCTOOLS_SYMLINKS", "ON"},
[2]string{"LLVM_LIT_ARGS", "'--verbose'"},
)
{"LLVM_LIT_ARGS", "'--verbose'"},
}...)
}
if attr.flags&llvmProjectClang != 0 {
cache = append(cache,
[2]string{"CLANG_DEFAULT_LINKER", "lld"},
[2]string{"CLANG_DEFAULT_CXX_STDLIB", "libc++"},
[2]string{"CLANG_DEFAULT_RTLIB", "compiler-rt"},
[2]string{"CLANG_DEFAULT_UNWINDLIB", "libunwind"},
)
cache = append(cache, []KV{
{"CLANG_DEFAULT_LINKER", "lld"},
{"CLANG_DEFAULT_CXX_STDLIB", "libc++"},
{"CLANG_DEFAULT_RTLIB", "compiler-rt"},
{"CLANG_DEFAULT_UNWINDLIB", "libunwind"},
}...)
}
if attr.flags&llvmProjectLld != 0 {
script += `
@@ -139,25 +141,27 @@ ln -s ld.lld /work/system/bin/ld
}
if attr.flags&llvmRuntimeCompilerRT != 0 {
if attr.append == nil {
cache = append(cache,
[2]string{"COMPILER_RT_USE_LLVM_UNWINDER", "ON"})
cache = append(cache, []KV{
{"COMPILER_RT_USE_LLVM_UNWINDER", "ON"},
}...)
}
}
if attr.flags&llvmRuntimeLibunwind != 0 {
cache = append(cache,
[2]string{"LIBUNWIND_USE_COMPILER_RT", "ON"})
cache = append(cache, []KV{
{"LIBUNWIND_USE_COMPILER_RT", "ON"},
}...)
}
if attr.flags&llvmRuntimeLibcxx != 0 {
cache = append(cache,
[2]string{"LIBCXX_HAS_MUSL_LIBC", "ON"},
[2]string{"LIBCXX_USE_COMPILER_RT", "ON"},
)
cache = append(cache, []KV{
{"LIBCXX_HAS_MUSL_LIBC", "ON"},
{"LIBCXX_USE_COMPILER_RT", "ON"},
}...)
}
if attr.flags&llvmRuntimeLibcxxABI != 0 {
cache = append(cache,
[2]string{"LIBCXXABI_USE_COMPILER_RT", "ON"},
[2]string{"LIBCXXABI_USE_LLVM_UNWINDER", "ON"},
)
cache = append(cache, []KV{
{"LIBCXXABI_USE_COMPILER_RT", "ON"},
{"LIBCXXABI_USE_LLVM_UNWINDER", "ON"},
}...)
}
return t.NewPackage("llvm", llvmVersion, pkg.NewHTTPGetTar(
@@ -208,7 +212,7 @@ func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
panic("unsupported target " + runtime.GOARCH)
}
minimalDeps := [][2]string{
minimalDeps := []KV{
{"LLVM_ENABLE_ZLIB", "OFF"},
{"LLVM_ENABLE_ZSTD", "OFF"},
{"LLVM_ENABLE_LIBXML2", "OFF"},
@@ -222,7 +226,7 @@ func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
env: stage0ExclConcat(t, []string{},
"LDFLAGS="+earlyLDFLAGS(false),
),
cmake: [][2]string{
cmake: []KV{
// libc++ not yet available
{"CMAKE_CXX_COMPILER_TARGET", ""},
@@ -272,7 +276,7 @@ ln -s \
"LDFLAGS="+earlyLDFLAGS(false),
),
flags: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI,
cmake: slices.Concat([][2]string{
cmake: slices.Concat([]KV{
// libc++ not yet available
{"CMAKE_CXX_COMPILER_WORKS", "ON"},
@@ -293,7 +297,7 @@ ln -s \
"CXXFLAGS="+earlyCXXFLAGS(),
"LDFLAGS="+earlyLDFLAGS(false),
),
cmake: slices.Concat([][2]string{
cmake: slices.Concat([]KV{
{"LLVM_TARGETS_TO_BUILD", target},
{"CMAKE_CROSSCOMPILING", "OFF"},
{"CXX_SUPPORTS_CUSTOM_LINKER", "ON"},
@@ -310,7 +314,7 @@ ln -s clang++ /work/system/bin/c++
ninja check-all
`,
patches: slices.Concat([][2]string{
patches: slices.Concat([]KV{
{"add-rosa-vendor", `diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 9c83abeeb3b1..5acfe5836a23 100644
--- a/llvm/include/llvm/TargetParser/Triple.h

View File

@@ -1,4 +1,4 @@
package rosa
// clangPatches are patches applied to the LLVM source tree for building clang.
var clangPatches [][2]string
var clangPatches []KV

View File

@@ -1,7 +1,7 @@
package rosa
// clangPatches are patches applied to the LLVM source tree for building clang.
var clangPatches [][2]string
var clangPatches []KV
// one version behind, latest fails 5 tests with 2 flaky on arm64
const (

View File

@@ -60,7 +60,7 @@ type MakeHelper struct {
// Alternative name for the configure script.
ConfigureName string
// Flags passed to the configure script.
Configure [][2]string
Configure []KV
// Host target triple, zero value is equivalent to the Rosa OS triple.
Host string
// Target triple, zero value is equivalent to the Rosa OS triple.

View File

@@ -59,7 +59,7 @@ type MesonHelper struct {
Script string
// Flags passed to the setup command.
Setup [][2]string
Setup []KV
// Whether to skip meson test.
SkipTest bool
}
@@ -113,7 +113,7 @@ meson test \
cd "$(mktemp -d)"
meson setup \
` + strings.Join(slices.Collect(func(yield func(string) bool) {
for _, v := range append([][2]string{
for _, v := range append([]KV{
{"prefix", "/system"},
{"buildtype", "release"},
}, attr.Setup...) {

View File

@@ -15,7 +15,7 @@ func (t Toolchain) newNcurses() (pkg.Artifact, string) {
// "tests" are actual demo programs, not a test suite.
SkipCheck: true,
Configure: [][2]string{
Configure: []KV{
{"with-pkg-config"},
{"enable-pc-files"},
},

View File

@@ -20,7 +20,7 @@ func (t Toolchain) newOpenSSL() (pkg.Artifact, string) {
OmitDefaults: true,
ConfigureName: "/usr/src/openssl/Configure",
Configure: [][2]string{
Configure: []KV{
{"prefix", "/system"},
{"libdir", "lib"},
{"openssldir", "etc/ssl"},

View File

@@ -20,7 +20,7 @@ func (t Toolchain) newPCRE2() (pkg.Artifact, string) {
ln -s ../system/bin/toybox /bin/echo
`,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"enable-jit"},
{"enable-pcre2-8"},
{"enable-pcre2-16"},

View File

@@ -31,7 +31,7 @@ rm -f /system/bin/ps # perl does not like toybox ps
InPlace: true,
ConfigureName: "./Configure",
Configure: [][2]string{
Configure: []KV{
{"-des"},
{"Dprefix", "/system"},
{"Dcc", "clang"},
@@ -67,7 +67,7 @@ func init() {
func (t Toolchain) newViaPerlModuleBuild(
name, version string,
source pkg.Artifact,
patches [][2]string,
patches []KV,
extra ...PArtifact,
) pkg.Artifact {
if name == "" || version == "" {
@@ -116,7 +116,7 @@ func init() {
func (t Toolchain) newViaPerlMakeMaker(
name, version string,
source pkg.Artifact,
patches [][2]string,
patches []KV,
extra ...PArtifact,
) pkg.Artifact {
return t.NewPackage("perl-"+name, version, source, &PackageAttr{
@@ -131,7 +131,7 @@ func (t Toolchain) newViaPerlMakeMaker(
InPlace: true,
ConfigureName: "perl Makefile.PL",
Configure: [][2]string{
Configure: []KV{
{"PREFIX", "/system"},
},
Check: []string{"test"},

View File

@@ -13,7 +13,7 @@ func (t Toolchain) newPkgConfig() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), nil, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"CFLAGS", "'-Wno-int-conversion'"},
{"with-internal-glib"},
},

View File

@@ -14,7 +14,7 @@ func (t Toolchain) newProcps() (pkg.Artifact, string) {
pkg.TarBzip2,
), nil, &MakeHelper{
Generate: "./autogen.sh",
Configure: [][2]string{
Configure: []KV{
{"without-ncurses"},
},
},

View File

@@ -12,7 +12,7 @@ func (t Toolchain) newQEMU() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarBzip2,
), &PackageAttr{
Patches: [][2]string{
Patches: []KV{
{"disable-mcast-test", `diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
index b731af0ad9..b5cbed4801 100644
--- a/tests/qtest/netdev-socket.c
@@ -58,7 +58,7 @@ _notrun 'appears to spuriously fail on zfs'
EOF
`,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"disable-download"},
{"disable-docs"},

View File

@@ -37,6 +37,9 @@ func mustDecode(s string) pkg.Checksum {
return pkg.MustDecode(s)
}
// KV is a key-value pair of strings.
type KV [2]string
var (
// AbsUsrSrc is the conventional directory to place source code under.
AbsUsrSrc = fhs.AbsUsr.Append("src")
@@ -364,7 +367,7 @@ func (t Toolchain) NewPatchedSource(
name, version string,
source pkg.Artifact,
passthrough bool,
patches ...[2]string,
patches ...KV,
) pkg.Artifact {
if passthrough && len(patches) == 0 {
return source
@@ -446,7 +449,7 @@ type PackageAttr struct {
ScriptEarly string
// Passed to [Toolchain.NewPatchedSource].
Patches [][2]string
Patches []KV
// Kind of source artifact.
SourceKind int

View File

@@ -15,7 +15,7 @@ func (t Toolchain) newRsync() (pkg.Artifact, string) {
), &PackageAttr{
Flag: TEarly,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"disable-openssl"},
{"disable-xxhash"},
{"disable-zstd"},

View File

@@ -23,7 +23,7 @@ sed -i 's/unsigned int msg_len;$/uint32_t msg_len;/g' \
tests/nlattr.c
`,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
// tests broken on clang
{"disable-gcc-Werror"},

View File

@@ -22,7 +22,7 @@ func (t Toolchain) newUtilLinux() (pkg.Artifact, string) {
ln -s ../system/bin/bash /bin/
`,
}, &MakeHelper{
Configure: [][2]string{
Configure: []KV{
{"disable-use-tty-group"},
{"disable-makeinstall-setuid"},
{"disable-makeinstall-chown"},

View File

@@ -20,7 +20,7 @@ chmod +w tests tests/sanity-test.c
echo 'int main(){}' > tests/sanity-test.c
`,
}, &MesonHelper{
Setup: [][2]string{
Setup: []KV{
{"Ddefault_library", "both"},
{"Ddocumentation", "false"},
{"Dtests", "true"},
@@ -63,7 +63,7 @@ func (t Toolchain) newWaylandProtocols() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarBzip2,
), &PackageAttr{
Patches: [][2]string{
Patches: []KV{
{"build-only", `From 8b4c76275fa1b6e0a99a53494151d9a2c907144d Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Fri, 8 Nov 2024 11:27:25 -0600

View File

@@ -12,7 +12,7 @@ func (t Toolchain) newZlib() (pkg.Artifact, string) {
mustDecode(checksum),
pkg.TarGzip,
), nil, &CMakeHelper{
Cache: [][2]string{
Cache: []KV{
{"CMAKE_BUILD_TYPE", "Release"},
{"ZLIB_BUILD_TESTING", "OFF"},

View File

@@ -14,7 +14,7 @@ func (t Toolchain) newZstd() (pkg.Artifact, string) {
pkg.TarGzip,
), nil, &CMakeHelper{
Append: []string{"build", "cmake"},
Cache: [][2]string{
Cache: []KV{
{"CMAKE_BUILD_TYPE", "Release"},
},
}), version