aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/rosa.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-21 16:10:55 +0900
committerOphestra <cat@gensokyo.uk>2026-05-21 16:11:38 +0900
commit6546ddc64bcbf73c7419bac7af596b924005dbc3 (patch)
tree5e09262421b52a2ce626200c79d67f36fac74b94 /internal/rosa/rosa.go
parentcbf18b302d51c3e667ebe06cfebb14b90ccc93b7 (diff)
internal/rosa: expose in-place behaviour in generic helper
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>
Diffstat (limited to 'internal/rosa/rosa.go')
-rw-r--r--internal/rosa/rosa.go25
1 files changed, 10 insertions, 15 deletions
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go
index e3d8a41a..b83b7d07 100644
--- a/internal/rosa/rosa.go
+++ b/internal/rosa/rosa.go
@@ -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.