From 15d8e03c3208cd61069f54f3776796a87a002001 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Sun, 18 Feb 2018 00:56:12 +0000 Subject: [PATCH] stand/lua: Fix module_path handling with multiple kernels Once we've successfully loaded a kernel, we add its directory to module_path. If we switch kernels with the kernel selector, we again prepend the kernel directory to the current module_path and end up with multiple kernel paths, potentially with mismatched kernel/modules, added to module_path. Fix it by caching module_path at load() time and using the cached version whenever we load a new kernel. --- stand/lua/config.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 34f7f7421a49..82372b14ebef 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -115,6 +115,7 @@ local pattern_table = { [10] = { str = "^%s*([%w%p]+)%s*=%s*\"([%w%s%p]-)\"%s*(.*)", process = function(k, v) + print("Setting '"..k.."' to '"..v.."'") if loader.setenv(k, v) ~= 0 then print("Failed to set '"..k.."' with value: "..v..""); end @@ -124,6 +125,7 @@ local pattern_table = { [11] = { str = "^%s*([%w%p]+)%s*=%s*(%d+)%s*(.*)", process = function(k, v) + print("Setting '"..k.."' to '"..v.."'") if loader.setenv(k, v) ~= 0 then print("Failed to set '"..k.."' with value: "..v..""); end @@ -293,7 +295,9 @@ function config.loadkernel(other_kernel) return false; end else - local module_path = loader.getenv("module_path"); + -- Use our cached module_path, so we don't end up with multiple + -- automatically added kernel paths to our final module_path + local module_path = config.module_path; local res = nil; if other_kernel ~= nil then @@ -308,9 +312,9 @@ function config.loadkernel(other_kernel) loader.setenv("module_path", v); res = load_bootfile(); - -- succeeded add path to module_path + -- succeeded, add path to module_path if res ~= nil then - if module_path ~= nil then + if (module_path ~= nil) then loader.setenv("module_path", v..";".. module_path); end @@ -350,6 +354,9 @@ function config.load(file) end end + -- Cache the provided module_path at load time for later use + config.module_path = loader.getenv("module_path"); + print("Loading kernel..."); config.loadkernel();