diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-19 01:24:22 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-19 01:25:41 +0900 |
| commit | fe6dc62ebf1e0ea62b23ba5f917e1280c1db57e9 (patch) | |
| tree | 1c2ed8d5254b57e3e5b4281f5171fbabd4324d14 /internal/rosa | |
| parent | 823f9c76a74b671fb7b76101346da562e5bcb655 (diff) | |
internal/rosa: musl libc artifact
This will likely be included in Rosa OS. The installation is modified to be entirely contained in prefix.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa')
| -rw-r--r-- | internal/rosa/musl.go | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/internal/rosa/musl.go b/internal/rosa/musl.go new file mode 100644 index 00000000..3f9bcf69 --- /dev/null +++ b/internal/rosa/musl.go @@ -0,0 +1,67 @@ +package rosa + +import ( + "slices" + + "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 { + const ( + version = "1.2.5" + checksum = "y6USdIeSdHER_Fw2eT2CNjqShEye85oEg2jnOur96D073ukmIpIqDOLmECQroyDb" + ) + + if attr == nil { + attr = new(MuslAttr) + } + + target := "install" + script := ` +mv -v /work/lib/* /work/system/lib +rmdir -v /work/lib/ +` + if attr.Headers { + target = "install-headers" + script = "" + } + + extra := []pkg.Artifact{ + t.NewMake(), + } + if t == toolchainStage3 { + extra = nil + } + + return t.New("musl-"+version, slices.Concat( + attr.Extra, + extra, + ), nil, slices.Concat([]string{ + "ROSA_MUSL_TARGET=" + target, + }, attr.Env), ` +# expected to be writable in copies +chmod -R +w /usr/src/musl/ + +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"), true, pkg.NewHTTPGetTar( + nil, + "https://musl.libc.org/releases/musl-"+version+".tar.gz", + mustDecode(checksum), + pkg.TarGzip, + ))) +} |
