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" version = "1.0.8"
checksum = "cTLykcco7boom-s05H1JVsQi1AtChYL84nXkg_92Dm1Xt94Ob_qlMg_-NSguIK-c" checksum = "cTLykcco7boom-s05H1JVsQi1AtChYL84nXkg_92Dm1Xt94Ob_qlMg_-NSguIK-c"
) )
return t.New("bzip2-"+version, 0, []pkg.Artifact{ return t.NewViaMake("bzip2", version, pkg.NewHTTPGetTar(
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(
nil, "https://sourceware.org/pub/bzip2/bzip2-"+version+".tar.gz", nil, "https://sourceware.org/pub/bzip2/bzip2-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, 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 } func init() { artifactsF[Bzip2] = Toolchain.newBzip2 }

View File

@@ -13,19 +13,7 @@ func (t Toolchain) newCMake() pkg.Artifact {
version = "4.2.1" version = "4.2.1"
checksum = "Y3OdbMsob6Xk2y1DCME6z4Fryb5_TkFD7knRT8dTNIRtSqbiCJyyDN9AxggN_I75" checksum = "Y3OdbMsob6Xk2y1DCME6z4Fryb5_TkFD7knRT8dTNIRtSqbiCJyyDN9AxggN_I75"
) )
return t.New("cmake-"+version, 0, []pkg.Artifact{ return t.NewViaMake("cmake", version, t.NewPatchedSource(
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(
// expected to be writable in the copy made during bootstrap // expected to be writable in the copy made during bootstrap
"cmake", version, pkg.NewHTTPGetTar( "cmake", version, pkg.NewHTTPGetTar(
nil, "https://github.com/Kitware/CMake/releases/download/"+ nil, "https://github.com/Kitware/CMake/releases/download/"+
@@ -33,7 +21,21 @@ make DESTDIR=/work install
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), false, ), 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 } func init() { artifactsF[CMake] = Toolchain.newCMake }

View File

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

View File

@@ -51,6 +51,8 @@ type MakeAttr struct {
// Remain in working directory set up during ScriptEarly. // Remain in working directory set up during ScriptEarly.
InPlace bool InPlace bool
// Whether to skip running the configure script.
SkipConfigure bool
// Flags passed to the configure script. // Flags passed to the configure script.
Configure [][2]string Configure [][2]string
// Extra make targets. // Extra make targets.
@@ -61,10 +63,14 @@ type MakeAttr struct {
SkipCheck bool SkipCheck bool
// Name of the check target, zero value is equivalent to "check". // Name of the check target, zero value is equivalent to "check".
CheckName string CheckName string
// Replaces the default install command.
ScriptInstall string
// Suffix appended to the source pathname. // Suffix appended to the source pathname.
SourceSuffix string SourceSuffix string
// Passed through to [Toolchain.New], before source.
Paths []pkg.ExecPath
// Passed through to [Toolchain.New]. // Passed through to [Toolchain.New].
Flag int Flag int
} }
@@ -87,34 +93,39 @@ func (t Toolchain) NewViaMake(
build = attr.Build build = attr.Build
} }
var configureFlags string var configure string
if len(attr.Configure) > 0 { if !attr.SkipConfigure {
const sep = " \\\n\t" configure += `
configureFlags += sep + strings.Join( /usr/src/` + name + `/configure \
slices.Collect(func(yield func(string) bool) { --prefix=/system`
for _, v := range attr.Configure {
s := v[0]
if v[1] == "" || (v[0] != "" &&
v[0][0] >= 'a' &&
v[0][0] <= 'z') {
s = "--" + s
}
if v[1] != "" {
s += "=" + v[1]
}
if !yield(s) {
return
}
}
}),
sep,
)
}
var buildFlag string if attr.Build != `""` {
if attr.Build != `""` { configure += ` \
buildFlag = ` \
--build=` + build --build=` + build
}
if len(attr.Configure) > 0 {
const sep = " \\\n\t"
configure += sep + strings.Join(
slices.Collect(func(yield func(string) bool) {
for _, v := range attr.Configure {
s := v[0]
if v[1] == "" || (v[0] != "" &&
v[0][0] >= 'a' &&
v[0][0] <= 'z') {
s = "--" + s
}
if v[1] != "" {
s += "=" + v[1]
}
if !yield(s) {
return
}
}
}),
sep,
)
}
} }
makeTargets := make([]string, 1, 2+len(attr.Make)) makeTargets := make([]string, 1, 2+len(attr.Make))
@@ -148,15 +159,20 @@ func (t Toolchain) NewViaMake(
panic("cannot remain in root") 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, return t.New(name+"-"+version, attr.Flag, stage0Concat(t,
attr.NonStage0, attr.NonStage0,
finalExtra..., finalExtra...,
), nil, attr.Env, scriptEarly+` ), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+`
/usr/src/`+name+`/configure \
--prefix=/system`+buildFlag+configureFlags+attr.ScriptConfigured+`
make "-j$(nproc)"`+strings.Join(makeTargets, " ")+` make "-j$(nproc)"`+strings.Join(makeTargets, " ")+`
make DESTDIR=/work install `+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{
`+attr.Script, pkg.Path(AbsUsrSrc.Append( pkg.Path(AbsUsrSrc.Append(
name+attr.SourceSuffix, 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" version = "3.5.5"
checksum = "I2Hp1LxcTR8j4G6LFEQMVy6EJH-Na1byI9Ti-ThBot6EMLNRnjGXGq-WXrim3Fkz" checksum = "I2Hp1LxcTR8j4G6LFEQMVy6EJH-Na1byI9Ti-ThBot6EMLNRnjGXGq-WXrim3Fkz"
) )
return t.New("openssl-"+version, 0, []pkg.Artifact{ return t.NewViaMake("openssl", version, pkg.NewHTTPGetTar(
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(
nil, "https://github.com/openssl/openssl/releases/download/"+ nil, "https://github.com/openssl/openssl/releases/download/"+
"openssl-"+version+"/openssl-"+version+".tar.gz", "openssl-"+version+"/openssl-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, 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 } func init() { artifactsF[OpenSSL] = Toolchain.newOpenSSL }

View File

@@ -12,45 +12,57 @@ func (t Toolchain) newNSS() pkg.Artifact {
version0 = "4_38_2" version0 = "4_38_2"
checksum0 = "25x2uJeQnOHIiq_zj17b4sYqKgeoU8-IsySUptoPcdHZ52PohFZfGuIisBreWzx0" checksum0 = "25x2uJeQnOHIiq_zj17b4sYqKgeoU8-IsySUptoPcdHZ52PohFZfGuIisBreWzx0"
) )
return t.New("nss-"+version, 0, []pkg.Artifact{ return t.NewViaMake("nss", version, t.NewPatchedSource(
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(
"nss", version, pkg.NewHTTPGetTar( "nss", version, pkg.NewHTTPGetTar(
nil, "https://github.com/nss-dev/nss/archive/refs/tags/"+ nil, "https://github.com/nss-dev/nss/archive/refs/tags/"+
"NSS_"+version+"_RTM.tar.gz", "NSS_"+version+"_RTM.tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), false, ), false,
)), pkg.Path(AbsUsrSrc.Append("nspr.zip"), false, pkg.NewHTTPGet( ), &MakeAttr{
nil, "https://hg-edge.mozilla.org/projects/nspr/archive/"+ Paths: []pkg.ExecPath{
"NSPR_"+version0+"_RTM.zip", pkg.Path(AbsUsrSrc.Append("nspr.zip"), false, pkg.NewHTTPGet(
mustDecode(checksum0), 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 } func init() { artifactsF[NSS] = Toolchain.newNSS }