internal/rosa/make: configurable configure and install
All checks were successful
Test / Create distribution (push) Successful in 29s
Test / ShareFS (push) Successful in 36s
Test / Sandbox (race detector) (push) Successful in 43s
Test / Sandbox (push) Successful in 44s
Test / Hakurei (race detector) (push) Successful in 49s
Test / Hpkg (push) Successful in 46s
Test / Hakurei (push) Successful in 2m50s
Test / Flake checks (push) Successful in 1m46s

This makes the helper useful for non-autotools build systems.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-11 23:51:10 +09:00
parent 59ff6db7ec
commit 1791b604b5
6 changed files with 161 additions and 133 deletions

View File

@@ -7,16 +7,21 @@ func (t Toolchain) newBzip2() pkg.Artifact {
version = "1.0.8"
checksum = "cTLykcco7boom-s05H1JVsQi1AtChYL84nXkg_92Dm1Xt94Ob_qlMg_-NSguIK-c"
)
return t.New("bzip2-"+version, 0, []pkg.Artifact{
t.Load(Make),
}, nil, nil, `
cd /usr/src/bzip2
make CC=cc
make PREFIX=/work/system install
`, pkg.Path(AbsUsrSrc.Append("bzip2"), true, pkg.NewHTTPGetTar(
return t.NewViaMake("bzip2", version, pkg.NewHTTPGetTar(
nil, "https://sourceware.org/pub/bzip2/bzip2-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
)))
), &MakeAttr{
Writable: true,
SkipConfigure: true,
SkipCheck: true,
InPlace: true,
ScriptEarly: "cd /usr/src/bzip2",
Make: []string{
"CC=cc",
},
ScriptInstall: "make PREFIX=/work/system install",
})
}
func init() { artifactsF[Bzip2] = Toolchain.newBzip2 }

View File

@@ -13,19 +13,7 @@ func (t Toolchain) newCMake() pkg.Artifact {
version = "4.2.1"
checksum = "Y3OdbMsob6Xk2y1DCME6z4Fryb5_TkFD7knRT8dTNIRtSqbiCJyyDN9AxggN_I75"
)
return t.New("cmake-"+version, 0, []pkg.Artifact{
t.Load(Make),
t.Load(KernelHeaders),
}, nil, nil, `
cd "$(mktemp -d)"
/usr/src/cmake/bootstrap \
--prefix=/system \
--parallel="$(nproc)" \
-- \
-DCMAKE_USE_OPENSSL=OFF
make "-j$(nproc)"
make DESTDIR=/work install
`, pkg.Path(AbsUsrSrc.Append("cmake"), true, t.NewPatchedSource(
return t.NewViaMake("cmake", version, t.NewPatchedSource(
// expected to be writable in the copy made during bootstrap
"cmake", version, pkg.NewHTTPGetTar(
nil, "https://github.com/Kitware/CMake/releases/download/"+
@@ -33,7 +21,21 @@ make DESTDIR=/work install
mustDecode(checksum),
pkg.TarGzip,
), false,
)))
), &MakeAttr{
OmitDefaults: true,
SkipConfigure: true,
ScriptConfigured: `
/usr/src/cmake/bootstrap \
--prefix=/system \
--parallel="$(nproc)" \
-- \
-DCMAKE_USE_OPENSSL=OFF
`,
SkipCheck: true,
},
t.Load(KernelHeaders),
)
}
func init() { artifactsF[CMake] = Toolchain.newCMake }

View File

