internal/rosa: apply patches in specified order
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m59s
Test / ShareFS (push) Successful in 4m4s
Test / Hakurei (push) Successful in 4m15s
Test / Sandbox (race detector) (push) Successful in 5m40s
Test / Hakurei (race detector) (push) Successful in 6m45s
Test / Flake checks (push) Successful in 1m30s
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m59s
Test / ShareFS (push) Successful in 4m4s
Test / Hakurei (push) Successful in 4m15s
Test / Sandbox (race detector) (push) Successful in 5m40s
Test / Hakurei (race detector) (push) Successful in 6m45s
Test / Flake checks (push) Successful in 1m30s
This seems more intuitive than letting the filesystem decide, and having to use awkward names. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+23
-17
@@ -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"
|
||||
}
|
||||
return t.New(aname, 0, t.Append(nil,
|
||||
`)
|
||||
|
||||
for _, p := range patches {
|
||||
buf.WriteString("apply '")
|
||||
buf.WriteString(p[0])
|
||||
buf.WriteString("'\n")
|
||||
}
|
||||
}
|
||||
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.
|
||||
|
||||
@@ -1053,7 +1053,7 @@ func (ctx *evalContext) pf(
|
||||
return
|
||||
}
|
||||
attr.Patches = append(attr.Patches, KV{
|
||||
strings.TrimSuffix(filepath.Base(pathname), ".patch"),
|
||||
filepath.Base(pathname),
|
||||
unsafe.String(unsafe.SliceData(p), len(p)),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user