summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-07-22 15:20:17 +0200
committerGitHub <noreply@github.com>2022-07-22 15:20:17 +0200
commitfce861d2ace299f2e9444a011c631a583e025c26 (patch)
tree9aba9c333a3928fd79878a26716dfc60455b0fcb /lib
parentcfdfdf77e0e3c049d3611ec1c173f2f373d29bd1 (diff)
downloadspack-fce861d2ace299f2e9444a011c631a583e025c26.tar.gz
spack-fce861d2ace299f2e9444a011c631a583e025c26.tar.bz2
spack-fce861d2ace299f2e9444a011c631a583e025c26.tar.xz
spack-fce861d2ace299f2e9444a011c631a583e025c26.zip
Mark external as explicit only when installing explicitly (#31665)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/installer.py10
-rw-r--r--lib/spack/spack/test/installer.py13
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