container: use absolute for pathname
All checks were successful
Test / Flake checks (push) Successful in 1m26s
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 2m58s
Test / Hpkg (push) Successful in 3m45s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 4m47s
All checks were successful
Test / Flake checks (push) Successful in 1m26s
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 2m58s
Test / Hpkg (push) Successful in 3m45s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 4m47s
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -33,14 +33,17 @@ func Exec(ctx context.Context, p string) ([]*Entry, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
z := container.NewCommand(c, toolPath.String(), lddName, p)
|
||||
z := container.NewCommand(c, toolPath, lddName, p)
|
||||
z.Hostname = "hakurei-" + lddName
|
||||
z.SeccompFlags |= seccomp.AllowMultiarch
|
||||
z.SeccompPresets |= seccomp.PresetStrict
|
||||
stdout, stderr := new(bytes.Buffer), new(bytes.Buffer)
|
||||
z.Stdout = stdout
|
||||
z.Stderr = stderr
|
||||
z.Bind(container.FHSRoot, container.FHSRoot, 0).Proc(container.FHSProc).Dev(container.FHSProc, false)
|
||||
z.
|
||||
Bind(container.AbsFHSRoot, container.AbsFHSRoot, 0).
|
||||
Proc(container.AbsFHSProc).
|
||||
Dev(container.AbsFHSDev, false)
|
||||
|
||||
if err := z.Start(); err != nil {
|
||||
return nil, err
|
||||
|
||||
19
ldd/path.go
19
ldd/path.go
@@ -1,21 +1,20 @@
|
||||
package ldd
|
||||
|
||||
import (
|
||||
"path"
|
||||
"slices"
|
||||
"hakurei.app/container"
|
||||
)
|
||||
|
||||
// Path returns a deterministic, deduplicated slice of absolute directory paths in entries.
|
||||
func Path(entries []*Entry) []string {
|
||||
p := make([]string, 0, len(entries)*2)
|
||||
func Path(entries []*Entry) []*container.Absolute {
|
||||
p := make([]*container.Absolute, 0, len(entries)*2)
|
||||
for _, entry := range entries {
|
||||
if path.IsAbs(entry.Path) {
|
||||
p = append(p, path.Dir(entry.Path))
|
||||
if a, err := container.NewAbs(entry.Path); err == nil {
|
||||
p = append(p, a.Dir())
|
||||
}
|
||||
if path.IsAbs(entry.Name) {
|
||||
p = append(p, path.Dir(entry.Name))
|
||||
if a, err := container.NewAbs(entry.Name); err == nil {
|
||||
p = append(p, a.Dir())
|
||||
}
|
||||
}
|
||||
slices.Sort(p)
|
||||
return slices.Compact(p)
|
||||
container.SortAbs(p)
|
||||
return container.CompactAbs(p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user