From ab018c2081672d9a412743ce6a7c645ff98177b3 Mon Sep 17 00:00:00 2001 From: Robert Cohn Date: Wed, 5 May 2021 17:00:34 -0400 Subject: 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. --- lib/spack/spack/build_systems/oneapi.py | 21 +++++++++++++++++++++ x.tgz | Bin 0 -> 9087 bytes 2 files changed, 21 insertions(+) create mode 100644 x.tgz 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') diff --git a/x.tgz b/x.tgz new file mode 100644 index 0000000000..c73f92661d Binary files /dev/null and b/x.tgz differ -- cgit v1.2.3-70-g09d2