Skip to content

Commit

Permalink
Issue #679 support for downstream conflicts added
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Mar 28, 2024
1 parent 60d1280 commit c92dc6f
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 21 deletions.
1 change: 1 addition & 0 deletions messageDir/en.lua
Expand Up @@ -110,6 +110,7 @@ return {
e_BrokenCacheFn = "Spider cache fn: \"%{fn}\" appears broken",
e_BrokenQ = "Internal error: broken module Q\n",
e_Conflict = "Cannot load module \"%{name}\" because these module(s) are loaded:\n %{module_list}\n",
e_Conflict_Downstream = "Cannot load module \"%{userName}\" because this module set a conflict: \"%{fullNameUpstream}\"\n",
e_Execute_Msg = [==[Syntax error in file: %{fn}
with command: "execute".
The syntax is:
Expand Down
10 changes: 10 additions & 0 deletions rt/conflict/conflict.tdesc
Expand Up @@ -53,6 +53,16 @@ testdescript = {
runLmod load D/1.1 #22
runLmod load acme #23
# Test downstream conflicts
runLmod purge #24
runLmod load acme #25
runLmod load D/1.1 #26
runLmod load D/1.3 #27
runLmod list #28
HOME=$ORIG_HOME
Expand Down
23 changes: 23 additions & 0 deletions rt/conflict/err.txt
Expand Up @@ -127,3 +127,26 @@ The following have been reloaded with a version change:
step 23
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load acme
===========================
===========================
step 24
lua ProjectDIR/src/lmod.in.lua shell --regression_testing purge
===========================
===========================
step 25
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load acme
===========================
===========================
step 26
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load D/1.1
===========================
===========================
step 27
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load D/1.3
===========================
Lmod has detected the following error: Cannot load module "D/1.3" because this module set a conflict: "acme/1.0"
===========================
step 28
lua ProjectDIR/src/lmod.in.lua shell --regression_testing list
===========================
Currently Loaded Modules:
1) acme/1.0 2) D/1.1
50 changes: 50 additions & 0 deletions rt/conflict/out.txt
Expand Up @@ -235,3 +235,53 @@ _LMFILES_=ProjectDIR/rt/conflict/mf2/Core/D/1.1.lua:ProjectDIR/rt/conflict/mf2/C
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.1>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},},depthT={},family={},mT={D={fn="ProjectDIR/rt/conflict/mf2/Core/D/1.1.lua",fullName="D/1.1",loadOrder=1,propT={},stackDepth=0,status="active",userName="D/1.1",wV="000000001.000000001.*zfinal",},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",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}';
export _ModuleTable_;
===========================
step 24
lua ProjectDIR/src/lmod.in.lua shell --regression_testing purge
===========================
unset D;
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_;
===========================
step 25
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load acme
===========================
LOADEDMODULES=acme/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/conflict/mf2/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.1>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},},depthT={},family={},mT={acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}';
export _ModuleTable_;
===========================
step 26
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load D/1.1
===========================
D=1.1;
export D;
LOADEDMODULES=acme/1.0:D/1.1;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/conflict/mf2/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua:ProjectDIR/rt/conflict/mf2/Core/D/1.1.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.1>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},},depthT={},family={},mT={D={fn="ProjectDIR/rt/conflict/mf2/Core/D/1.1.lua",fullName="D/1.1",loadOrder=2,propT={},stackDepth=0,status="active",userName="D/1.1",wV="000000001.000000001.*zfinal",},acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}';
export _ModuleTable_;
===========================
step 27
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load D/1.3
===========================
false
===========================
step 28
lua ProjectDIR/src/lmod.in.lua shell --regression_testing list
===========================
MODULEPATH=ProjectDIR/rt/conflict/mf2/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,conflictT={acme={{action="between",ie="<3.2",is="1.1>",sType="mt",userName="D",},{action="match",ie=false,is=false,sType="mt",userName="E",},},},depthT={},family={},mT={D={fn="ProjectDIR/rt/conflict/mf2/Core/D/1.1.lua",fullName="D/1.1",loadOrder=2,propT={},stackDepth=0,status="active",userName="D/1.1",wV="000000001.000000001.*zfinal",},acme={fn="ProjectDIR/rt/conflict/mf2/Core/acme/1.0.lua",fullName="acme/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="acme",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/conflict/mf2/Core",},systemBaseMPATH="ProjectDIR/rt/conflict/mf2/Core",}';
export _ModuleTable_;
23 changes: 13 additions & 10 deletions src/Hub.lua
Expand Up @@ -56,7 +56,6 @@ local cosmic = require("Cosmic"):singleton()
local dbg = require("Dbg"):dbg()
local hook = require("Hook")
local i18n = require("i18n")
local dsConflicts = cosmic:value("LMOD_DOWNSTREAM_CONFLICTS")
local remove = table.remove
local sort = table.sort
local q_load = 0
Expand Down Expand Up @@ -303,12 +302,13 @@ function M.load(self, mA)

