From c2411e644edc8d6a03facf8eb4eee1b5c0947803 Mon Sep 17 00:00:00 2001 From: tux-rampage Date: Tue, 4 Jun 2024 19:40:05 +0200 Subject: [PATCH] Build xorg lib search paths dynamically --- internal/discover/graphics.go | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index 4cf85889..7b11caf8 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -254,6 +254,26 @@ func optionalXorgDiscoverer(logger logger.Interface, driver *root.Driver, nvidia return xorg } +func buildXOrgSearchPaths(libRoot string) []string { + paths := []string{ + libRoot + "/nvidia/xorg", + } + + directories := []string{"drivers", "extensions"} + pathOptions := []string{"modules", "modules/updates"} + prefixes := []string{libRoot + "/xorg", "/usr/lib/xorg", "/usr/lib64/xorg", "/usr/X11R6/lib", "/usr/X11R6/lib64"} + + for _, prefix := range prefixes { + for _, pathOption := range pathOptions { + for _, directory := range directories { + paths = append(paths, prefix+"/"+pathOption+"/"+directory) + } + } + } + + return paths +} + func newXorgDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath string) (Discover, error) { libCudaPaths, err := cuda.New( driver.Libraries(), @@ -274,27 +294,7 @@ func newXorgDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHo lookup.NewFileLocator( lookup.WithLogger(logger), lookup.WithRoot(driver.Root), - lookup.WithSearchPaths([]string{ - libRoot + "/nvidia/xorg", - libRoot + "/xorg/modules/extensions", - libRoot + "/xorg/modules/drivers", - "/usr/lib/xorg/modules/extensions", - "/usr/lib/xorg/modules/drivers", - "/usr/lib64/xorg/modules/extensions", - "/usr/lib64/xorg/modules/drivers", - "/usr/lib/xorg/modules/updates/extensions", - "/usr/lib/xorg/modules/updates/drivers", - "/usr/lib64/xorg/modules/updates/extensions", - "/usr/lib64/xorg/modules/updates/drivers", - "/usr/X11R6/lib/modules/extensions", - "/usr/X11R6/lib/modules/drivers", - "/usr/X11R6/lib64/modules/extensions", - "/usr/X11R6/lib64/modules/drivers", - "/usr/X11R6/lib/modules/updates/extensions", - "/usr/X11R6/lib/modules/updates/drivers", - "/usr/X11R6/lib64/modules/updates/extensions", - "/usr/X11R6/lib64/modules/updates/drivers", - }), + lookup.WithSearchPaths(buildXOrgSearchPaths(libRoot)...), lookup.WithCount(1), ), driver.Root,