Restore package-related unsigned binary changes from PR 11107 (#15134)

Restore package-related unsigned binary changes from PR 11107
This commit is contained in:
Tamara Dahlgren 2020-02-20 14:03:47 -08:00 committed by GitHub
parent 2e387ef585
commit a03b252522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -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 @@ def _install_task(self, task, **kwargs):
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 @@ def _install_task(self, task, **kwargs):
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

View File

@ -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 _spec(spec):
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]