aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/musl.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-22 15:53:41 +0900
committerOphestra <cat@gensokyo.uk>2026-02-22 15:53:41 +0900
commit5e4bf23e0cd4b57b1b0c9bbcec23baf5718d8011 (patch)
tree300b0736a1f6841aea8cae124e82de8352222833 /internal/rosa/musl.go
parentd4519e2075ed486bf5e65edf0f047f541ddd422f (diff)
internal/rosa/musl: migrate to make helper
This is much cleaner and eliminates the early ugliness. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/musl.go')
-rw-r--r--internal/rosa/musl.go62
1 files changed, 23 insertions, 39 deletions
diff --git a/internal/rosa/musl.go b/internal/rosa/musl.go
index 79678372..e06f777e 100644
--- a/internal/rosa/musl.go
+++ b/internal/rosa/musl.go
@@ -1,34 +1,24 @@
package rosa
-import (
- "slices"
+import "hakurei.app/internal/pkg"
- "hakurei.app/internal/pkg"
-)
-
-// MuslAttr holds the attributes that will be applied to musl.
-type MuslAttr struct {
- // Install headers only.
- Headers bool
- // Environment variables concatenated with defaults.
- Env []string
- // Dependencies concatenated with defaults.
- Extra []pkg.Artifact
-}
-
-// NewMusl returns a [pkg.Artifact] containing an installation of musl libc.
-func (t Toolchain) NewMusl(attr *MuslAttr) pkg.Artifact {
+func (t Toolchain) newMusl(
+ headers bool,
+ env []string,
+ extra ...pkg.Artifact,
+) pkg.Artifact {
const (
version = "1.2.5"
checksum = "y6USdIeSdHER_Fw2eT2CNjqShEye85oEg2jnOur96D073ukmIpIqDOLmECQroyDb"
)
- if attr == nil {
- attr = new(MuslAttr)
- }
+ name := "musl"
+ attr := MakeAttr{
+ OmitDefaults: true,
+ SkipCheck: true,
- target := "install"
- script := `
+ Env: env,
+ Script: `
mkdir -p /work/system/bin
COMPAT_LINKER_NAME="ld-musl-` + linuxArch() + `.so.1"
ln -vs ../lib/libc.so /work/system/bin/linker
@@ -36,29 +26,23 @@ ln -vs ../lib/libc.so /work/system/bin/ldd
ln -vs libc.so "/work/system/lib/${COMPAT_LINKER_NAME}"
rm -v "/work/lib/${COMPAT_LINKER_NAME}"
rmdir -v /work/lib
-`
- if attr.Headers {
- target = "install-headers"
- script = ""
+`,
}
- return t.New("musl-"+version, 0, stage0Concat(t, attr.Extra,
- t.Load(Make),
- t.Load(Coreutils),
- ), nil, slices.Concat([]string{
- "ROSA_MUSL_TARGET=" + target,
- }, attr.Env), `
-cd "$(mktemp -d)"
-/usr/src/musl/configure \
- --prefix=/system \
- --target="${ROSA_TRIPLE}"
-make "-j$(nproc)" DESTDIR=/work "${ROSA_MUSL_TARGET}"
-`+script, pkg.Path(AbsUsrSrc.Append("musl"), false, t.NewPatchedSource(
+ if headers {
+ name += "-headers"
+ attr.ScriptInstall = "make DESTDIR=/work install-headers"
+ attr.Script = ""
+ }
+
+ return t.NewViaMake(name, version, t.NewPatchedSource(
// expected to be writable in copies
"musl", version, pkg.NewHTTPGetTar(
nil, "https://musl.libc.org/releases/musl-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
), false,
- )))
+ ), &attr, stage0Concat(t, extra,
+ t.Load(Coreutils),
+ )...)
}