aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-01 12:11:41 +0900
committerOphestra <cat@gensokyo.uk>2026-03-01 14:41:34 +0900
commit51d3df2419e26f15d780c98629a357473855ebd4 (patch)
treee5c0e3810156d3f706ed732b67bd5e12b3dfa8f5 /internal
parent1d0fcf3a75bbdbeac24c34f5d55cb5ba347f1782 (diff)
internal/rosa/make: split build and check
Doing these together breaks far too many buggy makefiles. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/rosa/cmake.go15
-rw-r--r--internal/rosa/curl.go3
-rw-r--r--internal/rosa/git.go22
-rw-r--r--internal/rosa/gnu.go23
-rw-r--r--internal/rosa/hakurei.go1
-rw-r--r--internal/rosa/kernel.go2
-rw-r--r--internal/rosa/libcap.go2
-rw-r--r--internal/rosa/libgd.go3
-rw-r--r--internal/rosa/libseccomp.go3
-rw-r--r--internal/rosa/libxml2.go3
-rw-r--r--internal/rosa/libxslt.go3
-rw-r--r--internal/rosa/make.go96
-rw-r--r--internal/rosa/openssl.go20
-rw-r--r--internal/rosa/perl.go21
-rw-r--r--internal/rosa/python.go7
-rw-r--r--internal/rosa/qemu.go9
-rw-r--r--internal/rosa/toybox.go11
-rw-r--r--internal/rosa/x.go4
-rw-r--r--internal/rosa/xcb.go12
19 files changed, 117 insertions, 143 deletions
diff --git a/internal/rosa/cmake.go b/internal/rosa/cmake.go
index 5f049dd0..33bad61c 100644
--- a/internal/rosa/cmake.go
+++ b/internal/rosa/cmake.go
@@ -24,14 +24,13 @@ func (t Toolchain) newCMake() pkg.Artifact {
), &MakeAttr{
OmitDefaults: true,
- SkipConfigure: true,
- ScriptConfigured: `
-/usr/src/cmake/bootstrap \
- --prefix=/system \
- --parallel="$(nproc)" \
- -- \
- -DCMAKE_USE_OPENSSL=OFF
-`,
+ ConfigureName: "/usr/src/cmake/bootstrap",
+ Configure: [][2]string{
+ {"prefix", "/system"},
+ {"parallel", `"$(nproc)"`},
+ {"--"},
+ {"-DCMAKE_USE_OPENSSL", "OFF"},
+ },
SkipCheck: true,
},
t.Load(KernelHeaders),
diff --git a/internal/rosa/curl.go b/internal/rosa/curl.go
index c2022ca1..d040ad7e 100644
--- a/internal/rosa/curl.go
+++ b/internal/rosa/curl.go
@@ -19,9 +19,6 @@ func (t Toolchain) newCurl() pkg.Artifact {
{"with-openssl"},
{"with-ca-bundle", "/system/etc/ssl/certs/ca-bundle.crt"},
},
- ScriptConfigured: `
-make "-j$(nproc)"
-`,
},
t.Load(Perl),
diff --git a/internal/rosa/git.go b/internal/rosa/git.go
index 0153f547..a243e507 100644
--- a/internal/rosa/git.go
+++ b/internal/rosa/git.go
@@ -1,8 +1,6 @@
package rosa
-import (
- "hakurei.app/internal/pkg"
-)
+import "hakurei.app/internal/pkg"
func (t Toolchain) newGit() pkg.Artifact {
const (
@@ -21,20 +19,14 @@ func (t Toolchain) newGit() pkg.Artifact {
Writable: true,
InPlace: true,
- // test suite in subdirectory
- SkipCheck: true,
-
- Make: []string{"all"},
ScriptEarly: `
cd /usr/src/git
make configure
-`,
- Script: `
ln -s ../../system/bin/perl /usr/bin/ || true
function disable_test {
- local test=$1 pattern=$2
+ local test=$1 pattern=${2:-''}
if [ $# -eq 1 ]; then
rm "t/${test}.sh"
else
@@ -56,12 +48,12 @@ disable_test t9300-fast-import
disable_test t0211-trace2-perf
disable_test t1517-outside-repo
disable_test t2200-add-update
-
-make \
- -C t \
- GIT_PROVE_OPTS="--jobs 32 --failures" \
- prove
`,
+ Check: []string{
+ "-C t",
+ `GIT_PROVE_OPTS="--jobs 32 --failures"`,
+ "prove",
+ },
},
t.Load(Perl),
t.Load(Diffutils),
diff --git a/internal/rosa/gnu.go b/internal/rosa/gnu.go
index 75f4b385..a110dcef 100644
--- a/internal/rosa/gnu.go
+++ b/internal/rosa/gnu.go
@@ -65,8 +65,9 @@ func (t Toolchain) newAutoconf() pkg.Artifact {
mustDecode(checksum),
pkg.TarGzip,
), &MakeAttr{
- Make: []string{
+ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`,
+ "check",
},
Flag: TExclusive,
},
@@ -122,8 +123,9 @@ func (t Toolchain) newLibtool() pkg.Artifact {
mustDecode(checksum),
pkg.TarGzip,
), &MakeAttr{
- Make: []string{
- `TESTSUITEFLAGS=32`,
+ Check: []string{
+ `TESTSUITEFLAGS="-j$(nproc)"`,
+ "check",
},
},
t.Load(M4),
@@ -442,8 +444,9 @@ func (t Toolchain) newTar() pkg.Artifact {
{"without-posix-acls"},
{"without-xattrs"},
},
- Make: []string{
+ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`,
+ "check",
},
},
t.Load(Diffutils),
@@ -464,11 +467,7 @@ func (t Toolchain) newBinutils() pkg.Artifact {
nil, "https://ftpmirror.gnu.org/gnu/binutils/binutils-"+version+".tar.bz2",
mustDecode(checksum),
pkg.TarBzip2,
- ), &MakeAttr{
- ScriptConfigured: `
-make "-j$(nproc)"
-`,
- },
+ ), nil,
t.Load(Bash),
)
}
@@ -484,11 +483,7 @@ func (t Toolchain) newGMP() pkg.Artifact {
"gmp-"+version+".tar.bz2",
mustDecode(checksum),
pkg.TarBzip2,
- ), &MakeAttr{
- ScriptConfigured: `
-make "-j$(nproc)"
-`,
- },
+ ), nil,
t.Load(M4),
)
}
diff --git a/internal/rosa/hakurei.go b/internal/rosa/hakurei.go
index 02879176..fe944607 100644
--- a/internal/rosa/hakurei.go
+++ b/internal/rosa/hakurei.go
@@ -66,6 +66,7 @@ echo '# Building hakurei.'
go generate -v ./...
go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w
-buildid=
+ -linkmode external
-extldflags=-static
-X hakurei.app/internal/info.buildVersion="$HAKUREI_VERSION"
-X hakurei.app/internal/info.hakureiPath=/system/bin/hakurei
diff --git a/internal/rosa/kernel.go b/internal/rosa/kernel.go
index bd3a1446..def556ce 100644
--- a/internal/rosa/kernel.go
+++ b/internal/rosa/kernel.go
@@ -29,7 +29,7 @@ func (t Toolchain) newKernelHeaders() pkg.Artifact {
"-f /usr/src/kernel-headers/Makefile",
"O=/tmp/kbuild",
"LLVM=1",
- `HOSTLDFLAGS="${LDFLAGS}"`,
+ `HOSTLDFLAGS="${LDFLAGS:-''}"`,
"INSTALL_HDR_PATH=/work/system",
"headers_install",
},
diff --git a/internal/rosa/libcap.go b/internal/rosa/libcap.go
index 804581c1..46492911 100644
--- a/internal/rosa/libcap.go
+++ b/internal/rosa/libcap.go
@@ -31,7 +31,7 @@ cd /usr/src/libcap
"CC=cc",
"all",
},
- CheckName: "test",
+ Check: []string{"test"},
},
t.Load(Bash),
t.Load(Diffutils),
diff --git a/internal/rosa/libgd.go b/internal/rosa/libgd.go
index 6f2991d4..fe88cbef 100644
--- a/internal/rosa/libgd.go
+++ b/internal/rosa/libgd.go
@@ -20,9 +20,6 @@ func (t Toolchain) newLibgd() pkg.Artifact {
ScriptEarly: `
mkdir /dev/shm/gd
`,
- Configure: [][2]string{
- {"enable-static"},
- },
},
t.Load(Zlib),
)
diff --git a/internal/rosa/libseccomp.go b/internal/rosa/libseccomp.go
index b9b31362..1c2794b0 100644
--- a/internal/rosa/libseccomp.go
+++ b/internal/rosa/libseccomp.go
@@ -19,9 +19,6 @@ func (t Toolchain) newLibseccomp() pkg.Artifact {
ScriptEarly: `
ln -s ../system/bin/bash /bin/
`,
- Configure: [][2]string{
- {"enable-static"},
- },
},
t.Load(Bash),
t.Load(Diffutils),
diff --git a/internal/rosa/libxml2.go b/internal/rosa/libxml2.go
index 12013e52..058977e5 100644
--- a/internal/rosa/libxml2.go
+++ b/internal/rosa/libxml2.go
@@ -22,9 +22,6 @@ cd /usr/src/
tar xf libxml2.tar.xz
mv libxml2-` + version + ` libxml2
`,
- Configure: [][2]string{
- {"enable-static"},
- },
SourceSuffix: ".tar.xz",
},
t.Load(Diffutils),
diff --git a/internal/rosa/libxslt.go b/internal/rosa/libxslt.go
index 1531a88e..db1fc41c 100644
--- a/internal/rosa/libxslt.go
+++ b/internal/rosa/libxslt.go
@@ -22,9 +22,6 @@ cd /usr/src/
tar xf libxslt.tar.xz
mv libxslt-` + version + ` libxslt
`,
- Configure: [][2]string{
- {"enable-static"},
- },
SourceSuffix: ".tar.xz",
// python libxml2 cyclic dependency
diff --git a/internal/rosa/make.go b/internal/rosa/make.go
index 4d45f32c..fb74039c 100644
--- a/internal/rosa/make.go
+++ b/internal/rosa/make.go
@@ -45,6 +45,8 @@ type MakeAttr struct {
ScriptEarly string
// Runs after configure.
ScriptConfigured string
+ // Runs before check.
+ ScriptCheckEarly string
// Runs after install.
Script string
@@ -66,7 +68,7 @@ type MakeAttr struct {
// Whether to skip the check target.
SkipCheck bool
// Name of the check target, zero value is equivalent to "check".
- CheckName string
+ Check []string
// Replaces the default install command.
ScriptInstall string
@@ -93,31 +95,30 @@ func (t Toolchain) NewViaMake(
attr = new(MakeAttr)
}
- host := `"${ROSA_TRIPLE}"`
- if attr.Host != "" {
- host = attr.Host
- }
- build := `"${ROSA_TRIPLE}"`
- if attr.Build != "" {
- build = attr.Build
- }
-
var configure string
if !attr.SkipConfigure {
configure = attr.ConfigureName
if configure == "" {
- configure += `
-/usr/src/` + name + `/configure \
+ configure += `/usr/src/` + name + `/configure \
--prefix=/system`
- }
- if attr.Host != `""` {
- configure += ` \
+ host := `"${ROSA_TRIPLE}"`
+ if attr.Host != "" {
+ host = attr.Host
+ }
+ if attr.Host != `""` {
+ configure += ` \
--host=` + host
- }
- if attr.Build != `""` {
- configure += ` \
+ }
+
+ build := `"${ROSA_TRIPLE}"`
+ if attr.Build != "" {
+ build = attr.Build
+ }
+ if attr.Build != `""` {
+ configure += ` \
--build=` + build
+ }
}
if len(attr.Configure) > 0 {
@@ -149,17 +150,25 @@ func (t Toolchain) NewViaMake(
}
}
- makeTargets := make([]string, 1, 2+len(attr.Make))
+ scriptMake := `
+make \
+ "-j$(nproc)"`
+ if len(attr.Make) > 0 {
+ scriptMake += " \\\n\t" + strings.Join(attr.Make, " \\\n\t")
+ }
+ scriptMake += "\n"
+
if !attr.SkipCheck {
- if attr.CheckName == "" {
- makeTargets = append(makeTargets, "check")
+ scriptMake += attr.ScriptCheckEarly + `
+make \
+ "-j$(nproc)" \
+ `
+ if len(attr.Check) > 0 {
+ scriptMake += strings.Join(attr.Check, " \\\n\t")
} else {
- makeTargets = append(makeTargets, attr.CheckName)
+ scriptMake += "check"
}
- }
- makeTargets = append(makeTargets, attr.Make...)
- if len(makeTargets) == 1 {
- makeTargets = nil
+ scriptMake += "\n"
}
var finalExtra []pkg.Artifact
@@ -176,7 +185,9 @@ func (t Toolchain) NewViaMake(
scriptEarly := attr.ScriptEarly
if !attr.InPlace {
- scriptEarly += "\ncd \"$(mktemp -d)\""
+ scriptEarly += `
+cd "$(mktemp -d)"
+`
} else if scriptEarly == "" {
panic("cannot remain in root")
}
@@ -187,14 +198,25 @@ func (t Toolchain) NewViaMake(
}
scriptInstall += "\n"
- return t.New(name+"-"+version, attr.Flag, stage0Concat(t,
- attr.NonStage0,
- finalExtra...,
- ), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+`
-make "-j$(nproc)"`+strings.Join(makeTargets, " ")+`
-`+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{
- pkg.Path(AbsUsrSrc.Append(
- name+attr.SourceSuffix,
- ), attr.Writable, source),
- })...)
+ return t.New(
+ name+"-"+version,
+ attr.Flag,
+ stage0Concat(t,
+ attr.NonStage0,
+ finalExtra...,
+ ),
+ nil,
+ attr.Env,
+ scriptEarly+
+ configure+
+ attr.ScriptConfigured+
+ scriptMake+
+ scriptInstall+
+ attr.Script,
+ slices.Concat(attr.Paths, []pkg.ExecPath{
+ pkg.Path(AbsUsrSrc.Append(
+ name+attr.SourceSuffix,
+ ), attr.Writable, source),
+ })...,
+ )
}
diff --git a/internal/rosa/openssl.go b/internal/rosa/openssl.go
index df8c4a94..63617141 100644
--- a/internal/rosa/openssl.go
+++ b/internal/rosa/openssl.go
@@ -13,24 +13,24 @@ func (t Toolchain) newOpenSSL() pkg.Artifact {
mustDecode(checksum),
pkg.TarGzip,
), &MakeAttr{
- OmitDefaults: true,
- SkipConfigure: true,
+ OmitDefaults: true,
Env: []string{
"CC=cc",
},
- ScriptConfigured: `
-/usr/src/openssl/Configure \
- --prefix=/system \
- --libdir=lib \
- --openssldir=etc/ssl
-`,
- CheckName: "test",
- Make: []string{
+ ConfigureName: "/usr/src/openssl/Configure",
+ Configure: [][2]string{
+ {"prefix", "/system"},
+ {"libdir", "lib"},
+ {"openssldir", "etc/ssl"},
+ },
+ Check: []string{
`HARNESS_JOBS="$(expr "$(nproc)" '*' 2)"`,
+ "test",
},
},
t.Load(Perl),
+ t.Load(Coreutils),
t.Load(Zlib),
t.Load(KernelHeaders),
diff --git a/internal/rosa/perl.go b/internal/rosa/perl.go
index 63b512dd..2598cdc1 100644
--- a/internal/rosa/perl.go
+++ b/internal/rosa/perl.go
@@ -29,8 +29,6 @@ echo 'print STDOUT "1..0 # Skip broken test\n";' > ext/Pod-Html/t/htmldir3.t
rm -f /system/bin/ps # perl does not like toybox ps
`,
ConfigureName: "./Configure",
- Host: `""`,
- Build: `""`,
Configure: [][2]string{
{"-des"},
{"Dprefix", "/system"},
@@ -40,7 +38,10 @@ rm -f /system/bin/ps # perl does not like toybox ps
{"Doptimize", "'-O2 -fno-strict-aliasing'"},
{"Duseithreads"},
},
- CheckName: "TEST_JOBS=256 test_harness",
+ Check: []string{
+ "TEST_JOBS=256",
+ "test_harness",
+ },
ScriptInstall: "./perl -Ilib -I. installperl --destdir=/work",
Flag: TEarly,
@@ -95,16 +96,18 @@ func (t Toolchain) newViaPerlMakeMaker(
return t.NewViaMake("perl-"+name, version, t.NewPatchedSource(
"perl-"+name, version, source, false, patches...,
), &MakeAttr{
- Writable: true,
- OmitDefaults: true,
- SkipConfigure: true,
- InPlace: true,
+ Writable: true,
+ OmitDefaults: true,
+ InPlace: true,
ScriptEarly: `
cd /usr/src/perl-` + name + `
-perl Makefile.PL PREFIX=/system
`,
- CheckName: "test",
+ ConfigureName: "perl Makefile.PL",
+ Configure: [][2]string{
+ {"PREFIX", "/system"},
+ },
+ Check: []string{"test"},
}, slices.Concat(extra, []pkg.Artifact{
t.Load(Perl),
})...)
diff --git a/internal/rosa/python.go b/internal/rosa/python.go
index 069b574d..2c98424b 100644
--- a/internal/rosa/python.go
+++ b/internal/rosa/python.go
@@ -48,12 +48,7 @@ func (t Toolchain) newPython() pkg.Artifact {
"LDFLAGS=-Wl,--dynamic-linker=/system/lib/" +
"ld-musl-" + linuxArch() + ".so.1",
},
-
- ScriptEarly: `
-export HOME="$(mktemp -d)"
-`,
-
- CheckName: "test",
+ Check: []string{"test"},
},
t.Load(Zlib),
t.Load(Libffi),
diff --git a/internal/rosa/qemu.go b/internal/rosa/qemu.go
index 07787c91..34241e0b 100644
--- a/internal/rosa/qemu.go
+++ b/internal/rosa/qemu.go
@@ -1,8 +1,6 @@
package rosa
-import (
- "hakurei.app/internal/pkg"
-)
+import "hakurei.app/internal/pkg"
func (t Toolchain) newQEMU() pkg.Artifact {
const (
@@ -57,7 +55,6 @@ _notrun 'appears to spuriously fail on zfs'
EOF
)
`,
-
Configure: [][2]string{
{"disable-download"},
{"disable-docs"},
@@ -70,10 +67,6 @@ EOF
"ppc-softmmu," +
"ppc64-softmmu"},
},
-
- ScriptConfigured: `
-make "-j$(nproc)"
-`,
},
t.Load(Bash),
t.Load(Python),
diff --git a/internal/rosa/toybox.go b/internal/rosa/toybox.go
index aa646db6..329ad736 100644
--- a/internal/rosa/toybox.go
+++ b/internal/rosa/toybox.go
@@ -19,7 +19,7 @@ func (t Toolchain) newToybox(suffix, script string) pkg.Artifact {
SkipConfigure: true,
ScriptEarly: `
-LDFLAGS="${LDFLAGS} -static"
+LDFLAGS="${LDFLAGS:-''} -static"
chmod +w /bin/
ln -rs "$(which bash)" /bin/ || true
@@ -37,13 +37,14 @@ make defconfig
sed -i \
's/^CONFIG_TOYBOX_ZHELP=y$/CONFIG_TOYBOX_ZHELP=0/' \
.config
-
-make "-j$(nproc)"
`,
ScriptConfigured: script,
- CheckName: "USER=cure tests",
SkipCheck: t.isStage0(),
- ScriptInstall: "PREFIX=/work/system/bin make install_flat",
+ Check: []string{
+ "USER=cure",
+ "tests",
+ },
+ ScriptInstall: "PREFIX=/work/system/bin make install_flat",
Script: `
mkdir -p /work/usr/bin
ln -s ../../system/bin/env /work/usr/bin
diff --git a/internal/rosa/x.go b/internal/rosa/x.go
index 19777bde..191bbe6f 100644
--- a/internal/rosa/x.go
+++ b/internal/rosa/x.go
@@ -64,10 +64,6 @@ func (t Toolchain) newLibXau() pkg.Artifact {
cd /usr/src/libXau
autoreconf -if
`,
-
- Configure: [][2]string{
- {"enable-static"},
- },
},
t.Load(M4),
t.Load(Perl),
diff --git a/internal/rosa/xcb.go b/internal/rosa/xcb.go
index b659cf2e..b35c5171 100644
--- a/internal/rosa/xcb.go
+++ b/internal/rosa/xcb.go
@@ -11,11 +11,7 @@ func (t Toolchain) newXCBProto() pkg.Artifact {
nil, "https://xcb.freedesktop.org/dist/xcb-proto-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- ), &MakeAttr{
- Configure: [][2]string{
- {"enable-static"},
- },
- },
+ ), nil,
t.Load(Python),
)
}
@@ -30,11 +26,7 @@ func (t Toolchain) newXCB() pkg.Artifact {
nil, "https://xcb.freedesktop.org/dist/libxcb-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- ), &MakeAttr{
- Configure: [][2]string{
- {"enable-static"},
- },
- },
+ ), nil,
t.Load(Python),
t.Load(PkgConfig),