diff options
-rw-r--r-- | lib/spack/spack/installer.py | 9 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/deprecate.py | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py index f1b33f1660..80fe9f2b03 100644 --- a/lib/spack/spack/installer.py +++ b/lib/spack/spack/installer.py @@ -2494,6 +2494,15 @@ def build_process(pkg: "spack.package_base.PackageBase", install_args: dict) -> def deprecate(spec: "spack.spec.Spec", deprecator: "spack.spec.Spec", link_fn) -> None: """Deprecate this package in favor of deprecator spec""" + # Here we assume we don't deprecate across different stores, and that same hash + # means same binary artifacts + if spec.dag_hash() == deprecator.dag_hash(): + return + + # We can't really have control over external specs, and cannot link anything in their place + if spec.external: + return + # Install deprecator if it isn't installed already if not spack.store.STORE.db.query(deprecator): PackageInstaller([deprecator.package], explicit=True).install() diff --git a/lib/spack/spack/test/cmd/deprecate.py b/lib/spack/spack/test/cmd/deprecate.py index 867b1cf2e1..3bb84fce7d 100644 --- a/lib/spack/spack/test/cmd/deprecate.py +++ b/lib/spack/spack/test/cmd/deprecate.py @@ -164,3 +164,30 @@ def test_concretize_deprecated(mock_packages, mock_archive, mock_fetch, install_ spec = spack.spec.Spec("libelf@0.8.10") with pytest.raises(spack.spec.SpecDeprecatedError): spec.concretize() + + +@pytest.mark.usefixtures("mock_packages", "mock_archive", "mock_fetch", "install_mockery") +@pytest.mark.regression("46915") +def test_deprecate_spec_with_external_dependency(mutable_config, temporary_store, tmp_path): + """Tests that we can deprecate a spec that has an external dependency""" + packages_yaml = { + "libelf": { + "buildable": False, + "externals": [{"spec": "libelf@0.8.13", "prefix": str(tmp_path / "libelf")}], + } + } + mutable_config.set("packages", packages_yaml) + + install("--fake", "dyninst ^libdwarf@=20111030") + install("--fake", "libdwarf@=20130729") + + # Ensure we are using the external libelf + db = temporary_store.db + libelf = db.query_one("libelf") + assert libelf.external + + deprecated_spec = db.query_one("libdwarf@=20111030") + new_libdwarf = db.query_one("libdwarf@=20130729") + deprecate("-y", "libdwarf@=20111030", "libdwarf@=20130729") + + assert db.deprecator(deprecated_spec) == new_libdwarf |