Mark external as explicit only when installing explicitly (#31665)

This commit is contained in:
Harmen Stoppels 2022-07-22 15:20:17 +02:00 committed by GitHub
parent cfdfdf77e0
commit fce861d2ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -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 @@ def _add_tasks(self, request, all_deps):
#
# 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

View File

@ -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