internal/rosa: expose in-place behaviour in generic helper
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 3m14s
Test / Hakurei (push) Successful in 4m23s
Test / ShareFS (push) Successful in 4m22s
Test / Sandbox (race detector) (push) Successful in 5m47s
Test / Hakurei (race detector) (push) Successful in 6m51s
Test / Flake checks (push) Successful in 1m29s
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 3m14s
Test / Hakurei (push) Successful in 4m23s
Test / ShareFS (push) Successful in 4m22s
Test / Sandbox (race detector) (push) Successful in 5m47s
Test / Hakurei (race detector) (push) Successful in 6m51s
Test / Flake checks (push) Successful in 1m29s
This change also combines the createDir and wantsDir methods, and replaces the non-inplace target of the generic helper with a deterministic path. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -48,11 +48,8 @@ func (*CMakeHelper) wantsWrite() bool { return false }
|
||||
// scriptEarly returns the zero value.
|
||||
func (*CMakeHelper) scriptEarly() string { return "" }
|
||||
|
||||
// createDir returns true.
|
||||
func (*CMakeHelper) createDir() bool { return true }
|
||||
|
||||
// wantsDir returns a hardcoded, deterministic pathname.
|
||||
func (*CMakeHelper) wantsDir() string { return "/cure/" }
|
||||
func (*CMakeHelper) wantsDir() (string, bool) { return "/cure/", true }
|
||||
|
||||
// script generates the cure script.
|
||||
func (attr *CMakeHelper) script(t Toolchain, name string) string {
|
||||
|
||||
@@ -82,15 +82,12 @@ func (attr *MakeHelper) scriptEarly() string {
|
||||
return generate
|
||||
}
|
||||
|
||||
// createDir returns false.
|
||||
func (*MakeHelper) createDir() bool { return false }
|
||||
|
||||
// wantsDir requests a new directory in TMPDIR, or omits the cd statement if InPlace.
|
||||
func (attr *MakeHelper) wantsDir() string {
|
||||
func (attr *MakeHelper) wantsDir() (string, bool) {
|
||||
if attr != nil && attr.InPlace {
|
||||
return helperInPlace
|
||||
return helperInPlace, false
|
||||
}
|
||||
return `"$(mktemp -d)"`
|
||||
return `"$(mktemp -d)"`, false
|
||||
}
|
||||
|
||||
// script generates the cure script.
|
||||
|
||||
@@ -36,11 +36,8 @@ func (*MesonHelper) wantsWrite() bool { return false }
|
||||
// scriptEarly returns the zero value.
|
||||
func (*MesonHelper) scriptEarly() string { return "" }
|
||||
|
||||
// createDir returns false.
|
||||
func (*MesonHelper) createDir() bool { return false }
|
||||
|
||||
// wantsDir requests a new directory in TMPDIR.
|
||||
func (*MesonHelper) wantsDir() string { return `"$(mktemp -d)"` }
|
||||
func (*MesonHelper) wantsDir() (string, bool) { return `"$(mktemp -d)"`, false }
|
||||
|
||||
// script generates the cure script.
|
||||
func (attr *MesonHelper) script(t Toolchain, name string) string {
|
||||
|
||||
@@ -153,7 +153,9 @@ package gen_init_cpio {
|
||||
description = "a program in the kernel source tree for creating initramfs archive";
|
||||
source = kernel-source;
|
||||
|
||||
enterSource = true;
|
||||
exec = generic {
|
||||
inPlace = true;
|
||||
build = `
|
||||
mkdir -p /work/system/bin/
|
||||
cc -o /work/system/bin/gen_init_cpio usr/gen_init_cpio.c
|
||||
|
||||
@@ -13,7 +13,6 @@ package make {
|
||||
toyboxEarly = true;
|
||||
|
||||
exec = generic {
|
||||
mktemp = true;
|
||||
build = `/usr/src/make/configure \
|
||||
--prefix=/system \
|
||||
--build="${ROSA_TRIPLE}" \
|
||||
|
||||
@@ -16,8 +16,6 @@ package mksh {
|
||||
];
|
||||
|
||||
exec = generic {
|
||||
mktemp = true;
|
||||
|
||||
build = `sh /usr/src/mksh/Build.sh -r
|
||||
CPPFLAGS="${CPPFLAGS} -DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED" \
|
||||
sh /usr/src/mksh/Build.sh -r -L
|
||||
|
||||
@@ -78,7 +78,9 @@ package nss-cacert {
|
||||
|
||||
source = nss;
|
||||
|
||||
enterSource = true;
|
||||
exec = generic {
|
||||
inPlace = true;
|
||||
build = `
|
||||
mkdir -p /work/system/etc/ssl/{certs/unbundled,certs/hashed,trust-source}
|
||||
buildcatrust \
|
||||
|
||||
@@ -59,10 +59,12 @@ package perl-Module-Build {
|
||||
checksum = "ZKxEFG4hE1rqZt52zBL2LRZBMkYzhjb5-cTBXcsyA52EbPeeYyVxU176yAea8-Di";
|
||||
};
|
||||
|
||||
enterSource = true;
|
||||
writable = true;
|
||||
chmod = true;
|
||||
|
||||
exec = generic {
|
||||
inPlace = true;
|
||||
build = `
|
||||
perl Build.PL --prefix=/system
|
||||
./Build build`;
|
||||
|
||||
@@ -15,10 +15,12 @@ package unzip {
|
||||
compress = gzip;
|
||||
};
|
||||
|
||||
enterSource = true;
|
||||
writable = true;
|
||||
chmod = true;
|
||||
|
||||
exec = generic {
|
||||
inPlace = true;
|
||||
build = `unix/configure
|
||||
make -f unix/Makefile generic1`;
|
||||
install = `
|
||||
|
||||
@@ -26,11 +26,8 @@ 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 "" }
|
||||
// wantsDir requests the source directory.
|
||||
func (*MakeMakerHelper) wantsDir() (string, bool) { return "", false }
|
||||
|
||||
// script generates Makefile.PL-based build and test commands.
|
||||
func (attr *MakeMakerHelper) script(t Toolchain, _ string) string {
|
||||
|
||||
@@ -48,11 +48,8 @@ func (attr *PipHelper) wantsWrite() bool { return attr.wantsChmod() }
|
||||
// scriptEarly is a noop.
|
||||
func (*PipHelper) scriptEarly() string { return "" }
|
||||
|
||||
// createDir returns false.
|
||||
func (*PipHelper) createDir() bool { return false }
|
||||
|
||||
// wantsDir requests a new directory in TMPDIR.
|
||||
func (*PipHelper) wantsDir() string { return `"$(mktemp -d)"` }
|
||||
func (*PipHelper) wantsDir() (string, bool) { return `"$(mktemp -d)"`, false }
|
||||
|
||||
// script generates the pip3 install command.
|
||||
func (attr *PipHelper) script(_ Toolchain, name string) string {
|
||||
|
||||
@@ -397,13 +397,11 @@ type Helper interface {
|
||||
// scriptEarly returns the helper-specific segment of cure script that goes
|
||||
// before the cd statement.
|
||||
scriptEarly() string
|
||||
// createDir returns whether the path returned by wantsDir should be created.
|
||||
createDir() bool
|
||||
// wantsDir returns the directory to enter before script.
|
||||
//
|
||||
// The zero value implies source directory if [PackageAttr.ScriptEarly] is
|
||||
// also empty. The special value helperInPlace omits the cd statement.
|
||||
wantsDir() string
|
||||
wantsDir() (pathname string, create bool)
|
||||
// script returns the helper-specific segment of cure script.
|
||||
script(t Toolchain, name string) string
|
||||
}
|
||||
@@ -527,7 +525,7 @@ mv '/usr/src/` + rn + `' '/usr/src/` + name + `'
|
||||
`
|
||||
}
|
||||
|
||||
dir := helper.wantsDir()
|
||||
dir, create := helper.wantsDir()
|
||||
helperScriptEarly := helper.scriptEarly()
|
||||
if attr.EnterSource ||
|
||||
dir == "" ||
|
||||
@@ -539,7 +537,7 @@ cd '/usr/src/` + name + `/'
|
||||
}
|
||||
scriptEarly += attr.ScriptEarly + helperScriptEarly
|
||||
if dir != "" && dir != helperInPlace {
|
||||
if helper.createDir() {
|
||||
if create {
|
||||
scriptEarly += "\nmkdir -p " + dir
|
||||
}
|
||||
scriptEarly += "\ncd " + dir + "\n"
|
||||
@@ -568,8 +566,8 @@ cd '/usr/src/` + name + `/'
|
||||
// one-off build scripts too specific to fit into any other [Helper]
|
||||
// implementation, but can still benefit from [Toolchain.NewPackage].
|
||||
type GenericHelper struct {
|
||||
// Whether to create and enter a directory in TMPDIR.
|
||||
EnterTemp bool
|
||||
// Remain in current directory.
|
||||
InPlace bool
|
||||
|
||||
// Concatenated for [Toolchain].
|
||||
Build, Check, Install string
|
||||
@@ -589,15 +587,12 @@ func (*GenericHelper) wantsWrite() bool { return false }
|
||||
// scriptEarly returns the zero value.
|
||||
func (*GenericHelper) scriptEarly() string { return "" }
|
||||
|
||||
// createDir returns false.
|
||||
func (*GenericHelper) createDir() bool { return false }
|
||||
|
||||
// wantsDir requests a new directory in TMPDIR, or the source directory otherwise.
|
||||
func (attr *GenericHelper) wantsDir() string {
|
||||
if attr != nil && attr.EnterTemp {
|
||||
return `"$(mktemp -d)"`
|
||||
// wantsDir requests a new directory, or omits the cd statement if InPlace.
|
||||
func (attr *GenericHelper) wantsDir() (string, bool) {
|
||||
if attr == nil || !attr.InPlace {
|
||||
return "/cure/", true
|
||||
}
|
||||
return ""
|
||||
return helperInPlace, false
|
||||
}
|
||||
|
||||
// script concatenates specified segments.
|
||||
|
||||
@@ -746,7 +746,7 @@ func (s *S) getFrame() azalea.Frame {
|
||||
) (v any, set bool, err error) {
|
||||
var attr GenericHelper
|
||||
if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
|
||||
k("mktemp"): &attr.EnterTemp,
|
||||
k("inPlace"): &attr.InPlace,
|
||||
k("build"): &attr.Build,
|
||||
k("check"): &attr.Check,
|
||||
k("install"): &attr.Install,
|
||||
|
||||
Reference in New Issue
Block a user