libreoffice support started, still broken. Some updates to how wine-access gets called.
This commit is contained in:
1 parent
8e76d2341c
commit
7f78177786
26 files changed
+1173
-21
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Package wine supervises the optional installed Cthulhu Wine accessibility
|
||||
// Package wine supervises the optional installed Wine Access accessibility
|
||||
// helper. Native Wine objects stay in that process; Go receives D-Bus messages.
|
||||
package wine
|
||||
|
||||
@@ -47,17 +47,28 @@ func New(logger *slog.Logger) *Manager {
|
||||
}
|
||||
|
||||
func helperPath() string {
|
||||
return findHelper([]string{
|
||||
filepath.Join(os.Getenv("HOME"), ".local", "libexec", "wine-access", "wine-access.exe"),
|
||||
filepath.Join(os.Getenv("HOME"), ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe"),
|
||||
"/usr/local/libexec/wine-access/wine-access.exe",
|
||||
"/usr/libexec/wine-access/wine-access.exe",
|
||||
"/usr/libexec/cthulhu/wine/cthulhu-wine-access.exe",
|
||||
})
|
||||
}
|
||||
|
||||
func findHelper(candidates []string) string {
|
||||
if path := os.Getenv("CTHULHU_WINE_ACCESS_HELPER"); executable(path) {
|
||||
return path
|
||||
}
|
||||
if path := filepath.Join(os.Getenv("HOME"), ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe"); executable(path) {
|
||||
return path
|
||||
for _, path := range candidates {
|
||||
if executable(path) {
|
||||
return path
|
||||
}
|
||||
}
|
||||
if path := "/usr/libexec/cthulhu/wine/cthulhu-wine-access.exe"; executable(path) {
|
||||
return path
|
||||
}
|
||||
if path, err := exec.LookPath("cthulhu-wine-access.exe"); err == nil {
|
||||
return path
|
||||
for _, name := range []string{"wine-access.exe", "cthulhu-wine-access.exe"} {
|
||||
if path, err := exec.LookPath(name); err == nil {
|
||||
return path
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -119,7 +119,18 @@ func TestHelperPathPrefersConfiguredThenLocalHelper(t *testing.T) {
|
||||
t.Setenv("HOME", root)
|
||||
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", "")
|
||||
|
||||
local := filepath.Join(root, ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe")
|
||||
legacy := filepath.Join(root, ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe")
|
||||
if err := os.MkdirAll(filepath.Dir(legacy), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(legacy, []byte("#!/bin/sh\n"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := helperPath(); got != legacy {
|
||||
t.Fatalf("helperPath() = %q, want existing user helper %q", got, legacy)
|
||||
}
|
||||
|
||||
local := filepath.Join(root, ".local", "libexec", "wine-access", "wine-access.exe")
|
||||
if err := os.MkdirAll(filepath.Dir(local), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -140,6 +151,50 @@ func TestHelperPathPrefersConfiguredThenLocalHelper(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindHelperPrecedenceAndExecutableFiltering(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", "")
|
||||
t.Setenv("PATH", root)
|
||||
candidates := []string{
|
||||
filepath.Join(root, "user", "wine-access.exe"),
|
||||
filepath.Join(root, "usr-local", "wine-access.exe"),
|
||||
filepath.Join(root, "usr", "wine-access.exe"),
|
||||
}
|
||||
for _, path := range candidates {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if got := findHelper(candidates); got != "" {
|
||||
t.Fatalf("missing helpers = %q, want empty", got)
|
||||
}
|
||||
legacy := filepath.Join(root, "cthulhu-wine-access.exe")
|
||||
pathHelper := filepath.Join(root, "wine-access.exe")
|
||||
for _, path := range []string{legacy, pathHelper, candidates[2], candidates[1], candidates[0]} {
|
||||
if err := os.WriteFile(path, []byte("#!/bin/sh\n"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := findHelper(candidates); got != path {
|
||||
t.Fatalf("findHelper() = %q, want %q", got, path)
|
||||
}
|
||||
}
|
||||
if err := os.Chmod(candidates[0], 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", candidates[0])
|
||||
if got := findHelper(candidates); got != candidates[1] {
|
||||
t.Fatalf("non-executable override/user helper = %q, want %q", got, candidates[1])
|
||||
}
|
||||
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", root)
|
||||
if got := findHelper(candidates); got != candidates[1] {
|
||||
t.Fatalf("directory override = %q, want %q", got, candidates[1])
|
||||
}
|
||||
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", pathHelper)
|
||||
if got := findHelper(candidates); got != pathHelper {
|
||||
t.Fatalf("executable override = %q, want %q", got, pathHelper)
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagerLaunchesAndStopsHelperForActivePrefix(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
procRoot := filepath.Join(root, "proc")
|
||||
|
||||
Reference in new issue
Block a user