Skip to content

Commit 37a16ff

Browse files
author
Robert McLay
committed
Merge branch 'testing' into PR674
2 parents 86f9d66 + 8d3c4d6 commit 37a16ff

10 files changed

Lines changed: 61 additions & 11 deletions

File tree

README.new

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ Lmod 8.7+
117117
(8.7.32) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function.
118118
* Better name for extension title, remove trailing \n
119119
* Testing github actions
120+
W.I.P:
121+
(8.7.33) * Issue #678: Change isFile(fn) to return nil if fn is a broken symlink.
122+
* Issue #678: Change abspath() to l_abspath() in tools/fileOps.lua
123+
* Issue #678: Create realpath() to use posix.realpath() if it exists otherwise use l_abspath()
124+

rt/symlink/err.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
step 1
33
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
44
===========================
5-
Modules based on Lua: Version 8.6.9 2022-02-02 11:25 -04:00
5+
Modules based on Lua: Version 8.7.32 2023-08-28 12:42 -05:00
66
by Robert McLay mclay@tacc.utexas.edu
77
===========================
88
step 2
99
lua ProjectDIR/src/lmod.in.lua shell --regression_testing avail
1010
===========================
1111
ProjectDIR/rt/symlink/mf/Core
12-
a/1.1 boost/1.55.0 (D) intel/14.0.2 mv2/2.1
13-
a/1.2 (D) boost/1.56.0 mv2/2.0 mv2/2.2
14-
b/1.1 (D) intel/12.1.5 (D) mv2/2.1rc1
15-
b/1.2 intel/13.1 mv2/2.1rc2 (D)
12+
a/1.1 bad_symlink/1.0 intel/13.1 mv2/2.1rc2 (D)
13+
a/1.2 (D) boost/1.55.0 (D) intel/14.0.2 mv2/2.1
14+
b/1.1 (D) boost/1.56.0 mv2/2.0 mv2/2.2
15+
b/1.2 intel/12.1.5 (D) mv2/2.1rc1
1616
Where:
1717
D: Default Module
1818
If the avail list is too long consider trying:
@@ -27,6 +27,7 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing -t -d avail
2727
ProjectDIR/rt/symlink/mf/Core:
2828
a/1.2
2929
b/1.1
30+
bad_symlink/1.0
3031
boost/1.55.0
3132
intel/12.1.5
3233
mv2/2.1rc2
@@ -40,3 +41,10 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing list
4041
===========================
4142
Currently Loaded Modules:
4243
1) intel/12.1.5 2) a/1.2 3) b/1.1 4) boost/1.55.0 5) mv2/2.1rc2
44+
===========================
45+
step 6
46+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load bad_symlink
47+
===========================
48+
good.text true
49+
bad1.text nil
50+
bad2.text nil
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
local a = { "good.text", "bad1.text", "bad2.text"}
2+
3+
for i = 1,#a do
4+
local result = isFile(a[i])
5+
io.stderr:write(a[i].." "..tostring(result).."\n")
6+
end
7+

rt/symlink/out.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ MODULEPATH=ProjectDIR/rt/symlink/mf/Core;
4444
export MODULEPATH;
4545
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={a={fn="ProjectDIR/rt/symlink/mf/Core/a/1.2.lua",fullName="a/1.2",loadOrder=2,propT={},stackDepth=0,status="active",userName="a",wV="^00000001.000000002.*zfinal",},b={fn="ProjectDIR/rt/symlink/mf/Core/b/1.1.lua",fullName="b/1.1",loadOrder=3,propT={},stackDepth=0,status="active",userName="b",wV="^00000001.000000001.*zfinal",},boost={fn="ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua",fullName="boost/1.55.0",loadOrder=4,propT={},stackDepth=0,status="active",userName="boost",wV="^00000001.000000055.*zfinal",},intel={fn="ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua",fullName="intel/12.1.5",loadOrder=1,propT={},stackDepth=0,status="active",userName="intel",wV="^00000012.000000001.000000005.*zfinal",},mv2={fn="ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua",fullName="mv2/2.1rc2",loadOrder=5,propT={},stackDepth=0,status="active",userName="mv2",wV="^00000002.000000001.*c.000000002.*zfinal",},},mpathA={"ProjectDIR/rt/symlink/mf/Core",},systemBaseMPATH="ProjectDIR/rt/symlink/mf/Core",}';
4646
export _ModuleTable_;
47+
===========================
48+
step 6
49+
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load bad_symlink
50+
===========================
51+
LOADEDMODULES=intel/12.1.5:a/1.2:b/1.1:boost/1.55.0:mv2/2.1rc2:bad_symlink/1.0;
52+
export LOADEDMODULES;
53+
MODULEPATH=ProjectDIR/rt/symlink/mf/Core;
54+
export MODULEPATH;
55+
_LMFILES_=ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua:ProjectDIR/rt/symlink/mf/Core/a/1.2.lua:ProjectDIR/rt/symlink/mf/Core/b/1.1.lua:ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua:ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua:ProjectDIR/rt/symlink/mf/Core/bad_symlink/1.0.lua;
56+
export _LMFILES_;
57+
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={a={fn="ProjectDIR/rt/symlink/mf/Core/a/1.2.lua",fullName="a/1.2",loadOrder=2,propT={},stackDepth=0,status="active",userName="a",wV="^00000001.000000002.*zfinal",},b={fn="ProjectDIR/rt/symlink/mf/Core/b/1.1.lua",fullName="b/1.1",loadOrder=3,propT={},stackDepth=0,status="active",userName="b",wV="^00000001.000000001.*zfinal",},bad_symlink={fn="ProjectDIR/rt/symlink/mf/Core/bad_symlink/1.0.lua",fullName="bad_symlink/1.0",loadOrder=6,propT={},stackDepth=0,status="active",userName="bad_symlink",wV="000000001.*zfinal",},boost={fn="ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua",fullName="boost/1.55.0",loadOrder=4,propT={},stackDepth=0,status="active",userName="boost",wV="^00000001.000000055.*zfinal",},intel={fn="ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua",fullName="intel/12.1.5",loadOrder=1,propT={},stackDepth=0,status="active",userName="intel",wV="^00000012.000000001.000000005.*zfinal",},mv2={fn="ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua",fullName="mv2/2.1rc2",loadOrder=5,propT={},stackDepth=0,status="active",userName="mv2",wV="^00000002.000000001.*c.000000002.*zfinal",},},mpathA={"ProjectDIR/rt/symlink/mf/Core",},systemBaseMPATH="ProjectDIR/rt/symlink/mf/Core",}';
58+
export _ModuleTable_;

