diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-30 18:15:56 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-30 18:24:53 +0900 |
| commit | a6600be34ad812ff13c89f45c3cadaac6d994e67 (patch) | |
| tree | 48c8cd6daab8084eb9391c7ee16f2b38f1cf280f /internal | |
| parent | b5592633f5b980970808fc5be43b0fb4f4d4e784 (diff) | |
all: use filepath
This makes package check portable, and removes nonportable behaviour from package pkg, pipewire, and system. All other packages remain nonportable due to their nature. No latency increase was observed due to this change on amd64 and arm64 linux.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/acl/acl_test.go | 4 | ||||
| -rw-r--r-- | internal/outcome/spcontainer.go | 6 | ||||
| -rw-r--r-- | internal/pipewire/pipewire.go | 12 | ||||
| -rw-r--r-- | internal/pkg/exec.go | 4 | ||||
| -rw-r--r-- | internal/pkg/pkg.go | 5 | ||||
| -rw-r--r-- | internal/pkg/tar.go | 4 | ||||
| -rw-r--r-- | internal/pkg/testdata/main.go | 18 | ||||
| -rw-r--r-- | internal/rosa/cmake.go | 4 | ||||
| -rw-r--r-- | internal/rosa/report_test.go | 6 | ||||
| -rw-r--r-- | internal/system/pipewire_test.go | 4 | ||||
| -rw-r--r-- | internal/wayland/conn_test.go | 4 |
11 files changed, 35 insertions, 36 deletions
diff --git a/internal/acl/acl_test.go b/internal/acl/acl_test.go index 19ce45ac..5f5447ba 100644 --- a/internal/acl/acl_test.go +++ b/internal/acl/acl_test.go @@ -8,7 +8,7 @@ import ( "io" "os" "os/exec" - "path" + "path/filepath" "reflect" "strconv" "testing" @@ -28,7 +28,7 @@ func TestUpdate(t *testing.T) { t.Skip("acl test skipped") } - testFilePath := path.Join(t.TempDir(), testFileName) + testFilePath := filepath.Join(t.TempDir(), testFileName) if f, err := os.Create(testFilePath); err != nil { t.Fatalf("Create: error = %v", err) diff --git a/internal/outcome/spcontainer.go b/internal/outcome/spcontainer.go index ba529955..0ad1de50 100644 --- a/internal/outcome/spcontainer.go +++ b/internal/outcome/spcontainer.go @@ -5,7 +5,7 @@ import ( "errors" "io/fs" "os" - "path" + "path/filepath" "slices" "strconv" "syscall" @@ -165,9 +165,9 @@ func (s *spFilesystemOp) toSystem(state *outcomeStateSys) error { } for _, pair := range entry.Values { if pair[0] == "path" { - if path.IsAbs(pair[1]) { + if filepath.IsAbs(pair[1]) { // get parent dir of socket - dir := path.Dir(pair[1]) + dir := filepath.Dir(pair[1]) if dir == "." || dir == fhs.Root { state.msg.Verbosef("dbus socket %q is in an unusual location", pair[1]) } diff --git a/internal/pipewire/pipewire.go b/internal/pipewire/pipewire.go index 0538863a..3b909336 100644 --- a/internal/pipewire/pipewire.go +++ b/internal/pipewire/pipewire.go @@ -20,7 +20,7 @@ import ( "fmt" "io" "os" - "path" + "path/filepath" "runtime" "slices" "strconv" @@ -973,23 +973,23 @@ func connectName(name string, manager bool) (conn Conn, err error) { return connectName(name+"-manager", false) } - if path.IsAbs(name) || (len(name) > 0 && name[0] == '@') { + if filepath.IsAbs(name) || (len(name) > 0 && name[0] == '@') { return Dial(name) } else { runtimeDir, ok := os.LookupEnv("PIPEWIRE_RUNTIME_DIR") - if !ok || !path.IsAbs(runtimeDir) { + if !ok || !filepath.IsAbs(runtimeDir) { runtimeDir, ok = os.LookupEnv("XDG_RUNTIME_DIR") } - if !ok || !path.IsAbs(runtimeDir) { + if !ok || !filepath.IsAbs(runtimeDir) { // this is cargo culted from windows stuff and has no effect normally; // keeping it to maintain compatibility in case someone sets this runtimeDir, ok = os.LookupEnv("USERPROFILE") } - if !ok || !path.IsAbs(runtimeDir) { + if !ok || !filepath.IsAbs(runtimeDir) { runtimeDir = DEFAULT_SYSTEM_RUNTIME_DIR } - return Dial(path.Join(runtimeDir, name)) + return Dial(filepath.Join(runtimeDir, name)) } } diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index f1385529..a78dab84 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -8,7 +8,7 @@ import ( "io" "os" "os/exec" - "path" + "path/filepath" "slices" "strconv" "syscall" @@ -189,7 +189,7 @@ func NewExec( paths ...ExecPath, ) Artifact { if name == "" { - name = "exec-" + path.Base(pathname.String()) + name = "exec-" + filepath.Base(pathname.String()) } if timeout <= 0 { timeout = ExecTimeoutDefault diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index a8fb91ba..ea7ac815 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -16,7 +16,6 @@ import ( "iter" "maps" "os" - "path" "path/filepath" "runtime" "slices" @@ -894,7 +893,7 @@ func (c *Cache) Scrub(checks int) error { se.DanglingIdentifiers = append(se.DanglingIdentifiers, *want) seMu.Unlock() return false - } else if err = Decode(got, path.Base(linkname)); err != nil { + } else if err = Decode(got, filepath.Base(linkname)); err != nil { seMu.Lock() lnp := dir.Append(linkname) se.Errs[lnp.Handle()] = append(se.Errs[lnp.Handle()], err) @@ -1488,7 +1487,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) ( return } buf := c.getIdentBuf() - err = Decode((*Checksum)(buf[:]), path.Base(name)) + err = Decode((*Checksum)(buf[:]), filepath.Base(name)) if err == nil { checksum = unique.Make(Checksum(buf[:])) } diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go index 39f55010..32b4b362 100644 --- a/internal/pkg/tar.go +++ b/internal/pkg/tar.go @@ -10,7 +10,7 @@ import ( "io/fs" "net/http" "os" - "path" + "path/filepath" ) const ( @@ -169,7 +169,7 @@ func (a *tarArtifact) Cure(t *TContext) (err error) { } if typeflag >= '0' && typeflag <= '9' && typeflag != tar.TypeDir { - if err = root.MkdirAll(path.Dir(header.Name), 0700); err != nil { + if err = root.MkdirAll(filepath.Dir(header.Name), 0700); err != nil { return } } diff --git a/internal/pkg/testdata/main.go b/internal/pkg/testdata/main.go index bbe26d69..c969474d 100644 --- a/internal/pkg/testdata/main.go +++ b/internal/pkg/testdata/main.go @@ -7,7 +7,7 @@ import ( "log" "net" "os" - "path" + "path/filepath" "reflect" "slices" "strings" @@ -68,7 +68,7 @@ func main() { if got, err := os.Executable(); err != nil { log.Fatalf("Executable: error = %v", err) } else { - iftPath = path.Join(path.Dir(path.Dir(got)), "ift") + iftPath = filepath.Join(filepath.Dir(filepath.Dir(got)), "ift") if got != wantExec { switch got { @@ -161,7 +161,7 @@ func main() { } } if !layers { - if path.Base(lowerdir) != checksumEmptyDir { + if filepath.Base(lowerdir) != checksumEmptyDir { log.Fatal("unexpected artifact checksum") } } else { @@ -187,8 +187,8 @@ func main() { } if len(lowerdirs) != 2 || - path.Base(lowerdirs[0]) != "MGWmEfjut2QE2xPJwTsmUzpff4BN_FEnQ7T0j7gvUCCiugJQNwqt9m151fm9D1yU" || - path.Base(lowerdirs[1]) != "nY_CUdiaUM1OL4cPr5TS92FCJ3rCRV7Hm5oVTzAvMXwC03_QnTRfQ5PPs7mOU9fK" { + filepath.Base(lowerdirs[0]) != "MGWmEfjut2QE2xPJwTsmUzpff4BN_FEnQ7T0j7gvUCCiugJQNwqt9m151fm9D1yU" || + filepath.Base(lowerdirs[1]) != "nY_CUdiaUM1OL4cPr5TS92FCJ3rCRV7Hm5oVTzAvMXwC03_QnTRfQ5PPs7mOU9fK" { log.Fatalf("unexpected lowerdirs %s", strings.Join(lowerdirs, ", ")) } } @@ -202,12 +202,12 @@ func main() { } next() - if path.Base(m.Root) != "OLBgp1GsljhM2TJ-sbHjaiH9txEUvgdDTAzHv2P24donTt6_529l-9Ua0vFImLlb" { + if filepath.Base(m.Root) != "OLBgp1GsljhM2TJ-sbHjaiH9txEUvgdDTAzHv2P24donTt6_529l-9Ua0vFImLlb" { log.Fatal("unexpected file artifact checksum") } next() - if path.Base(m.Root) != checksumEmptyDir { + if filepath.Base(m.Root) != checksumEmptyDir { log.Fatal("unexpected artifact checksum") } } @@ -226,13 +226,13 @@ func main() { log.Fatal("unexpected work mount entry") } } else { - if path.Base(m.Root) != ident || m.Target != "/work" { + if filepath.Base(m.Root) != ident || m.Target != "/work" { log.Fatal("unexpected work mount entry") } } next() - if path.Base(m.Root) != ident || m.Target != "/tmp" { + if filepath.Base(m.Root) != ident || m.Target != "/tmp" { log.Fatal("unexpected temp mount entry") } diff --git a/internal/rosa/cmake.go b/internal/rosa/cmake.go index e7abffde..f6f29d3e 100644 --- a/internal/rosa/cmake.go +++ b/internal/rosa/cmake.go @@ -1,7 +1,7 @@ package rosa import ( - "path" + "path/filepath" "slices" "strings" @@ -200,7 +200,7 @@ cmake -G ` + generate + ` \ } }), " \\\n\t") + ` \ -DCMAKE_INSTALL_PREFIX=/system \ - '/usr/src/` + name + `/` + path.Join(attr.Append...) + `' + '/usr/src/` + name + `/` + filepath.Join(attr.Append...) + `' cmake --build .` + jobs + ` cmake --install . --prefix=/work/system ` + attr.Script diff --git a/internal/rosa/report_test.go b/internal/rosa/report_test.go index ca29cf36..f394e915 100644 --- a/internal/rosa/report_test.go +++ b/internal/rosa/report_test.go @@ -3,7 +3,7 @@ package rosa_test import ( "errors" "os" - "path" + "path/filepath" "syscall" "testing" "unique" @@ -13,7 +13,7 @@ import ( ) func TestReportZeroLength(t *testing.T) { - report := path.Join(t.TempDir(), "report") + report := filepath.Join(t.TempDir(), "report") if err := os.WriteFile(report, nil, 0400); err != nil { t.Fatal(err) } @@ -24,7 +24,7 @@ func TestReportZeroLength(t *testing.T) { } func TestReportSIGSEGV(t *testing.T) { - report := path.Join(t.TempDir(), "report") + report := filepath.Join(t.TempDir(), "report") if err := os.WriteFile(report, make([]byte, 64), 0400); err != nil { t.Fatal(err) } diff --git a/internal/system/pipewire_test.go b/internal/system/pipewire_test.go index d1bf5781..f0ca0b34 100644 --- a/internal/system/pipewire_test.go +++ b/internal/system/pipewire_test.go @@ -3,7 +3,7 @@ package system import ( "fmt" "os" - "path" + "path/filepath" "syscall" "testing" "time" @@ -18,7 +18,7 @@ func TestPipeWireOp(t *testing.T) { checkOpBehaviour(t, checkNoParallel, []opBehaviourTestCase{ {"success", 0xbeef, 0xff, &pipewireOp{nil, - m(path.Join(t.TempDir(), "pipewire")), + m(filepath.Join(t.TempDir(), "pipewire")), "org.chromium.Chromium", "ebf083d1b175911782d413369b64ce7c", }, []stub.Call{ diff --git a/internal/wayland/conn_test.go b/internal/wayland/conn_test.go index a884c182..30c66cb2 100644 --- a/internal/wayland/conn_test.go +++ b/internal/wayland/conn_test.go @@ -3,7 +3,7 @@ package wayland import ( "errors" "os" - "path" + "path/filepath" "reflect" "syscall" "testing" @@ -19,7 +19,7 @@ func TestSecurityContextClose(t *testing.T) { } var ctx SecurityContext - if f, err := os.Create(path.Join(t.TempDir(), "remove")); err != nil { + if f, err := os.Create(filepath.Join(t.TempDir(), "remove")); err != nil { t.Fatal(err) } else { ctx.bindPath = check.MustAbs(f.Name()) |
