aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-19 03:24:27 +0900
committerOphestra <cat@gensokyo.uk>2026-05-19 03:24:27 +0900
commit8092492018a520b997f688a617ccb0684cb82b4b (patch)
treea89878652c0a30cb50305b6f3de340b73a595463 /internal
parenta7877844bf93d9e15cc4f90e99d6e283d59b74ab (diff)
internal/rosa/perl: Makefile.PL helper
This can be invoked from azalea. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/rosa/perl.go64
-rw-r--r--internal/rosa/python.go3
-rw-r--r--internal/rosa/rosa.go2
-rw-r--r--internal/rosa/state_native.go2
4 files changed, 53 insertions, 18 deletions
diff --git a/internal/rosa/perl.go b/internal/rosa/perl.go
index 965aad06..93dc0de1 100644
--- a/internal/rosa/perl.go
+++ b/internal/rosa/perl.go
@@ -7,6 +7,9 @@ import (
"hakurei.app/internal/pkg"
)
+// Perl is the perl interpreter used by [MakeMakerHelper].
+var Perl = H("perl")
+
// newViaPerlModuleBuild installs a perl module via Build.PL.
func (t Toolchain) newViaPerlModuleBuild(
name, version string,
@@ -54,6 +57,51 @@ func init() {
})
}
+// MakeMakerHelper is the [Perl] MakeMaker helper.
+type MakeMakerHelper struct {
+ // Whether to skip the check target.
+ SkipCheck bool
+}
+
+// extra returns perl.
+func (*MakeMakerHelper) extra(int) P { return P{Perl, Make} }
+
+// wantsChmod returns true.
+func (*MakeMakerHelper) wantsChmod() bool { return true }
+
+// wantsWrite returns true.
+func (*MakeMakerHelper) wantsWrite() bool { return true }
+
+// scriptEarly is a noop.
+func (*MakeMakerHelper) scriptEarly() string { return "" }
+
+// createDir returns false.
+func (*MakeMakerHelper) createDir() bool { return false }
+
+// wantsDir returns the zero value.
+func (*MakeMakerHelper) wantsDir() string { return "" }
+
+// script generates Makefile.PL-based build and test commands.
+func (attr *MakeMakerHelper) script(t Toolchain, _ string) string {
+ if attr == nil {
+ attr = new(MakeMakerHelper)
+ }
+
+ script := `perl Makefile.PL \
+ PREFIX=/system
+make \
+ ` + jobsFlagE
+ if !attr.SkipCheck && t.opts&OptSkipCheck == 0 {
+ script += `
+make \
+ ` + jobsFlagE + ` \
+ test
+`
+ }
+ script += "make DESTDIR=/work install\n"
+ return script
+}
+
// newViaPerlMakeMaker installs a perl module via Makefile.PL.
func (t Toolchain) newViaPerlMakeMaker(
name, version string,
@@ -62,22 +110,8 @@ func (t Toolchain) newViaPerlMakeMaker(
extra ...ArtifactH,
) pkg.Artifact {
return t.NewPackage("perl-"+name, version, source, &PackageAttr{
- // uses source tree as scratch space
- Writable: true,
- Chmod: true,
- EnterSource: true,
-
Patches: patches,
- }, &MakeHelper{
- OmitDefaults: true,
- InPlace: true,
-
- ConfigureName: "perl Makefile.PL",
- Configure: []KV{
- {"PREFIX", "/system"},
- },
- Check: []string{"test"},
- }, slices.Concat(extra, P{
+ }, (*MakeMakerHelper)(nil), slices.Concat(extra, P{
Perl,
})...)
}
diff --git a/internal/rosa/python.go b/internal/rosa/python.go
index 1e4cbca8..4b85399b 100644
--- a/internal/rosa/python.go
+++ b/internal/rosa/python.go
@@ -7,6 +7,9 @@ import (
"hakurei.app/internal/pkg"
)
+// Python is the python interpreter used by [PipHelper].
+var Python = H("python")
+
// PipHelper is the [Python] pip packaging helper.
type PipHelper struct {
// Path elements joined with source.
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go
index 209b8942..44a463af 100644
--- a/internal/rosa/rosa.go
+++ b/internal/rosa/rosa.go
@@ -523,7 +523,7 @@ cd '/usr/src/` + name + `/'
scriptEarly += "\nmkdir -p " + dir
}
scriptEarly += "\ncd " + dir + "\n"
- } else if !attr.EnterSource && attr.ScriptEarly == "" {
+ } else if !attr.EnterSource && attr.ScriptEarly == "" && dir != "" {
panic("cannot remain in root")
}
diff --git a/internal/rosa/state_native.go b/internal/rosa/state_native.go
index c05814f2..d1a47fe3 100644
--- a/internal/rosa/state_native.go
+++ b/internal/rosa/state_native.go
@@ -118,7 +118,6 @@ var (
PCRE2 = H("pcre2")
Parallel = H("parallel")
Patch = H("patch")
- Perl = H("perl")
PerlLocaleGettext = H("perl-Locale::gettext")
PerlMIMECharset = H("perl-MIME::Charset")
PerlModuleBuild = H("perl-Module::Build")
@@ -133,7 +132,6 @@ var (
Pixman = H("pixman")
PkgConfig = H("pkg-config")
Procps = H("procps")
- Python = H("python")
PythonFlitCore = H("python-flit-core")
PythonHatchling = H("python-hatchling")
PythonIniConfig = H("python-iniconfig")