rt/symlink/symlink.tdesc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ testdescript = {
2323
MODULEPATH=$MODULEPATH_ROOT/Core; export MODULEPATH
2424
2525
rm -fr _stderr.* _stdout.* err.* out.* .lmod.d .cache .config
26+
rm -f good.text bad1.text bad2.text
2627
2728
runLmod --version # 1
2829
runLmod avail # 2
2930
runLmod -t -d avail # 3
3031
runLmod load intel a b boost mv2 # 4
3132
runLmod list # 5
33+
touch good.text
34+
ln -s bad bad1.text
35+
ln -s bad1.text bad2.text
36+
runLmod load bad_symlink # 6
37+
3238
3339
3440

src/cmdfuncs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ function Use(...)
12021202
if (v:sub(1,1) ~= '/') then
12031203
local old = v
12041204
-- If relative convert to try to convert to absolute path
1205-
v = abspath(v)
1205+
v = realpath(v)
12061206
-- If it doesn't exist then build path with current directory and relative path.
12071207
if (not v) then
12081208
v = pathJoin(posix.getcwd(), old)

src/sandbox.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ local sandbox_env = {
218218
removeExt = removeExt,
219219
barefilename = barefilename,
220220
splitFileName = splitFileName,
221-
abspath = abspath,
221+
abspath = realpath,
222+
realpath = realpath,
222223
path_regularize = path_regularize,
223224

224225
------------------------------------------------------------

src/spider.in.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ local function l_add2map(entry, tbl, dirA, moduleFn, kind, rmapT)
211211
end
212212
dbg.print{"assigning rmapT for path: ",path,"\n"}
213213
rmapT[path] = t
214-
local p2 = abspath(path)
214+
local p2 = realpath(path)
215215
if (p2 and p2 ~= path) then
216216
dbg.print{"assigning rmapT for path: ",p2,"\n"}
217217
rmapT[p2] = deepcopy(t)

src/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ function locatePkg(pkg)
12041204
for path in package.path:split(";") do
12051205
local s = path:gsub("?",pkg)
12061206
if (isFile(s)) then
1207-
result = abspath(s)
1207+
result = realpath(s)
12081208
break
12091209
end
12101210
end

tools/fileOps.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ function isFile(fn)
147147
local t = posix.stat(fn,"type")
148148

149149
local result = t and t ~= "directory"
150+
if (t == "link") then
151+
result = realpath(fn)
152+
end
150153
return result
151154
end
152155

@@ -318,7 +321,7 @@ end
318321
-- when following symlinks
319322
-- @return A absolute path.
320323

321-
function abspath (path, localDir)
324+
local function l_abspath (path, localDir)
322325
if (path == nil) then return nil end
323326

324327
local cwd = lfs.currentdir()
@@ -355,12 +358,20 @@ function abspath (path, localDir)
355358
lfs.chdir(cwd)
356359
return result
357360
end
358-
result = abspath(rl, localDir)
361+
result = l_abspath(rl, localDir)
359362
end
360363
lfs.chdir(cwd)
361364
return result
362365
end
363366

367+
function realpath(path, localDir)
368+
if (localDir or not posix.realpath) then
369+
return l_abspath(path, localDir)
370+
end
371+
return posix.realpath(path)
372+
end
373+
374+
364375
--------------------------------------------------------------------------
365376
-- Remove leading and trail spaces and extra slashes.
366377
-- @param value A path

0 commit comments

Comments
 (0)