Skip to content

Commit

Permalink
Merge pull request #342 from TopRichard/EESSI-PR538
Browse files Browse the repository at this point in the history
Add fix for permissions set on Lmod SitePackage and fixed spacing
  • Loading branch information
trz42 authored May 1, 2024
2 parents 3b52dd5 + 9ff4384 commit f75e386
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions create_lmodsitepackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
import os
import sys
from stat import S_IREAD, S_IWRITE, S_IRGRP, S_IWGRP, S_IROTH

DOT_LMOD = '.lmod'

Expand Down Expand Up @@ -62,16 +63,20 @@
-- Again, the host site could also decide to overwrite by simply doing
--
-- hook.register("load", arch_specific_load_hook)
-- get path to to architecture independent SitePackage.lua
local prefixHostInjections = string.gsub(os.getenv('EESSI_PREFIX') or "", 'versions', 'host_injections')
local hostSitePackage = prefixHostInjections .. "/.lmod/SitePackage.lua"
-- If the file exists, run it
if isFile(hostSitePackage) then
dofile(hostSitePackage)
end
-- build the full architecture specific path in host_injections
local archHostInjections = string.gsub(os.getenv('EESSI_SOFTWARE_PATH') or "", 'versions', 'host_injections')
local archSitePackage = archHostInjections .. "/.lmod/SitePackage.lua"
-- If the file exists, run it
if isFile(archSitePackage) then
dofile(archSitePackage)
Expand Down Expand Up @@ -176,6 +181,8 @@ def error(msg):
os.makedirs(os.path.dirname(sitepackage_path), exist_ok=True)
with open(sitepackage_path, 'w') as fp:
fp.write(hook_txt)
# Make sure that the created Lmod file has "read/write" for the user/group and "read" permissions for others
os.chmod(sitepackage_path, S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH)

except (IOError, OSError) as err:
error("Failed to create %s: %s" % (sitepackage_path, err))
Expand Down

0 comments on commit f75e386

Please sign in to comment.