Relocate "run" type dependencies too (#33191)

When downloading from binary cache not only replace RPATHs to dependencies, but
also text references to dependencies.

Example:
`autoconf@2.69` contains a text reference to the executable of its dependency
`perl`:

```
$ grep perl-5 /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/autoconf-2.69-q3lo/bin/autoreconf
eval 'case $# in 0) exec /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/perl-5.34.1-yphg/bin/perl -S "$0";; *) exec /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/perl-5.34.1-yphg/bin/perl -S "$0" "$@";; esac'
```

These references need to be replace or any package using `autoreconf` will fail
as it cannot find the installed `perl`.

Co-authored-by: Stephen Sachs <stesachs@amazon.com>
This commit is contained in:
Stephen Sachs 2022-10-19 17:37:07 +02:00 committed by GitHub
parent a423dc646a
commit 25cbb34579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -721,7 +721,7 @@ def write_buildinfo_file(spec, workdir, rel=False):
prefix_to_hash = dict() prefix_to_hash = dict()
prefix_to_hash[str(spec.package.prefix)] = spec.dag_hash() prefix_to_hash[str(spec.package.prefix)] = spec.dag_hash()
deps = spack.build_environment.get_rpath_deps(spec.package) deps = spack.build_environment.get_rpath_deps(spec.package)
for d in deps: for d in deps + spec.dependencies(deptype="run"):
prefix_to_hash[str(d.prefix)] = d.dag_hash() prefix_to_hash[str(d.prefix)] = d.dag_hash()
# Create buildinfo data and write it to disk # Create buildinfo data and write it to disk
@ -1474,7 +1474,7 @@ def relocate_package(spec, allow_root):
hash_to_prefix = dict() hash_to_prefix = dict()
hash_to_prefix[spec.format("{hash}")] = str(spec.package.prefix) hash_to_prefix[spec.format("{hash}")] = str(spec.package.prefix)
new_deps = spack.build_environment.get_rpath_deps(spec.package) new_deps = spack.build_environment.get_rpath_deps(spec.package)
for d in new_deps: for d in new_deps + spec.dependencies(deptype="run"):
hash_to_prefix[d.format("{hash}")] = str(d.prefix) hash_to_prefix[d.format("{hash}")] = str(d.prefix)
# Spurious replacements (e.g. sbang) will cause issues with binaries # Spurious replacements (e.g. sbang) will cause issues with binaries
# For example, the new sbang can be longer than the old one. # For example, the new sbang can be longer than the old one.