All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 2m36s
Test / Hakurei (push) Successful in 3m48s
Test / ShareFS (push) Successful in 3m57s
Test / Hpkg (push) Successful in 4m24s
Test / Sandbox (race detector) (push) Successful in 4m59s
Test / Hakurei (race detector) (push) Successful in 5m53s
Test / Flake checks (push) Successful in 3m51s
Musl appears to implement this behaviour but does not install the symlink by default. Signed-off-by: Ophestra <cat@gensokyo.uk>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
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 := `
|
|
mkdir -p /work/system/bin
|
|
COMPAT_LINKER_NAME="ld-musl-$(uname -m).so.1"
|
|
ln -vs ../lib/libc.so /work/system/bin/linker
|
|
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, stage3Concat(t, attr.Extra,
|
|
t.Load(Make),
|
|
), 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,
|
|
)))
|
|
}
|