diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-07-10 15:31:58 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-07-10 15:39:55 +0900 |
| commit | e1f16e77209bc5acc7e41afecc15672627a0fafa (patch) | |
| tree | a308ad63a7ddfd7c7095764878fbecd87b854094 /internal/rosa/rosa.go | |
| parent | 8e9b3a2ed165b5432714c712838695fa5e763c5a (diff) | |
internal/rosa: apply patches in specified order
This seems more intuitive than letting the filesystem decide, and having to use awkward names.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/rosa.go')
| -rw-r--r-- | internal/rosa/rosa.go | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index 7c23736c..97351f10 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -10,6 +10,7 @@ import ( "strings" "sync" "time" + "unsafe" "hakurei.app/fhs" "hakurei.app/internal/pkg" @@ -332,7 +333,7 @@ func (s *S) HasStageEarly() (ok bool) { } // NewPatchedSource returns [pkg.Artifact] of source with patches applied. If -// passthrough is true, source is returned as is for zero length patches. +// passthrough is true, source is returned as is for zero-length patches. func (t Toolchain) NewPatchedSource( name string, source pkg.Artifact, @@ -346,29 +347,34 @@ func (t Toolchain) NewPatchedSource( paths := make([]pkg.ExecPath, len(patches)+1) for i, p := range patches { paths[i+1] = pkg.Path( - AbsUsrSrc.Append(name+"-patches", p[0]+".patch"), false, - pkg.NewFile(p[0]+".patch", []byte(p[1])), + fhs.AbsRoot.Append("patches", p[0]), false, + pkg.NewFile(p[0], unsafe.Slice(unsafe.StringData(p[1]), len(p[1]))), ) } - paths[0] = pkg.Path(AbsUsrSrc.Append(name), false, source) + paths[0] = pkg.Path(fhs.AbsRoot.Append("src"), false, source) - aname := name + "-src" - script := ` -cp -r /usr/src/` + name + `/. /work/. + var buf strings.Builder + buf.WriteString(` +cp -r /src/. /work/. chmod -R +w /work && cd /work -` +`) if len(paths) > 1 { - script += ` -cat /usr/src/` + name + `-patches/* | \ - patch \ - -p 1 \ - --ignore-whitespace -` - aname += "-patched" + buf.WriteString(` +function apply { + echo "applying $1" + patch -p 1 < "/patches/$1" +} +`) + + for _, p := range patches { + buf.WriteString("apply '") + buf.WriteString(p[0]) + buf.WriteString("'\n") + } } - return t.New(aname, 0, t.Append(nil, + return t.New(name+"-src", 0, t.Append(nil, _patch, - ), nil, nil, script, paths...) + ), nil, nil, buf.String(), paths...) } // helperInPlace is a special directory value for omitting the cd statement. |
