Skip to content

Commit

Permalink
Change lmod initialize from utils.lua file based to use initialize_lm…
Browse files Browse the repository at this point in the history
…od() function
  • Loading branch information
Robert McLay committed Nov 11, 2021
1 parent e4b6fe5 commit 10c0bbb
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 71 deletions.
2 changes: 2 additions & 0 deletions rt/configDir/configDir.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ testdescript = {
export LMOD_CONFIG_DIR=$(testDir)/lmod_cfg_dir
runLmod --config # 2
runLmod load tryThis # 3
runLmod load w # 4
HOME=$ORIG_HOME
Expand Down
22 changes: 16 additions & 6 deletions rt/configDir/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
step 1
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --version
===========================
Modules based on Lua: Version 8.5.24 2021-11-10 09:41 -06:00
Modules based on Lua: Version 8.5.26 2021-11-10 17:28 -06:00
by Robert McLay [email protected]
===========================
step 2
lua ProjectDIR/src/lmod.in.lua bash --regression_testing --config
===========================
Modules based on Lua: Version 8.5.24 2021-11-10 09:41 -06:00
Modules based on Lua: Version 8.5.26 2021-11-10 17:28 -06:00
by Robert McLay [email protected]
Description Value
Allow root to use Lmod yes
Expand All @@ -28,7 +28,7 @@ Use attached TCL over system call no
Use italic instead of dim no
KSH Support no
Language used for err/msg/warn en
Site message file <empty>
Site message file ProjectDIR/rt/configDir/lmod_cfg_dir/lang.lua
LUA_CPATH @sys_lua_cpath@
LUA_PATH @sys_lua_path@
System lua-term no
Expand Down Expand Up @@ -63,9 +63,10 @@ Tmod find first rule no
Tmod prepend PATH Rule no
Tracing no
uname -a
LMOD_CONFIG_DIR /etc/lmod ProjectDIR/rt/configDir/lmod_cfg_dir
LMOD_PACKAGE_PATH nil ProjectDIR/rt/configDir/lmod_cfg_dir
LMOD_SITE_NAME false XYZZY
LMOD_CONFIG_DIR /etc/lmod ProjectDIR/rt/configDir/lmod_cfg_dir
LMOD_PACKAGE_PATH nil ProjectDIR/rt/configDir/lmod_cfg_dir
LMOD_SITE_MSG_FILE false ProjectDIR/rt/configDir/lmod_cfg_dir/lang.lua
LMOD_SITE_NAME false XYZZY
Active RC file(s):
ProjectDIR/src/../init/lmodrc.lua
Lmod Property Table:
Expand Down Expand Up @@ -180,3 +181,12 @@ step 3
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load tryThis
===========================
This is kewl
===========================
step 4
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load w
===========================
Lmod Warning: The module w/1.0 is outdated. Please use a version from 2019a or newer.
If there is no newer version, request one at [email protected].
While processing the following module(s):
Module fullname Module Filename
w/1.0 ProjectDIR/rt/configDir/mf/w/1.0.lua
8 changes: 8 additions & 0 deletions rt/configDir/lmod_cfg_dir/lang.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Custom strings for SISC-HPC
-- Ward Poelmans <[email protected]>

return {
en = {
sisc_deprecated_module = "The module %{fullName} is outdated. Please use a version from %{tcver_cutoff} or newer.\nIf there is no newer version, request one at [email protected].\n",
}
}
3 changes: 2 additions & 1 deletion rt/configDir/lmod_cfg_dir/lmod_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ require("strict")
local cosmic = require("Cosmic"):singleton()
local testDir = os.getenv("testDir")

cosmic:assign("LMOD_PACKAGE_PATH", pathJoin(testDir,"lmod_cfg_dir"))
cosmic:assign("LMOD_PACKAGE_PATH", pathJoin(testDir,"lmod_cfg_dir"))
cosmic:assign("LMOD_SITE_MSG_FILE", pathJoin(testDir,"lmod_cfg_dir/lang.lua"))

cosmic:assign("LMOD_SITE_NAME", "XYZZY")

Expand Down
2 changes: 2 additions & 0 deletions rt/configDir/mf/w/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
local cutoff = string.format("%da", os.date("%Y") - 2)
LmodWarning{msg="sisc_deprecated_module", fullName=myModuleFullName(), tcver_cutoff=cutoff}
17 changes: 17 additions & 0 deletions rt/configDir/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ _LMFILES_=ProjectDIR/rt/configDir/mf/tryThis/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={tryThis={fn="ProjectDIR/rt/configDir/mf/tryThis/1.0.lua",fullName="tryThis/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="tryThis",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/configDir/mf",},systemBaseMPATH="ProjectDIR/rt/configDir/mf",}';
export _ModuleTable_;
===========================
step 4
lua ProjectDIR/src/lmod.in.lua bash --regression_testing load w
===========================
__LMOD_REF_COUNT_LOADEDMODULES=tryThis/1.0:1\;w/1.0:1;
export __LMOD_REF_COUNT_LOADEDMODULES;
LOADEDMODULES=tryThis/1.0:w/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/configDir/mf;
export MODULEPATH;
__LMOD_REF_COUNT__LMFILES_=ProjectDIR/rt/configDir/mf/tryThis/1.0.lua:1\;ProjectDIR/rt/configDir/mf/w/1.0.lua:1;
export __LMOD_REF_COUNT__LMFILES_;
_LMFILES_=ProjectDIR/rt/configDir/mf/tryThis/1.0.lua:ProjectDIR/rt/configDir/mf/w/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={tryThis={fn="ProjectDIR/rt/configDir/mf/tryThis/1.0.lua",fullName="tryThis/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="tryThis",wV="000000001.*zfinal",},w={fn="ProjectDIR/rt/configDir/mf/w/1.0.lua",fullName="w/1.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="w",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/configDir/mf",},systemBaseMPATH="ProjectDIR/rt/configDir/mf",}';
export _ModuleTable_;
false
1 change: 0 additions & 1 deletion src/check_module_tree_syntax.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ function main()
local errorT = { defaultA = {}, syntaxA = {} }

Shell = BaseShell:build("bash")
build_i18n_messages()
dbg.set_prefix(colorize("red","Lmod"))

------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/lmod.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ function main()
{cmd = 'whatis', min = 1, action = whatisTbl },
}

build_i18n_messages()
dbg.set_prefix(colorize("red","Lmod"))

local shellNm = barefilename(arg[1])
Expand Down
2 changes: 1 addition & 1 deletion src/ml_cmd.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ end
-- The main program. Process options and generate module command.
function main()

build_i18n_messages()
initialize_lmod()
local argA = {}
local optA = {}
local cmdA = {}
Expand Down
2 changes: 1 addition & 1 deletion src/sh_to_modulefile.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function main()
dbg:activateDebug(masterTbl.debug)
end

build_i18n_messages()
initialize_lmod()
if (masterTbl.cleanEnv) then
l_cleanEnv()
end
Expand Down
1 change: 0 additions & 1 deletion src/spider.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ function main()
local mpathA = {}

Shell = BaseShell:build("bash")
build_i18n_messages()

local master = Master:singleton(false)

Expand Down
104 changes: 45 additions & 59 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,45 +81,6 @@ function __LINE__()
return debug.getinfo(2, 'l').currentline
end

------------------------------------------------------------
-- Initialize Lmod

function initialize_lmod()
-- Push Lmod version into environment
setenv_lmod_version()

------------------------------------------------------------------------
-- The StandardPackage is where Lmod registers hooks. Sites may
-- override the hook functions in SitePackage.
------------------------------------------------------------------------
require("StandardPackage")

------------------------------------------------------------------------
-- Load a SitePackage Module.
------------------------------------------------------------------------

local configDir = cosmic:value("LMOD_CONFIG_DIR")
local fn = pathJoin(configDir,"lmod_config.lua")
if (isFile(fn)) then
assert(loadfile(fn))()
end

local lmodPath = cosmic:value("LMOD_PACKAGE_PATH")
for path in lmodPath:split(":") do
path = path .. "/"
path = path:gsub("//+","/")
package.path = path .. "?.lua;" ..
path .. "?/init.lua;" ..
package.path

package.cpath = path .. "../lib/?.so;"..
package.cpath
end

require("SitePackage")
end



--------------------------------------------------------------------------
-- Generate a message that will fix the available terminal width.
Expand Down Expand Up @@ -896,10 +857,6 @@ local function l_build_runTCLprog()
end
end

if (not runTCLprog) then
l_build_runTCLprog()
end

--------------------------------------------------------------------------
-- Create the accept functions to allow or ignore TCL modulefiles.
local function l_build_accept_function()
Expand All @@ -916,10 +873,6 @@ local function l_build_accept_function()
end
end

if (not accept_fn) then
l_build_accept_function()
end

local function l_build_allow_dups_function()
local dups = cosmic:value("LMOD_DUPLICATE_PATHS")
if (dups == "yes") then
Expand All @@ -933,10 +886,6 @@ local function l_build_allow_dups_function()
end
end

if (not allow_dups) then
l_build_allow_dups_function()
end

local function l_build_epoch_function()
if (posix.gettimeofday) then
local gettimeofday = posix.gettimeofday
Expand Down Expand Up @@ -993,10 +942,6 @@ local function l_build_prepend_order_function()
end
end

if (not prepend_order) then
l_build_prepend_order_function()
end

local s_checkSyntaxMode = false
function setSyntaxMode(state)
s_checkSyntaxMode = state
Expand All @@ -1018,8 +963,49 @@ local function l_build_quarantineT()
end
end

if (not QuarantineT) then
l_build_quarantineT()
end
------------------------------------------------------------
-- Initialize Lmod

function initialize_lmod()
-- Push Lmod version into environment
setenv_lmod_version()

------------------------------------------------------------------------
-- The StandardPackage is where Lmod registers hooks. Sites may
-- override the hook functions in SitePackage.
------------------------------------------------------------------------
require("StandardPackage")

------------------------------------------------------------------------
-- Load a SitePackage Module.
------------------------------------------------------------------------

local configDir = cosmic:value("LMOD_CONFIG_DIR")
local fn = pathJoin(configDir,"lmod_config.lua")
if (isFile(fn)) then
assert(loadfile(fn))()
end

build_i18n_messages()
l_build_runTCLprog()
l_build_accept_function()
l_build_allow_dups_function()
l_build_prepend_order_function()
if (not QuarantineT) then
l_build_quarantineT()
end


local lmodPath = cosmic:value("LMOD_PACKAGE_PATH")
for path in lmodPath:split(":") do
path = path .. "/"
path = path:gsub("//+","/")
package.path = path .. "?.lua;" ..
path .. "?/init.lua;" ..
package.path

package.cpath = path .. "../lib/?.so;"..
package.cpath
end

require("SitePackage")
end

0 comments on commit 10c0bbb

Please sign in to comment.