Skip to content
Snippets Groups Projects
Unverified Commit a03b2525 authored by Tamara Dahlgren's avatar Tamara Dahlgren Committed by GitHub
Browse files

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

Restore package-related unsigned binary changes from PR 11107
parent 2e387ef5
No related branches found
No related tags found
No related merge requests found
...@@ -211,7 +211,7 @@ def _hms(seconds): ...@@ -211,7 +211,7 @@ def _hms(seconds):
return ' '.join(parts) 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 Install the package from binary cache
...@@ -220,12 +220,15 @@ def _install_from_cache(pkg, cache_only, explicit): ...@@ -220,12 +220,15 @@ def _install_from_cache(pkg, cache_only, explicit):
cache_only (bool): only install from binary cache cache_only (bool): only install from binary cache
explicit (bool): ``True`` if installing the package was explicitly explicit (bool): ``True`` if installing the package was explicitly
requested by the user, otherwise, ``False`` requested by the user, otherwise, ``False``
unsigned (bool): ``True`` if binary package signatures to be checked,
otherwise, ``False``
Return: Return:
(bool) ``True`` if the package was installed from binary cache, (bool) ``True`` if the package was installed from binary cache,
``False`` otherwise ``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) pkg_id = package_id(pkg)
if not installed_from_cache: if not installed_from_cache:
pre = 'No binary for {0} found'.format(pkg_id) pre = 'No binary for {0} found'.format(pkg_id)
...@@ -298,7 +301,7 @@ def _process_external_package(pkg, explicit): ...@@ -298,7 +301,7 @@ def _process_external_package(pkg, explicit):
spack.store.db.add(spec, None, explicit=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. Process the binary cache tarball.
...@@ -306,6 +309,8 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit): ...@@ -306,6 +309,8 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit):
pkg (PackageBase): the package being installed pkg (PackageBase): the package being installed
binary_spec (Spec): the spec whose cache has been confirmed binary_spec (Spec): the spec whose cache has been confirmed
explicit (bool): the package was explicitly requested by the user explicit (bool): the package was explicitly requested by the user
unsigned (bool): ``True`` if binary package signatures to be checked,
otherwise, ``False``
Return: Return:
(bool) ``True`` if the package was installed from binary cache, (bool) ``True`` if the package was installed from binary cache,
...@@ -321,19 +326,21 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit): ...@@ -321,19 +326,21 @@ def _process_binary_cache_tarball(pkg, binary_spec, explicit):
pkg_id = package_id(pkg) pkg_id = package_id(pkg)
tty.msg('Installing {0} from binary cache'.format(pkg_id)) tty.msg('Installing {0} from binary cache'.format(pkg_id))
binary_distribution.extract_tarball(binary_spec, tarball, allow_root=False, binary_distribution.extract_tarball(binary_spec, tarball, allow_root=False,
unsigned=False, force=False) unsigned=unsigned, force=False)
pkg.installed_from_binary_cache = True pkg.installed_from_binary_cache = True
spack.store.db.add(pkg.spec, spack.store.layout, explicit=explicit) spack.store.db.add(pkg.spec, spack.store.layout, explicit=explicit)
return True 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. Try to install the package from binary cache.
Args: Args:
pkg (PackageBase): the package to be installed from binary cache pkg (PackageBase): the package to be installed from binary cache
explicit (bool): the package was explicitly requested by the user 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) pkg_id = package_id(pkg)
tty.debug('Searching for binary cache of {0}'.format(pkg_id)) tty.debug('Searching for binary cache of {0}'.format(pkg_id))
...@@ -343,7 +350,7 @@ def _try_install_from_binary_cache(pkg, explicit): ...@@ -343,7 +350,7 @@ def _try_install_from_binary_cache(pkg, explicit):
if binary_spec not in specs: if binary_spec not in specs:
return False 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): def _update_explicit_entry_in_db(pkg, rec, explicit):
...@@ -936,6 +943,7 @@ def _install_task(self, task, **kwargs): ...@@ -936,6 +943,7 @@ def _install_task(self, task, **kwargs):
keep_stage = kwargs.get('keep_stage', False) keep_stage = kwargs.get('keep_stage', False)
skip_patch = kwargs.get('skip_patch', False) skip_patch = kwargs.get('skip_patch', False)
tests = kwargs.get('tests', False) tests = kwargs.get('tests', False)
unsigned = kwargs.get('unsigned', False)
use_cache = kwargs.get('use_cache', True) use_cache = kwargs.get('use_cache', True)
verbose = kwargs.get('verbose', False) verbose = kwargs.get('verbose', False)
...@@ -948,7 +956,8 @@ def _install_task(self, task, **kwargs): ...@@ -948,7 +956,8 @@ def _install_task(self, task, **kwargs):
task.status = STATUS_INSTALLING task.status = STATUS_INSTALLING
# Use the binary cache if requested # 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) self._update_installed(task)
return return
......
...@@ -87,7 +87,7 @@ def test_install_from_cache_errors(install_mockery, capsys): ...@@ -87,7 +87,7 @@ def test_install_from_cache_errors(install_mockery, capsys):
# Check with cache-only # Check with cache-only
with pytest.raises(SystemExit): 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()) captured = str(capsys.readouterr())
assert 'No binary' in captured assert 'No binary' in captured
...@@ -95,7 +95,7 @@ def test_install_from_cache_errors(install_mockery, capsys): ...@@ -95,7 +95,7 @@ def test_install_from_cache_errors(install_mockery, capsys):
assert not spec.package.installed_from_binary_cache assert not spec.package.installed_from_binary_cache
# Check when don't expect to install only 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 assert not spec.package.installed_from_binary_cache
...@@ -106,7 +106,7 @@ def test_install_from_cache_ok(install_mockery, monkeypatch): ...@@ -106,7 +106,7 @@ def test_install_from_cache_ok(install_mockery, monkeypatch):
monkeypatch.setattr(inst, '_try_install_from_binary_cache', _true) monkeypatch.setattr(inst, '_try_install_from_binary_cache', _true)
monkeypatch.setattr(spack.hooks, 'post_install', _noop) 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): def test_process_external_package_module(install_mockery, monkeypatch, capfd):
...@@ -133,7 +133,7 @@ def test_process_binary_cache_tarball_none(install_mockery, monkeypatch, ...@@ -133,7 +133,7 @@ def test_process_binary_cache_tarball_none(install_mockery, monkeypatch,
monkeypatch.setattr(spack.binary_distribution, 'download_tarball', _none) monkeypatch.setattr(spack.binary_distribution, 'download_tarball', _none)
pkg = spack.repo.get('trivial-install-test-package') 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] assert 'exists in binary cache but' in capfd.readouterr()[0]
...@@ -151,7 +151,7 @@ def _spec(spec): ...@@ -151,7 +151,7 @@ def _spec(spec):
monkeypatch.setattr(spack.database.Database, 'add', _noop) monkeypatch.setattr(spack.database.Database, 'add', _noop)
spec = spack.spec.Spec('a').concretized() 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] assert 'Installing a from binary cache' in capfd.readouterr()[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment