From fce861d2ace299f2e9444a011c631a583e025c26 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 22 Jul 2022 15:20:17 +0200 Subject: Mark external as explicit only when installing explicitly (#31665) --- lib/spack/spack/installer.py | 10 +++++----- lib/spack/spack/test/installer.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py index 6f6af97812..d4acc1dd16 100644 --- a/lib/spack/spack/installer.py +++ b/lib/spack/spack/installer.py @@ -330,11 +330,10 @@ def _process_external_package(pkg, explicit): try: # Check if the package was already registered in the DB. - # If this is the case, then just exit. + # If this is the case, then only make explicit if required. tty.debug('{0} already registered in DB'.format(pre)) - - # Update the explicit state if it is necessary - if explicit: + record = spack.store.db.get_record(spec) + if explicit and not record.explicit: spack.store.db.update_explicit(spec, explicit) except KeyError: @@ -1115,7 +1114,8 @@ class PackageInstaller(object): # # External and upstream packages need to get flagged as installed to # ensure proper status tracking for environment build. - not_local = _handle_external_and_upstream(request.pkg, True) + explicit = request.install_args.get('explicit', True) + not_local = _handle_external_and_upstream(request.pkg, explicit) if not_local: self._flag_installed(request.pkg) return diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py index 8a36978cab..3d8b53e2eb 100644 --- a/lib/spack/spack/test/installer.py +++ b/lib/spack/spack/test/installer.py @@ -1289,3 +1289,16 @@ def test_term_status_line(): x.add("a") x.add("b") x.clear() + + +@pytest.mark.parametrize('explicit_args,is_explicit', [ + ({'explicit': False}, False), + ({'explicit': True}, True), + ({}, True) +]) +def test_single_external_implicit_install(install_mockery, explicit_args, is_explicit): + pkg = 'trivial-install-test-package' + s = spack.spec.Spec(pkg).concretized() + s.external_path = '/usr' + create_installer([(s, explicit_args)]).install() + assert spack.store.db.get_record(pkg).explicit == is_explicit -- cgit v1.2.3-60-g2f50