summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Cohn <rscohn2@gmail.com>2021-05-05 17:00:34 -0400
committerGitHub <noreply@github.com>2021-05-05 14:00:34 -0700
commitab018c2081672d9a412743ce6a7c645ff98177b3 (patch)
tree19b2728675385d7edece64da2035fecaf902cdd1 /lib
parentd51deb4961754e5dcc940374e8a545706eb13e96 (diff)
downloadspack-ab018c2081672d9a412743ce6a7c645ff98177b3.tar.gz
spack-ab018c2081672d9a412743ce6a7c645ff98177b3.tar.bz2
spack-ab018c2081672d9a412743ce6a7c645ff98177b3.tar.xz
spack-ab018c2081672d9a412743ce6a7c645ff98177b3.zip
intel-oneapi packages: support root installs (#23401)
When installing OneAPI packages as root (e.g. in a container), the installer places cache files in /var/intel/installercache that interfere with future Spack installs. This ensures that when running an installation as a root user that this is removed.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_systems/oneapi.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/spack/spack/build_systems/oneapi.py b/lib/spack/spack/build_systems/oneapi.py
index dfa1e1da78..0844ff5d82 100644
--- a/lib/spack/spack/build_systems/oneapi.py
+++ b/lib/spack/spack/build_systems/oneapi.py
@@ -7,6 +7,8 @@
"""
+import getpass
+import shutil
from sys import platform
from os.path import basename, dirname, isdir
@@ -47,6 +49,22 @@ class IntelOneApiPackage(Package):
installer_path = basename(self.url_for_version(spec.version))
if platform == 'linux':
+ # Intel installer assumes and enforces that all components
+ # are installed into a single prefix. Spack wants to
+ # install each component in a separate prefix. The
+ # installer mechanism is implemented by saving install
+ # information in a directory called installercache for
+ # future runs. The location of the installercache depends
+ # on the userid. For root it is always in /var/intel. For
+ # non-root it is in $HOME/intel.
+ #
+ # The method for preventing this install from interfering
+ # with other install depends on the userid. For root, we
+ # delete the installercache before and after install. For
+ # non root we redefine the HOME environment variable.
+ if getpass.getuser() == 'root':
+ shutil.rmtree('/var/intel/installercache', ignore_errors=True)
+
bash = Executable('bash')
# Installer writes files in ~/intel set HOME so it goes to prefix
@@ -57,6 +75,9 @@ class IntelOneApiPackage(Package):
'--eula', 'accept',
'--install-dir', prefix)
+ if getpass.getuser() == 'root':
+ shutil.rmtree('/var/intel/installercache', ignore_errors=True)
+
# Some installers have a bug and do not return an error code when failing
if not isdir(join_path(prefix, self.component_dir)):
raise RuntimeError('install failed')