Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for permissions set on Lmod SitePackage and fixed spacing #342

Merged
merged 3 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 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,21 +63,25 @@
-- 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)
end

TopRichard marked this conversation as resolved.
Show resolved Hide resolved
end


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
Loading