local disable_same_name_autoswap = cosmic:value("LMOD_DISABLE_SAME_NAME_AUTOSWAP")

local optionTbl = optionTbl()
local tracing = cosmic:value("LMOD_TRACING")
local frameStk = FrameStk:singleton()
local shell = _G.Shell
local shellNm = shell and shell:name() or "bash"
local a = true
local dsConflicts = cosmic:value("LMOD_DOWNSTREAM_CONFLICTS")
local optionTbl = optionTbl()
local tracing = cosmic:value("LMOD_TRACING")
local frameStk = FrameStk:singleton()
local shell = _G.Shell
local shellNm = shell and shell:name() or "bash"
local a = true
local mt


Expand All @@ -318,10 +318,13 @@ function M.load(self, mA)
local userName = mname:userName()
mt = frameStk:mt()

dbg.print{"dsConflicts: ",dsConflicts,"\n"}
if (dsConflicts == "yes") then
local mnameUpstream = mt:haveDSConflict(mname)
if (mnameUpstream) then
LmodError{msg="e_Conflict_Downstream",upStream=mnameUpstream:fullName(), userName=userName}
local snUpstream = mt:haveDSConflict(mname)
if (snUpstream) then
local fullNameUpstream = mt:fullName(snUpstream)
LmodError{msg="e_Conflict_Downstream", fullNameUpstream = fullNameUpstream,
userName=userName}
end
end

Expand Down
15 changes: 8 additions & 7 deletions src/MName.lua
Expand Up @@ -713,28 +713,29 @@ function M.conflictCk(self, mt)
return userName
end

function downstreamConflictCk(self, mnameIn)
function M.downstreamConflictCk(self, mnameIn)
local snIn = mnameIn:sn()
dbg.start{"MName:downstreamConflictCk(snIn:", snIn,")"}

local sn = self:sn()
local userName = false
local have_range = nil
local sn = self:sn()
local result = false
if (snIn ~= sn) then
return userName
return result
end

local have_range, result = l_rangeCk(self, mname:version(), mnameIn:userName(), false)
have_range, result = l_rangeCk(self, mnameIn:version(), mnameIn:userName(), false)
if (have_range) then
dbg.fini( "MName:downstreamConflictCk")
return result
end

if (self:userName() == snIn or extractVersion(userName, sn) == mnameIn:version()) then
userName = mnameIn:userName()
result = snIn
end

dbg.fini( "MName:downstreamConflictCk")
return userName
return result
end

function M.set_depends_on_flag(self, value)
Expand Down
9 changes: 5 additions & 4 deletions src/MT.lua
Expand Up @@ -1514,13 +1514,14 @@ function M.haveDSConflict(self, mnameIn)
dbg.start{"MT:haveDSConflict(sn:", snIn,")"}
end

local cT = self.__conflictT
local cT = self.__conflictT
local MName = require("MName")
for sn, vv in pairs(cT) do
for i = 1,#vv do
local conflict_mname = vv[i]
local userName = conflict_mname:downstreamConflictCk(mnameIn)
if (userName) then
return userName
local snUpstream = conflict_mname:downstreamConflictCk(mnameIn)
if (snUpstream) then
return sn
end
end
end
Expand Down

0 comments on commit c92dc6f

Please sign in to comment.