summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2020-02-20 14:03:47 -0800
committerGitHub <noreply@github.com>2020-02-20 14:03:47 -0800
commita03b252522565f3dc226b6b4d8a97d711d961da4 (patch)
tree731b582c5eab06410edfae9655f26f1edefab86a /lib
parent2e387ef5855d533f685478cc15e3d9bea799bf30 (diff)
downloadspack-a03b252522565f3dc226b6b4d8a97d711d961da4.tar.gz
spack-a03b252522565f3dc226b6b4d8a97d711d961da4.tar.bz2
spack-a03b252522565f3dc226b6b4d8a97d711d961da4.tar.xz
spack-a03b252522565f3dc226b6b4d8a97d711d961da4.zip
Restore package-related unsigned binary changes from PR 11107 (#15134)
Restore package-related unsigned binary changes from PR 11107
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/spack/installer.py23
-rw-r--r--lib/spack/spack/test/installer.py10
2 files changed, 21 insertions, 12 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 9b340b951d..6d50b0f15d 100755
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -211,7 +211,7 @@ def _hms(seconds):
return ' '.join(parts)
-def _install_from_cache(pkg, cache_only, explicit):
+def _install_from_cache(pkg, cache_only, explicit, unsigned=False):
"""
Install the package from binary cache
@@ -220,12 +220,15 @@ def _install_from_cache(pkg, cache_only, explicit):
cache_only (bool): only install from binary cache
explicit (bool): ``True`` if installing the package was explicitly
requested by the user, otherwise, ``False``
+ unsigned (bool): ``True`` if binary package signatures to be checked,
+ otherwise, ``False``
Return:
(bool) ``True`` if the package was installed from binary cache,
``False`` otherwise
"""
- installed_from_cache = _try_install_from_binary_cache(pkg, explicit)
+ installed_from_cache = _try_install_from_binary_cache(pkg, explicit,
+ unsigned)
pkg_id = package_id(pkg)
if not installed_from_cache:
pre = 'No binary for {0} found'.format(pkg_id)
@@ -298,7 +301,7 @@ def _process_external_package(pkg, explicit):
spack.store.db.add(spec, None, explicit=explicit)
-def _process_binary_cache_tarball(pkg, binary_spec, explicit):
+def _process_binary_cache_tarball(pkg, binary_spec, explicit, unsigned):
"""
Process the binary cache tarball.
@@ -306,6 +309,8 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit):
pkg (PackageBase): the package being installed
binary_spec (Spec): the spec whose cache has been confirmed
explicit (bool): the package was explicitly requested by the user
+ unsigned (bool): ``True`` if binary package signatures to be checked,
+ otherwise, ``False``
Return:
(bool) ``True`` if the package was installed from binary cache,
@@ -321,19 +326,21 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit):
pkg_id = package_id(pkg)
tty.msg('Installing {0} from binary cache'.format(pkg_id))
binary_distribution.extract_tarball(binary_spec, tarball, allow_root=False,
- unsigned=False, force=False)
+ unsigned=unsigned, force=False)
pkg.installed_from_binary_cache = True
spack.store.db.add(pkg.spec, spack.store.layout, explicit=explicit)
return True
-def _try_install_from_binary_cache(pkg, explicit):
+def _try_install_from_binary_cache(pkg, explicit, unsigned=False):
"""
Try to install the package from binary cache.
Args:
pkg (PackageBase): the package to be installed from binary cache
explicit (bool): the package was explicitly requested by the user
+ unsigned (bool): ``True`` if binary package signatures to be checked,
+ otherwise, ``False``
"""
pkg_id = package_id(pkg)
tty.debug('Searching for binary cache of {0}'.format(pkg_id))
@@ -343,7 +350,7 @@ def _try_install_from_binary_cache(pkg, explicit):
if binary_spec not in specs:
return False
- return _process_binary_cache_tarball(pkg, binary_spec, explicit)
+ return _process_binary_cache_tarball(pkg, binary_spec, explicit, unsigned)
def _update_explicit_entry_in_db(pkg, rec, explicit):
@@ -936,6 +943,7 @@ class PackageInstaller(object):
keep_stage = kwargs.get('keep_stage', False)
skip_patch = kwargs.get('skip_patch', False)
tests = kwargs.get('tests', False)
+ unsigned = kwargs.get('unsigned', False)
use_cache = kwargs.get('use_cache', True)
verbose = kwargs.get('verbose', False)
@@ -948,7 +956,8 @@ class PackageInstaller(object):
task.status = STATUS_INSTALLING
# Use the binary cache if requested
- if use_cache and _install_from_cache(pkg, cache_only, explicit):
+ if use_cache and \
+ _install_from_cache(pkg, cache_only, explicit, unsigned):
self._update_installed(task)
return
diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py
index 02d10fce41..7d2eec8caf 100644
--- a/lib/spack/spack/test/installer.py
+++ b/lib/spack/spack/test/installer.py
@@ -87,7 +87,7 @@ def test_install_from_cache_errors(install_mockery, capsys):
# Check with cache-only
with pytest.raises(SystemExit):
- inst._install_from_cache(spec.package, True, True)
+ inst._install_from_cache(spec.package, True, True, False)
captured = str(capsys.readouterr())
assert 'No binary' in captured
@@ -95,7 +95,7 @@ def test_install_from_cache_errors(install_mockery, capsys):
assert not spec.package.installed_from_binary_cache
# Check when don't expect to install only from binary cache
- assert not inst._install_from_cache(spec.package, False, True)
+ assert not inst._install_from_cache(spec.package, False, True, False)
assert not spec.package.installed_from_binary_cache
@@ -106,7 +106,7 @@ def test_install_from_cache_ok(install_mockery, monkeypatch):
monkeypatch.setattr(inst, '_try_install_from_binary_cache', _true)
monkeypatch.setattr(spack.hooks, 'post_install', _noop)
- assert inst._install_from_cache(spec.package, True, True)
+ assert inst._install_from_cache(spec.package, True, True, False)
def test_process_external_package_module(install_mockery, monkeypatch, capfd):
@@ -133,7 +133,7 @@ def test_process_binary_cache_tarball_none(install_mockery, monkeypatch,
monkeypatch.setattr(spack.binary_distribution, 'download_tarball', _none)
pkg = spack.repo.get('trivial-install-test-package')
- assert not inst._process_binary_cache_tarball(pkg, None, False)
+ assert not inst._process_binary_cache_tarball(pkg, None, False, False)
assert 'exists in binary cache but' in capfd.readouterr()[0]
@@ -151,7 +151,7 @@ def test_process_binary_cache_tarball_tar(install_mockery, monkeypatch, capfd):
monkeypatch.setattr(spack.database.Database, 'add', _noop)
spec = spack.spec.Spec('a').concretized()
- assert inst._process_binary_cache_tarball(spec.package, spec, False)
+ assert inst._process_binary_cache_tarball(spec.package, spec, False, False)
assert 'Installing a from binary cache' in capfd.readouterr()[0]