From e43809c72ab892c72130efef4ea44d940c24a014 Mon Sep 17 00:00:00 2001 From: Robert McLay Date: Tue, 19 Mar 2024 16:24:25 -0600 Subject: [PATCH] Issue #679: add code to remove downstream conflicts when module is unloaded --- .versionDate | 1 + Makefile.in | 8 +++-- rt/conflict/conflict.tdesc | 4 ++- rt/conflict/err.txt | 28 +++++++++++++++- rt/conflict/out.txt | 68 ++++++++++++++++++++++++++++++++++++++ src/Hub.lua | 54 +++++++++++++++++------------- src/MC_Unload.lua | 2 +- src/MT.lua | 12 ++++++- src/MainControl.lua | 24 ++++++++++++-- 9 files changed, 169 insertions(+), 32 deletions(-) create mode 100644 .versionDate diff --git a/.versionDate b/.versionDate new file mode 100644 index 000000000..e1ab94964 --- /dev/null +++ b/.versionDate @@ -0,0 +1 @@ +2024-03-19 16:11 -06:00 diff --git a/Makefile.in b/Makefile.in index 6565f1f43..3deaa62c0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -85,6 +85,7 @@ PATH_TO_PAGER := @PATH_TO_PAGER@ PATH_TO_TCLSH := @PATH_TO_TCLSH@ PATH_TO_LS := @PATH_TO_LS@ MODULEPATH_ROOT := @MODULEPATH_ROOT@ +VDateFn := $(srcdir)/.versionDate VERSION_SRC := $(srcdir)/src/Version.lua SETTARG_VSRC := $(srcdir)/settarg/Version.lua LUA_INCLUDE := @LUA_INCLUDE@ @@ -108,6 +109,7 @@ LMOD_MF_SOURCE := $(patsubst %, $(srcdir)/%, MF/*.version.lua) SETTARG_SOURCE := $(patsubst %, $(srcdir)/%, settarg/*.lua settarg/targ.in) DATE_cmd := $(srcdir)/proj_mgmt/DATE_cmd.sh UNAME_S := $(shell uname -s) +VersionDate := $(shell cat $(VDateFn)) MODE := @MODE@ ifeq ($(UNAME_S),Darwin) @@ -547,10 +549,10 @@ libexec: $(lua_code) $(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(LIBEXEC) GIT_VERSION=$(GIT_VERSION) __installMe VersionSrc: - $(BUILD_V_src) "$(GIT_BRANCH)" "$(version)" "$(GIT_VERSION)" "$(VDATE)" > $(DESTDIR)$(LIBEXEC)/Version.lua + $(BUILD_V_src) "$(GIT_BRANCH)" "$(version)" "$(GIT_VERSION)" "$(VersionDate)" > $(DESTDIR)$(LIBEXEC)/Version.lua STVersionSrc: Inst_Settarg - $(BUILD_V_src) "$(GIT_BRANCH)" "$(version)" "$(GIT_VERSION)" "$(VDATE)" > $(DESTDIR)$(SETTARG)/Version.lua + $(BUILD_V_src) "$(GIT_BRANCH)" "$(version)" "$(GIT_VERSION)" "$(VersionDate)" > $(DESTDIR)$(SETTARG)/Version.lua Inst_Tools: $(TOOL_SRC) $(MAKE) FILELIST="$^" DIRLOC=$(DESTDIR)$(TOOLS) GIT_VERSION=$(GIT_VERSION) __installMe @@ -614,9 +616,11 @@ gittag: $(RM) $(SETTARG_VSRC); \ $(BUILD_V_src) "$(GIT_BRANCH)" "$(TAG)" "$(TAG)" "$(VDATE)" > $(VERSION_SRC); \ cp $(VERSION_SRC) $(SETTARG_VSRC); \ + echo $(VDATE) > $(VDateFn); \ $(UPDATE_VERSION) -p $(CONF_PY_PATTERN) --version $(TAG) $(CONF_PY); \ git commit -m "moving to TAG_VERSION $(TAG)" $(SETTARG_VSRC) \ $(CONF_PY) \ + $(VDateFn) \ $(VERSION_SRC); \ git tag -a $(TAG) -m 'Setting TAG_VERSION to $(TAG)' ; \ branchName=`git status | head -n 1 | sed 's/^[# ]*On branch //g'` ; \ diff --git a/rt/conflict/conflict.tdesc b/rt/conflict/conflict.tdesc index b32884fe8..48da2280f 100644 --- a/rt/conflict/conflict.tdesc +++ b/rt/conflict/conflict.tdesc @@ -46,7 +46,9 @@ testdescript = { runLmod load base acme #15 runLmod save #16 runLmod restore #17 - + runLmod unload acme #18 + runLmod unload base #19 + HOME=$ORIG_HOME diff --git a/rt/conflict/err.txt b/rt/conflict/err.txt index e19265815..ec5879af0 100644 --- a/rt/conflict/err.txt +++ b/rt/conflict/err.txt @@ -2,7 +2,7 @@ step 1 lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version =========================== -Modules based on Lua: Version 8.7.34 (8.7.34-25-g516266fa) 2024-03-11 18:05 -06:00 +Modules based on Lua: Version 8.7.37 2024-03-17 13:11 -06:00 by Robert McLay mclay@tacc.utexas.edu =========================== step 2 @@ -78,3 +78,29 @@ Lmod has detected the following error: Cannot load module "y/1.0" because these While processing the following module(s): Module fullname Module Filename y/1.0 ProjectDIR/rt/conflict/mf/y/1.0.lua +=========================== +step 14 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing purge +=========================== +=========================== +step 15 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load base acme +=========================== +=========================== +step 16 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing save +=========================== +Saved current collection of modules to: "default" +=========================== +step 17 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing restore +=========================== +Restoring modules from user's default +=========================== +step 18 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload acme +=========================== +=========================== +step 19 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload base +=========================== diff --git a/rt/conflict/out.txt b/rt/conflict/out.txt index 2fe954a47..3f83b1e92 100644 --- a/rt/conflict/out.txt +++ b/rt/conflict/out.txt @@ -122,3 +122,71 @@ step 13 lua ProjectDIR/src/lmod.in.lua shell --regression_testing load y =========================== false +=========================== +step 14 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing purge +=========================== +unset LOADEDMODULES; +MODULEPATH=ProjectDIR/rt/conflict/mf; +export MODULEPATH; +unset TEST_A; +unset TEST_B; +unset X; +unset _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/conflict/mf",},systemBaseMPATH="ProjectDIR/rt/conflict/mf",}'; +export _ModuleTable_; +unset e; +=========================== +step 15 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing load base acme +=========================== +LOADEDMODULES=base/1.0:acme/1.0; +export LOADEDMODULES; +__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/conflict/mf2/Core:1; +export __LMOD_REF_COUNT_MODULEPATH; +MODULEPATH=ProjectDIR/rt/conflict/mf2/Core; +export MODULEPATH; +_LMFILES_=ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua:ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua; +export _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.2>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},base={{action="match",ie=false,is=false,sType="mt",userName="A",},{action="match",ie=false,is=false,sType="mt",userName="B",},},},depthT={},family={},mT={acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},base={fn="ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua",fullName="base/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="base",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}'; +export _ModuleTable_; +=========================== +step 16 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing save +=========================== +MODULEPATH=ProjectDIR/rt/conflict/mf2/Core; +export MODULEPATH; +_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.2>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},base={{action="match",ie=false,is=false,sType="mt",userName="A",},{action="match",ie=false,is=false,sType="mt",userName="B",},},},depthT={},family={},mT={acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},base={fn="ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua",fullName="base/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="base",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}'; +export _ModuleTable_; +=========================== +step 17 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing restore +=========================== +MODULEPATH=ProjectDIR/rt/conflict/mf2/Core; +export MODULEPATH; +_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.2>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},base={{action="match",ie=false,is=false,sType="mt",userName="A",},{action="match",ie=false,is=false,sType="mt",userName="B",},},},depthT={},family={},mT={acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},base={fn="ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua",fullName="base/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="base",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}'; +export _ModuleTable_; +__LMOD_DEFAULT_MODULES_LOADED__=1; +export __LMOD_DEFAULT_MODULES_LOADED__; +=========================== +step 18 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload acme +=========================== +LOADEDMODULES=base/1.0; +export LOADEDMODULES; +MODULEPATH=ProjectDIR/rt/conflict/mf2/Core; +export MODULEPATH; +_LMFILES_=ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua; +export _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={base={{action="match",ie=false,is=false,sType="mt",userName="A",},{action="match",ie=false,is=false,sType="mt",userName="B",},},},depthT={},family={},mT={base={fn="ProjectDIR/rt/conflict/mf2/Core/base/1.0.lua",fullName="base/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="base",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}'; +export _ModuleTable_; +=========================== +step 19 +lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload base +=========================== +unset LOADEDMODULES; +MODULEPATH=ProjectDIR/rt/conflict/mf2/Core; +export MODULEPATH; +unset _LMFILES_; +_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}'; +export _ModuleTable_; diff --git a/src/Hub.lua b/src/Hub.lua index 70af8d9af..a79cba408 100644 --- a/src/Hub.lua +++ b/src/Hub.lua @@ -39,30 +39,31 @@ require("TermWidth") require("string_utils") require("loadModuleFile") -local Banner = require("Banner") -local BeautifulTbl = require("BeautifulTbl") -local Cache = require("Cache") -local ColumnTable = require("ColumnTable") -local FrameStk = require("FrameStk") -local M = {} -local MRC = require("MRC") -local MName = require("MName") -local MT = require("MT") -local ModuleA = require("ModuleA") -local Spider = require("Spider") -local Var = require("Var") -local concatTbl = table.concat -local cosmic = require("Cosmic"):singleton() -local dbg = require("Dbg"):dbg() -local hook = require("Hook") -local i18n = require("i18n") -local remove = table.remove -local sort = table.sort -local q_load = 0 -local s_same = true +local Banner = require("Banner") +local BeautifulTbl = require("BeautifulTbl") +local Cache = require("Cache") +local ColumnTable = require("ColumnTable") +local FrameStk = require("FrameStk") +local M = {} +local MRC = require("MRC") +local MName = require("MName") +local MT = require("MT") +local ModuleA = require("ModuleA") +local Spider = require("Spider") +local Var = require("Var") +local concatTbl = table.concat +local cosmic = require("Cosmic"):singleton() +local dbg = require("Dbg"):dbg() +local hook = require("Hook") +local i18n = require("i18n") +local permConflicts = cosmic:value("LMOD_PERMANENT_CONFLICTS") +local remove = table.remove +local sort = table.sort +local q_load = 0 +local s_same = true local A = ShowResultsA -local mpath_avail = cosmic:value("LMOD_MPATH_AVAIL") +local mpath_avail = cosmic:value("LMOD_MPATH_AVAIL") ------------------------------------------------------------------------ -- a private ctor that is used to construct a singleton. @@ -315,10 +316,17 @@ function M.load(self, mA) repeat local mname = mA[i] local userName = mname:userName() + mt = frameStk:mt() + + if (permConflicts == "yes") then + -- local function or an mt thing? + --l_checkForLoadConflicts(mname + -- Probably an MT thing. + end + dbg.print{"Hub:load i: ",i,", userName: ",userName,"\n",} - mt = frameStk:mt() local sn = mname:sn() if ((sn == nil) and ((i > 1) or (frameStk:stackDepth() > 0))) then dbg.print{"Pushing ",mname:userName()," on moduleQ\n"} diff --git a/src/MC_Unload.lua b/src/MC_Unload.lua index 227217026..4ea4186a4 100644 --- a/src/MC_Unload.lua +++ b/src/MC_Unload.lua @@ -56,7 +56,7 @@ M.append_path = MainControl.remove_path_last M.build_unload = MainControl.do_not_build_unload M.color_banner = MainControl.color_banner M.complete = MainControl.uncomplete -M.conflict = MainControl.quiet +M.conflict = MainControl.removeConflict M.depends_on = MainControl.forgo M.error = MainControl.warning M.execute = MainControl.execute diff --git a/src/MT.lua b/src/MT.lua index 8692fe25e..15e2d80e3 100644 --- a/src/MT.lua +++ b/src/MT.lua @@ -170,7 +170,7 @@ local function l_new(self, s, restoreFn) end o.__conflictT = cT end - o.conflict = nil + o.conflictT = nil end -- remove any mcmdT connected to a mT entry @@ -1497,4 +1497,14 @@ function M.registerConflicts(self, mname, mA) self.__conflictT[sn] = A dbg.fini("MT:registerConflicts") end +------------------------------------------------------------------------ +-- Unregister Downstream conflicts +function M.removeConflicts(self, mname) + local sn = mname:sn() + if (dbg.active()) then + dbg.start{"MT:removeConflicts(sn:", sn,")"} + end + self.__conflictT[sn] = nil + dbg.fini("MT:removeConflicts") +end return M diff --git a/src/MainControl.lua b/src/MainControl.lua index 3f48ffdbe..18c27041d 100644 --- a/src/MainControl.lua +++ b/src/MainControl.lua @@ -1221,15 +1221,33 @@ function M.conflict(self, mA) end end + ------------------------------------------------------------------------ + -- check for current conflicits + + if (#a > 0) then + LmodError{msg="e_Conflict", name = fullName, module_list = concatTbl(a," ")} + end + + ------------------------------------------------------------------------ + -- register downstream conflicts if (permConflicts == "yes") then mt:registerConflicts(frameStk:mname(), mA) end + dbg.fini("MainControl:conflict") +end - if (#a > 0) then - LmodError{msg="e_Conflict", name = fullName, module_list = concatTbl(a," ")} +function M.removeConflict(self, mA) + dbg.start{"MainControl:removeConflict(mA)"} + local frameStk = FrameStk:singleton() + local mt = frameStk:mt() + local permConflicts = cosmic:value("LMOD_PERMANENT_CONFLICTS") + + if (permConflicts == "yes" ) then + mt:removeConflicts(frameStk:mname()) end - dbg.fini("MainControl:conflict") + + dbg.fini("MainControl:removeConflict") end --------------------------------------------------------------------------