@@ -7,34 +7,24 @@ func (t Toolchain) newLibucontext() pkg.Artifact {
version = "1.5"
checksum = "Ggk7FMmDNBdCx1Z9PcNWWW6LSpjGYssn2vU0GK5BLXJYw7ZxZbA2m_eSgT9TFnIG"
)
return t.New("libucontext", 0, []pkg.Artifact{
t.Load(Make),
}, nil, []string{
"ARCH=" + linuxArch(),
}, `
cd /usr/src/libucontext
make check
make DESTDIR=/work install
`, pkg.Path(AbsUsrSrc.Append("libucontext"), true,
t.NewPatchedSource("libucontext", version, pkg.NewHTTPGetTar(
return t.NewViaMake("libucontext", version, t.NewPatchedSource(
"libucontext", version, pkg.NewHTTPGetTar(
nil, "https://github.com/kaniini/libucontext/archive/refs/tags/"+
"libucontext-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
), true, [2]string{"rosa-prefix", `diff --git a/Makefile b/Makefile
index c80e574..4a8c1d3 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ ifeq ($(ARCH),$(filter $(ARCH),arm64))
override ARCH = aarch64
endif
), false,
), &MakeAttr{
Writable: true,
OmitDefaults: true,
SkipConfigure: true,
InPlace: true,
-prefix = /usr
+prefix = /system
libdir = ${prefix}/lib
shared_libdir = ${libdir}
static_libdir = ${libdir}
`}),
))
ScriptEarly: "cd /usr/src/libucontext",
Make: []string{
"ARCH=" + linuxArch(),
},
ScriptInstall: "make prefix=/system DESTDIR=/work install",
})
}
func init() { artifactsF[Libucontext] = Toolchain.newLibucontext }

View File

