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.
This commit is contained in:
parent
d51deb4961
commit
ab018c2081
@ -7,6 +7,8 @@
|
||||
|
||||
"""
|
||||
|
||||
import getpass
|
||||
import shutil
|
||||
from sys import platform
|
||||
from os.path import basename, dirname, isdir
|
||||
|
||||
@ -47,6 +49,22 @@ def install(self, spec, prefix, installer_path=None):
|
||||
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 @@ def install(self, spec, prefix, installer_path=None):
|
||||
'--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')
|
||||
|
Loading…
Reference in New Issue
Block a user