Skip to content

Commit

Permalink
Issue #679: add code to remove downstream conflicts when module is un…
Browse files Browse the repository at this point in the history
…loaded
  • Loading branch information
Robert McLay committed Mar 19, 2024
1 parent db71a6d commit e43809c
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 32 deletions.
1 change: 1 addition & 0 deletions .versionDate
@@ -0,0 +1 @@
2024-03-19 16:11 -06:00
8 changes: 6 additions & 2 deletions Makefile.in
Expand Up @@ -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@
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'` ; \
Expand Down
4 changes: 3 additions & 1 deletion rt/conflict/conflict.tdesc
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion rt/conflict/err.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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
===========================
68 changes: 68 additions & 0 deletions rt/conflict/out.txt
Expand Up @@ -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_;
54 changes: 31 additions & 23 deletions src/Hub.lua
Expand Up @@ -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.
Expand Down Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion src/MC_Unload.lua
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/MT.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
24 changes: 21 additions & 3 deletions src/MainControl.lua
Expand Up @@ -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

--------------------------------------------------------------------------
Expand Down

0 comments on commit e43809c

Please sign in to comment.