Skip to content

Commit dbea419

Browse files
committed
Use some wildcard matching
1 parent 484394b commit dbea419

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

init/modules/EESSI/2023.06.lua

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,26 @@ end
237237
-- Needs to be reversible so first make a copy
238238
append_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", os.getenv("LD_LIBRARY_PATH") or "")
239239
-- on unload the variable will no longer exist
240+
local function remove_system_paths(var)
241+
local paths = os.getenv(var)
242+
local system_lib_patterns = {
243+
"^/lib(64)?(/|$)",
244+
"^/usr/lib(64)?(/|$)",
245+
"^/usr/local/lib(64)?(/|$)",
246+
}
247+
if not paths then return end
248+
249+
for path in string.gmatch(paths, "([^:]+)") do
250+
for _, pat in ipairs(system_lib_patterns) do
251+
if path:match(pat) then
252+
remove_path(var, path)
253+
break
254+
end
255+
end
256+
end
257+
end
240258
if mode() == "load" then
241-
-- remove any standard paths that can interfere with the compat layer
242-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/lib")
243-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/lib64")
244-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/usr/lib")
245-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/usr/lib64")
246-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/usr/local/lib")
247-
remove_path ("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH", "/usr/local/lib64")
259+
remove_matching_paths("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH")
248260
end
249261
-- now we can use pushenv to retain/restore the original value
250262
pushenv ("LD_LIBRARY_PATH", os.getenv("EESSI_DEFAULT_HOST_LD_LIBRARY_PATH") or "")

0 commit comments

Comments
 (0)