internal/rosa/perl: Makefile.PL helper
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m47s
Test / Hakurei (push) Successful in 3m47s
Test / ShareFS (push) Successful in 3m46s
Test / Sandbox (race detector) (push) Successful in 5m24s
Test / Hakurei (race detector) (push) Successful in 6m30s
Test / Flake checks (push) Successful in 1m24s

This can be invoked from azalea.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-19 03:24:27 +09:00
parent a7877844bf
commit 8092492018
4 changed files with 53 additions and 18 deletions

View File

@@ -7,6 +7,9 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
// Perl is the perl interpreter used by [MakeMakerHelper].
var Perl = H("perl")
// newViaPerlModuleBuild installs a perl module via Build.PL. // newViaPerlModuleBuild installs a perl module via Build.PL.
func (t Toolchain) newViaPerlModuleBuild( func (t Toolchain) newViaPerlModuleBuild(
name, version string, 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. // newViaPerlMakeMaker installs a perl module via Makefile.PL.
func (t Toolchain) newViaPerlMakeMaker( func (t Toolchain) newViaPerlMakeMaker(
name, version string, name, version string,
@@ -62,22 +110,8 @@ func (t Toolchain) newViaPerlMakeMaker(
extra ...ArtifactH, extra ...ArtifactH,
) pkg.Artifact { ) pkg.Artifact {
return t.NewPackage("perl-"+name, version, source, &PackageAttr{ return t.NewPackage("perl-"+name, version, source, &PackageAttr{
// uses source tree as scratch space
Writable: true,
Chmod: true,
EnterSource: true,
Patches: patches, Patches: patches,
}, &MakeHelper{ }, (*MakeMakerHelper)(nil), slices.Concat(extra, P{
OmitDefaults: true,
InPlace: true,
ConfigureName: "perl Makefile.PL",
Configure: []KV{
{"PREFIX", "/system"},
},
Check: []string{"test"},
}, slices.Concat(extra, P{
Perl, Perl,
})...) })...)
} }

View File

@@ -7,6 +7,9 @@ import (
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
) )
// Python is the python interpreter used by [PipHelper].
var Python = H("python")
// PipHelper is the [Python] pip packaging helper. // PipHelper is the [Python] pip packaging helper.
type PipHelper struct { type PipHelper struct {
// Path elements joined with source. // Path elements joined with source.

View File

@@ -523,7 +523,7 @@ cd '/usr/src/` + name + `/'
scriptEarly += "\nmkdir -p " + dir scriptEarly += "\nmkdir -p " + dir
} }
scriptEarly += "\ncd " + dir + "\n" scriptEarly += "\ncd " + dir + "\n"
} else if !attr.EnterSource && attr.ScriptEarly == "" { } else if !attr.EnterSource && attr.ScriptEarly == "" && dir != "" {
panic("cannot remain in root") panic("cannot remain in root")
} }

View File

@@ -118,7 +118,6 @@ var (
PCRE2 = H("pcre2") PCRE2 = H("pcre2")
Parallel = H("parallel") Parallel = H("parallel")
Patch = H("patch") Patch = H("patch")
Perl = H("perl")
PerlLocaleGettext = H("perl-Locale::gettext") PerlLocaleGettext = H("perl-Locale::gettext")
PerlMIMECharset = H("perl-MIME::Charset") PerlMIMECharset = H("perl-MIME::Charset")
PerlModuleBuild = H("perl-Module::Build") PerlModuleBuild = H("perl-Module::Build")
@@ -133,7 +132,6 @@ var (
Pixman = H("pixman") Pixman = H("pixman")
PkgConfig = H("pkg-config") PkgConfig = H("pkg-config")
Procps = H("procps") Procps = H("procps")
Python = H("python")
PythonFlitCore = H("python-flit-core") PythonFlitCore = H("python-flit-core")
PythonHatchling = H("python-hatchling") PythonHatchling = H("python-hatchling")
PythonIniConfig = H("python-iniconfig") PythonIniConfig = H("python-iniconfig")