Files
hakurei/internal/rosa/perl.go
Ophestra 8092492018 internal/rosa/perl: Makefile.PL helper
This can be invoked from azalea.

Signed-off-by: Ophestra <cat@gensokyo.uk>
2026-05-19 03:24:27 +09:00

364 lines
8.7 KiB
Go

package rosa
import (
"slices"
"strings"
"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,
source pkg.Artifact,
patches []KV,
extra ...ArtifactH,
) pkg.Artifact {
if name == "" || version == "" {
panic("names must be non-empty")
}
return t.New("perl-"+name, 0, t.Append(nil,
slices.Concat(P{Perl}, extra)...,
), nil, nil, `
cd /usr/src/`+name+`
perl Build.PL --prefix=/system
./Build build
./Build test
./Build install --destdir=/work
`, pkg.Path(AbsUsrSrc.Append(name), true, t.NewPatchedSource(
"perl-"+name, version, source, false, patches...,
)))
}
func (t Toolchain) newPerlModuleBuild() (pkg.Artifact, string) {
const (
version = "0.4234"
checksum = "ZKxEFG4hE1rqZt52zBL2LRZBMkYzhjb5-cTBXcsyA52EbPeeYyVxU176yAea8-Di"
)
return t.newViaPerlModuleBuild("Module-Build", version, newTar(
"https://cpan.metacpan.org/authors/id/L/LE/LEONT/"+
"Module-Build-"+version+".tar.gz",
checksum,
pkg.TarGzip,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlModuleBuild, &Metadata{
Name: "perl-Module::Build",
Description: "build and install Perl modules",
Website: "https://metacpan.org/release/Module-Build",
Dependencies: P{
Perl,
},
})
}
// 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,
source pkg.Artifact,
patches []KV,
extra ...ArtifactH,
) pkg.Artifact {
return t.NewPackage("perl-"+name, version, source, &PackageAttr{
Patches: patches,
}, (*MakeMakerHelper)(nil), slices.Concat(extra, P{
Perl,
})...)
}
func (t Toolchain) newPerlLocaleGettext() (pkg.Artifact, string) {
const (
version = "1.07"
checksum = "cFq4BKFD1MWSoa7lsrPjpdo9kzPqd0jlRcBFUyL1L1isw8m3D_Sge_ff0MAu_9J3"
)
return t.newViaPerlMakeMaker("Locale::gettext", version, newFromCPAN(
"PVANDRY",
"Locale-gettext",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlLocaleGettext, &Metadata{
Name: "perl-Locale::gettext",
Description: "message handling functions",
Website: "https://metacpan.org/release/Locale-gettext",
ID: 7523,
})
}
func (t Toolchain) newPerlPodParser() (pkg.Artifact, string) {
const (
version = "1.67"
checksum = "RdURu9mOfExk_loCp6abxlcQV3FycSNbTqhRS9i6JUqnYfGGEgercK30g0gjYyqe"
)
return t.newViaPerlMakeMaker("Pod::Parser", version, newFromCPAN(
"MAREKR",
"Pod-Parser",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlPodParser, &Metadata{
Name: "perl-Pod::Parser",
Description: "base class for creating POD filters and translators",
Website: "https://metacpan.org/release/Pod-Parser",
ID: 3244,
})
}
func (t Toolchain) newPerlSGMLS() (pkg.Artifact, string) {
const (
version = "1.1"
checksum = "aZijn4MUqD-wfyZgdcCruCwl4SgDdu25cNmJ4_UvdAk9a7uz4gzMQdoeB6DQ6QOy"
)
return t.newViaPerlMakeMaker("SGMLS", version, newFromCPAN(
"RAAB",
"SGMLSpm",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlSGMLS, &Metadata{
Name: "perl-SGMLS",
Description: "class for postprocessing the output from the sgmls and nsgmls parsers",
Website: "https://metacpan.org/release/RAAB/SGMLSpm-1.1",
ID: 389576,
latest: func(v *Versions) string {
for _, s := range v.Stable {
_, m, ok := strings.Cut(s, ".")
if !ok {
continue
}
if len(m) > 1 && m[0] == '0' {
continue
}
return s
}
return v.Latest
},
})
}
func (t Toolchain) newPerlTermReadKey() (pkg.Artifact, string) {
const (
version = "2.38"
checksum = "qerL8Xo7kD0f42PZoiEbmE8Roc_S9pOa27LXelY4DN_0UNy_u5wLrGHI8utNlaiI"
)
return t.newViaPerlMakeMaker("Term::ReadKey", version, newFromCPAN(
"JSTOWE",
"TermReadKey",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlTermReadKey, &Metadata{
Name: "perl-Term::ReadKey",
Description: "a perl module for simple terminal control",
Website: "https://metacpan.org/release/TermReadKey",
ID: 3372,
})
}
func (t Toolchain) newPerlTextCharWidth() (pkg.Artifact, string) {
const (
version = "0.04"
checksum = "G2p5RHU4_HiZ23ZusBA_enTlVMxz0J4esUx4CGcOPhY6xYTbp-aXWRN6lYZpzBw2"
)
return t.newViaPerlMakeMaker("Text::CharWidth", version, newFromCPAN(
"KUBOTA",
"Text-CharWidth",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlTextCharWidth, &Metadata{
Name: "perl-Text::CharWidth",
Description: "get number of occupied columns of a string on terminal",
Website: "https://metacpan.org/release/Text-CharWidth",
ID: 14380,
})
}
func (t Toolchain) newPerlTextWrapI18N() (pkg.Artifact, string) {
const (
version = "0.06"
checksum = "Vmo89qLgxUqyQ6QmWJVqu60aQAUjrNKRjFQSXGnvClxofzRjiCa6idzPgJ4VkixM"
)
return t.newViaPerlMakeMaker("Text::WrapI18N", version, newFromCPAN(
"KUBOTA",
"Text-WrapI18N",
version,
checksum,
), nil,
PerlTextCharWidth,
), version
}
func init() {
native.mustRegister(Toolchain.newPerlTextWrapI18N, &Metadata{
Name: "perl-Text::WrapI18N",
Description: "line wrapping module",
Website: "https://metacpan.org/release/Text-WrapI18N",
Dependencies: P{
PerlTextCharWidth,
},
ID: 14385,
})
}
func (t Toolchain) newPerlMIMECharset() (pkg.Artifact, string) {
const (
version = "1.013.1"
checksum = "Ou_ukcrOa1cgtE3mptinb-os3bdL1SXzbRDFZQF3prrJj-drc3rp_huay7iDLJol"
)
return t.newViaPerlMakeMaker("MIME::Charset", version, newFromCPAN(
"NEZUMI",
"MIME-Charset",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlMIMECharset, &Metadata{
Name: "perl-MIME::Charset",
Description: "Charset Information for MIME",
Website: "https://metacpan.org/release/MIME-Charset",
ID: 3070,
})
}
func (t Toolchain) newPerlUnicodeLineBreak() (pkg.Artifact, string) {
const (
version = "2019.001"
checksum = "ZHVkh7EDgAUHnTpvXsnPAuWpgNoBImtY_9_8TIbo2co_WgUwEb0MtXPhI8pAZ5OH"
)
return t.newViaPerlMakeMaker("Unicode::LineBreak", version, newFromCPAN(
"NEZUMI",
"Unicode-LineBreak",
version,
checksum,
), nil,
PerlMIMECharset,
), version
}
func init() {
native.mustRegister(Toolchain.newPerlUnicodeLineBreak, &Metadata{
Name: "perl-Unicode::LineBreak",
Description: "String as Sequence of UAX #29 Grapheme Clusters",
Website: "https://metacpan.org/release/Unicode-LineBreak",
Dependencies: P{
PerlMIMECharset,
},
ID: 6033,
})
}
func (t Toolchain) newPerlYAMLTiny() (pkg.Artifact, string) {
const (
version = "1.76"
checksum = "V1MV4KPym1LxSw8CRXqPR3K-l1hGHbT5Ob4t-9xju6R9X_CWyw6hI8wsMaNdHdBY"
)
return t.newViaPerlMakeMaker("YAML::Tiny", version, newFromCPAN(
"ETHER",
"YAML-Tiny",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlYAMLTiny, &Metadata{
Name: "perl-YAML::Tiny",
Description: "read/write YAML files with as little code as possible",
Website: "https://metacpan.org/release/YAML-Tiny",
ID: 3549,
})
}
func (t Toolchain) newPerlTestCmd() (pkg.Artifact, string) {
const (
version = "1.09"
checksum = "gpGUwyC9IozDiYSgW_kXARNfXsTPFa6cTowJmmCBbPqcs2-pONZca_SB06FGy-7H"
)
return t.newViaPerlMakeMaker("Test::Cmd", version, newFromCPAN(
"NEILB",
"Test-Cmd",
version,
checksum,
), nil), version
}
func init() {
native.mustRegister(Toolchain.newPerlTestCmd, &Metadata{
Name: "perl-Test::Cmd",
Description: "portable testing of commands and scripts",
Website: "https://metacpan.org/release/Test-Cmd",
ID: 6014,
})
}