@@ -51,6 +51,8 @@ type MakeAttr struct {
// Remain in working directory set up during ScriptEarly.
InPlace bool
// Whether to skip running the configure script.
SkipConfigure bool
// Flags passed to the configure script.
Configure [][2]string
// Extra make targets.
@@ -61,10 +63,14 @@ type MakeAttr struct {
SkipCheck bool
// Name of the check target, zero value is equivalent to "check".
CheckName string
// Replaces the default install command.
ScriptInstall string
// Suffix appended to the source pathname.
SourceSuffix string
// Passed through to [Toolchain.New], before source.
Paths []pkg.ExecPath
// Passed through to [Toolchain.New].
Flag int
}
@@ -87,10 +93,20 @@ func (t Toolchain) NewViaMake(
build = attr.Build
}
var configureFlags string
var configure string
if !attr.SkipConfigure {
configure += `
/usr/src/` + name + `/configure \
--prefix=/system`
if attr.Build != `""` {
configure += ` \
--build=` + build
}
if len(attr.Configure) > 0 {
const sep = " \\\n\t"
configureFlags += sep + strings.Join(
configure += sep + strings.Join(
slices.Collect(func(yield func(string) bool) {
for _, v := range attr.Configure {
s := v[0]
@@ -110,11 +126,6 @@ func (t Toolchain) NewViaMake(
sep,
)
}
var buildFlag string
if attr.Build != `""` {
buildFlag = ` \
--build=` + build
}
makeTargets := make([]string, 1, 2+len(attr.Make))
@@ -148,15 +159,20 @@ func (t Toolchain) NewViaMake(
panic("cannot remain in root")
}
scriptInstall := attr.ScriptInstall
if scriptInstall == "" {
scriptInstall = "make DESTDIR=/work install"
}
scriptInstall += "\n"
return t.New(name+"-"+version, attr.Flag, stage0Concat(t,
attr.NonStage0,
finalExtra...,
), nil, attr.Env, scriptEarly+`
/usr/src/`+name+`/configure \
--prefix=/system`+buildFlag+configureFlags+attr.ScriptConfigured+`
), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+`
make "-j$(nproc)"`+strings.Join(makeTargets, " ")+`
make DESTDIR=/work install
`+attr.Script, pkg.Path(AbsUsrSrc.Append(
`+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{
pkg.Path(AbsUsrSrc.Append(
name+attr.SourceSuffix,
), attr.Writable, source))
), attr.Writable, source),
})...)
}

View File

@@ -7,30 +7,33 @@ func (t Toolchain) newOpenSSL() pkg.Artifact {
version = "3.5.5"
checksum = "I2Hp1LxcTR8j4G6LFEQMVy6EJH-Na1byI9Ti-ThBot6EMLNRnjGXGq-WXrim3Fkz"
)
return t.New("openssl-"+version, 0, []pkg.Artifact{
t.Load(Perl),
t.Load(Make),
t.Load(Zlib),
t.Load(KernelHeaders),
}, nil, []string{
"CC=cc",
}, `
cd "$(mktemp -d)"
/usr/src/openssl/Configure \
--prefix=/system \
--libdir=lib \
--openssldir=etc/ssl
make \
"-j$(nproc)" \
HARNESS_JOBS=256 \
test
make DESTDIR=/work install
`, pkg.Path(AbsUsrSrc.Append("openssl"), false, pkg.NewHTTPGetTar(
return t.NewViaMake("openssl", version, pkg.NewHTTPGetTar(
nil, "https://github.com/openssl/openssl/releases/download/"+
"openssl-"+version+"/openssl-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
)))
), &MakeAttr{
OmitDefaults: true,
SkipConfigure: true,
Env: []string{
"CC=cc",
},
ScriptConfigured: `
/usr/src/openssl/Configure \
--prefix=/system \
--libdir=lib \
--openssldir=etc/ssl
`,
CheckName: "test",
Make: []string{
"HARNESS_JOBS=256",
},
},
t.Load(Perl),
t.Load(Zlib),
t.Load(KernelHeaders),
)
}
func init() { artifactsF[OpenSSL] = Toolchain.newOpenSSL }

View File

@@ -12,45 +12,57 @@ func (t Toolchain) newNSS() pkg.Artifact {
version0 = "4_38_2"
checksum0 = "25x2uJeQnOHIiq_zj17b4sYqKgeoU8-IsySUptoPcdHZ52PohFZfGuIisBreWzx0"
)
return t.New("nss-"+version, 0, []pkg.Artifact{
t.Load(Perl),
t.Load(Python),
t.Load(Unzip),
t.Load(Make),
t.Load(Gawk),
t.Load(Coreutils),
t.Load(Zlib),
t.Load(KernelHeaders),
}, nil, nil, `
unzip /usr/src/nspr.zip -d /usr/src
mv '/usr/src/nspr-NSPR_`+version0+`_RTM' /usr/src/nspr
cd /usr/src/nss
make \
"-j$(nproc)" \
CCC="clang++" \
NSDISTMODE=copy \
BUILD_OPT=1 \
USE_64=1 \
nss_build_all
mkdir -p /work/system/nss
cp -r \
/usr/src/dist/. \
lib/ckfw/builtins/certdata.txt \
/work/system/nss
`, pkg.Path(AbsUsrSrc.Append("nss"), true, t.NewPatchedSource(
return t.NewViaMake("nss", version, t.NewPatchedSource(
"nss", version, pkg.NewHTTPGetTar(
nil, "https://github.com/nss-dev/nss/archive/refs/tags/"+
"NSS_"+version+"_RTM.tar.gz",
mustDecode(checksum),
pkg.TarGzip,
), false,
)), pkg.Path(AbsUsrSrc.Append("nspr.zip"), false, pkg.NewHTTPGet(
), &MakeAttr{
Paths: []pkg.ExecPath{
pkg.Path(AbsUsrSrc.Append("nspr.zip"), false, pkg.NewHTTPGet(
nil, "https://hg-edge.mozilla.org/projects/nspr/archive/"+
"NSPR_"+version0+"_RTM.zip",
mustDecode(checksum0),
)))
)),
},
Writable: true,
OmitDefaults: true,
SkipConfigure: true,
InPlace: true,
ScriptEarly: `
unzip /usr/src/nspr.zip -d /usr/src
mv '/usr/src/nspr-NSPR_` + version0 + `_RTM' /usr/src/nspr
cd /usr/src/nss
`,
SkipCheck: true,
Make: []string{
"CCC=clang++",
"NSDISTMODE=copy",
"BUILD_OPT=1",
"USE_64=1",
"nss_build_all",
},
ScriptInstall: `
mkdir -p /work/system/nss
cp -r \
/usr/src/dist/. \
lib/ckfw/builtins/certdata.txt \
/work/system/nss
`,
},
t.Load(Perl),
t.Load(Python),
t.Load(Unzip),
t.Load(Gawk),
t.Load(Coreutils),
t.Load(Zlib),
t.Load(KernelHeaders),
)
}
func init() { artifactsF[NSS] = Toolchain.newNSS }