|
| 1 | +easyblock = 'Bundle' |
| 2 | + |
| 3 | +name = 'NESSI-extend' |
| 4 | +version = '2023.06' |
| 5 | +# May have different ways to extend NESSI in the future (manually, other tools,...) |
| 6 | +versionsuffix = '-easybuild' |
| 7 | + |
| 8 | +homepage = 'https://documentation.sigma2.no/software/nessi_eessi.html' |
| 9 | + |
| 10 | +description = """ |
| 11 | + NESSI is an innovative service to make optimized scientific software |
| 12 | + installations available on any machine anywhere in the world in near |
| 13 | + real-time - without the need to build or install the software. NESSI |
| 14 | + works similarly to popular streaming services for videos and music. |
| 15 | +
|
| 16 | + NESSI is a sibling of EESSI, the European Environment for Scientific |
| 17 | + Software Installations (see https://eessi.io/docs). |
| 18 | +
|
| 19 | + This module allows you to extend NESSI using the same configuration for |
| 20 | + EasyBuild as NESSI itself uses. A number of environment variables control the |
| 21 | + behaviour of the module: |
| 22 | + - NESSI_USER_INSTALL can be set to a location to install modules for use by |
| 23 | + the user only. The location must already exist on the filesystem. |
| 24 | + - NESSI_PROJECT_INSTALL can be set to a location to install modules for use by |
| 25 | + a project. The location must already exist on the filesystem and you should |
| 26 | + ensure that the location has the correct Linux group and the SGID permission |
| 27 | + is set on that directory (`chmod g+s $NESSI_PROJECT_INSTALL`) so that all |
| 28 | + members of the group have permission to read and write installations. |
| 29 | + - NESSI_SITE_INSTALL is either defined or not and cannot be used with another |
| 30 | + environment variable. A site installation is done in a defined location and |
| 31 | + any installations there are (by default) world readable. |
| 32 | + - NESSI_CVMFS_INSTALL is either defined or not and cannot be used with another |
| 33 | + environment variable. A CVMFS installation targets a defined location which |
| 34 | + will be ingested into CVMFS and is only useful for CVMFS administrators. |
| 35 | + - If none of the environment variables above are defined, a NESSI_USER_INSTALL |
| 36 | + is assumed with a value of $HOME/NESSI |
| 37 | + If both NESSI_USER_INSTALL and NESSI_PROJECT_INSTALL are defined, both sets of |
| 38 | + installations are exposed, but new installations are created as user |
| 39 | + installations. |
| 40 | +""" |
| 41 | + |
| 42 | +toolchain = SYSTEM |
| 43 | + |
| 44 | +# All the dependencies we filter in NESSI |
| 45 | +local_deps_to_filter = "Autoconf,Automake,Autotools,binutils,bzip2,DBus,flex,gettext,gperf,help2man,intltool,libreadline,libtool,M4,makeinfo,ncurses,util-linux,XZ,zlib" |
| 46 | +local_arch_specific_deps_to_filter = {'aarch64': ',yasm', 'x86_64': ''} |
| 47 | +local_deps_to_filter += local_arch_specific_deps_to_filter[ARCH] |
| 48 | + |
| 49 | +# Set the universal EasyBuild variables |
| 50 | +modextravars = { |
| 51 | + 'EASYBUILD_FILTER_DEPS': local_deps_to_filter, |
| 52 | + 'EASYBUILD_IGNORE_OSDEPS': '1', |
| 53 | + 'EASYBUILD_DEBUG': '1', |
| 54 | + 'EASYBUILD_TRACE': '1', |
| 55 | + 'EASYBUILD_ZIP_LOGS': 'bzip2', |
| 56 | + 'EASYBUILD_RPATH': '1', |
| 57 | + 'EASYBUILD_FILTER_ENV_VARS': 'LD_LIBRARY_PATH', |
| 58 | + 'EASYBUILD_READ_ONLY_INSTALLDIR': '1', |
| 59 | + 'EASYBUILD_MODULE_EXTENSIONS': '1', |
| 60 | + 'EASYBUILD_EXPERIMENTAL': '1', |
| 61 | +} |
| 62 | + |
| 63 | +# Need a few other variables, but they are more dynamic |
| 64 | +# EASYBUILD_SYSROOT=${EPREFIX} |
| 65 | +# EASYBUILD_PREFIX=${WORKDIR}/easybuild |
| 66 | +# EASYBUILD_HOOKS=${EESSI_PREFIX}/init/easybuild/eb_hooks.py |
| 67 | +# EASYBUILD_INSTALLPATH=${EESSI_PREFIX}/software/${EESSI_OS_TYPE}/${EESSI_SOFTWARE_SUBDIR} |
| 68 | +# EASYBUILD_SOURCEPATH=${WORKDIR}/easybuild/sources:${EESSI_SOURCEPATH} |
| 69 | +# |
| 70 | +# And also some optional ones based on the kind of installation |
| 71 | +# EASYBUILD_SET_GID_BIT |
| 72 | +# EASYBUILD_GROUP_WRITABLE_INSTALLDIR |
| 73 | +# EASYBUILD_UMASK |
| 74 | +# EASYBUILD_STICKY_BIT |
| 75 | +modluafooter = """ |
| 76 | +if (mode() == "load") then |
| 77 | + -- Use a working directory for temporary build files |
| 78 | + if (os.getenv("WORKING_DIR") == nil) then |
| 79 | + LmodMessage("-- Using /tmp/$USER as a temporary working directory for installations, you can override this by setting the environment variable WORKING_DIR and reloading the module (e.g., /dev/shm is a common option)") |
| 80 | + end |
| 81 | +end |
| 82 | +working_dir = os.getenv("WORKING_DIR") or pathJoin("/tmp", os.getenv("USER")) |
| 83 | +-- Gather the EPREFIX to use as a sysroot |
| 84 | +sysroot = os.getenv("EESSI_EPREFIX") |
| 85 | +-- Use an installation prefix that we _should_ have write access to |
| 86 | +if (os.getenv("NESSI_CVMFS_INSTALL") ~= nil) then |
| 87 | + -- Make sure no other NESSI install environment variables are set |
| 88 | + if ((os.getenv("NESSI_SITE_INSTALL") ~= nil) or (os.getenv("NESSI_PROJECT_INSTALL") ~= nil) or (os.getenv("NESSI_USER_INSTALL") ~= nil)) then |
| 89 | + LmodError("You cannot use NESSI_CVMFS_INSTALL in combination with any other NESSI_*_INSTALL environment variables") |
| 90 | + end |
| 91 | + eessi_cvmfs_install = true |
| 92 | + easybuild_installpath = os.getenv("EESSI_SOFTWARE_PATH") |
| 93 | +elseif (os.getenv("NESSI_SITE_INSTALL") ~= nil) then |
| 94 | + -- Make sure no other NESSI install environment variables are set |
| 95 | + if ((os.getenv("NESSI_PROJECT_INSTALL") ~= nil) or (os.getenv("NESSI_USER_INSTALL") ~= nil)) then |
| 96 | + LmodError("You cannot use NESSI_SITE_INSTALL in combination with any other NESSI_*_INSTALL environment variables") |
| 97 | + end |
| 98 | + easybuild_installpath = string.gsub(os.getenv("EESSI_SOFTWARE_PATH"), 'versions', 'host_injections') |
| 99 | +else |
| 100 | + -- Deal with user and project installs |
| 101 | + project_install = os.getenv("NESSI_PROJECT_INSTALL") |
| 102 | + project_modulepath = nil |
| 103 | + if (project_install ~= nil) then |
| 104 | + -- Check the folder exists |
| 105 | + if not isDir(project_install) then |
| 106 | + LmodError("The location of NESSI_PROJECT_INSTALL (" .. project_install .. ") does not exist or is not a folder") |
| 107 | + end |
| 108 | + if (mode() == "load") then |
| 109 | + LmodMessage("Configuring for use of NESSI_PROJECT_INSTALL under " .. project_install) |
| 110 | + end |
| 111 | + easybuild_installpath = string.gsub(os.getenv("EESSI_SOFTWARE_PATH"), os.getenv("EESSI_CVMFS_REPO"), project_install) |
| 112 | + project_modulepath = pathJoin(easybuild_installpath, 'modules', 'all') |
| 113 | + end |
| 114 | + user_install = os.getenv("NESSI_USER_INSTALL") |
| 115 | + user_modulepath = nil |
| 116 | + if (user_install ~= nil) then |
| 117 | + -- Check the folder exists |
| 118 | + if not isDir(user_install) then |
| 119 | + LmodError("The location of NESSI_USER_INSTALL (" .. user_install .. ") does not exist or is not a folder") |
| 120 | + end |
| 121 | + elseif (user_install == nil) and (project_install == nil) then |
| 122 | + -- No need to check for existence when we use a HOME subdir |
| 123 | + user_install = pathJoin(os.getenv("HOME"), "nessi") |
| 124 | + end |
| 125 | + if (user_install ~= nil) then |
| 126 | + if (mode() == "load") then |
| 127 | + LmodMessage("Configuring for use of NESSI_USER_INSTALL under " .. user_install) |
| 128 | + end |
| 129 | + easybuild_installpath = string.gsub(os.getenv("EESSI_SOFTWARE_PATH"), os.getenv("EESSI_CVMFS_REPO"), user_install) |
| 130 | + user_modulepath = pathJoin(easybuild_installpath, 'modules', 'all') |
| 131 | + end |
| 132 | +end |
| 133 | +if (mode() == "load") then |
| 134 | + LmodMessage("-- To create installations for NESSI, you _must_ have write permissions to " .. easybuild_installpath) |
| 135 | + -- Advise them to reuse sources |
| 136 | + if (os.getenv("EASYBUILD_SOURCEPATH") == nil) then |
| 137 | + LmodMessage("-- You may wish to configure a sources directory for EasyBuild (for example, via setting the environment variable EASYBUILD_SOURCEPATH) to allow you to reuse existing sources for packages.") |
| 138 | + end |
| 139 | +end |
| 140 | +-- Set the relevant universal environment variables for EasyBuild |
| 141 | +setenv ("EASYBUILD_SYSROOT", sysroot) |
| 142 | +setenv ("EASYBUILD_PREFIX", pathJoin(working_dir, "easybuild")) |
| 143 | +setenv ("EASYBUILD_INSTALLPATH", easybuild_installpath) |
| 144 | +setenv ("EASYBUILD_HOOKS", pathJoin(os.getenv("EESSI_PREFIX"), "init", "easybuild", "eb_hooks.py")) |
| 145 | +setenv ("EASYBUILD_UMASK", "002") |
| 146 | +
|
| 147 | +-- Set all related environment variables if we have project or user installations (including extending MODULEPATH) |
| 148 | +if (user_modulepath ~= nil) then |
| 149 | + -- Use a more restrictive umask for this case |
| 150 | + setenv ("EASYBUILD_UMASK", "022") |
| 151 | + setenv ("EASYBUILD_STICKY_BIT", "1") |
| 152 | + -- configure MODULEPATH |
| 153 | + if (project_modulepath ~= nil) then |
| 154 | + prepend_path("MODULEPATH", project_modulepath) |
| 155 | + end |
| 156 | + prepend_path("MODULEPATH", user_modulepath) |
| 157 | +elseif (project_modulepath ~= nil) then |
| 158 | + setenv ("EASYBUILD_SET_GID_BIT", "1") |
| 159 | + setenv ("EASYBUILD_GROUP_WRITABLE_INSTALLDIR", "1") |
| 160 | + setenv ("EASYBUILD_STICKY_BIT", "0") |
| 161 | + -- configure MODULEPATH |
| 162 | + prepend_path("MODULEPATH", project_modulepath) |
| 163 | +end |
| 164 | +-- Make sure EasyBuild itself is loaded |
| 165 | +if not ( isloaded("EasyBuild") ) then |
| 166 | + load("EasyBuild") |
| 167 | +end |
| 168 | +""" |
| 169 | + |
| 170 | +moduleclass = 'devel' |
0 commit comments