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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user