|
3 | 3 | # SPDX-License-Identifier: (Apache-2.0 OR MIT) |
4 | 4 |
|
5 | 5 | import os |
6 | | -import shutil |
7 | 6 | import tempfile |
8 | 7 |
|
9 | 8 | import spack.binary_distribution as bindist |
10 | | -import spack.deptypes as dt |
11 | 9 | import spack.error |
12 | 10 | import spack.hooks |
13 | | -import spack.platforms |
14 | | -import spack.relocate as relocate |
15 | 11 | import spack.store |
16 | 12 |
|
17 | 13 |
|
@@ -42,63 +38,11 @@ def rewire_node(spec, explicit): |
42 | 38 |
|
43 | 39 | spack.hooks.pre_install(spec) |
44 | 40 | bindist.extract_buildcache_tarball(tarball, destination=spec.prefix) |
45 | | - buildinfo = bindist.read_buildinfo_file(spec.prefix) |
| 41 | + bindist.relocate_package(spec) |
46 | 42 |
|
47 | | - # compute prefix-to-prefix for every node from the build spec to the spliced |
48 | | - # spec |
49 | | - prefix_to_prefix = {spec.build_spec.prefix: spec.prefix} |
50 | | - build_spec_ids = set(id(s) for s in spec.build_spec.traverse(deptype=dt.ALL & ~dt.BUILD)) |
51 | | - for s in bindist.specs_to_relocate(spec): |
52 | | - analog = s |
53 | | - if id(s) not in build_spec_ids: |
54 | | - analogs = [ |
55 | | - d |
56 | | - for d in spec.build_spec.traverse(deptype=dt.ALL & ~dt.BUILD) |
57 | | - if s._splice_match(d, self_root=spec, other_root=spec.build_spec) |
58 | | - ] |
59 | | - if analogs: |
60 | | - # Prefer same-name analogs and prefer higher versions |
61 | | - # This matches the preferences in Spec.splice, so we will find same node |
62 | | - analog = max(analogs, key=lambda a: (a.name == s.name, a.version)) |
63 | | - |
64 | | - prefix_to_prefix[analog.prefix] = s.prefix |
65 | | - |
66 | | - platform = spack.platforms.by_name(spec.platform) |
67 | | - |
68 | | - text_to_relocate = [ |
69 | | - os.path.join(spec.prefix, rel_path) for rel_path in buildinfo["relocate_textfiles"] |
70 | | - ] |
71 | | - if text_to_relocate: |
72 | | - relocate.relocate_text(files=text_to_relocate, prefix_to_prefix=prefix_to_prefix) |
73 | | - links = [os.path.join(spec.prefix, f) for f in buildinfo["relocate_links"]] |
74 | | - relocate.relocate_links(links, prefix_to_prefix) |
75 | | - bins_to_relocate = [ |
76 | | - os.path.join(spec.prefix, rel_path) for rel_path in buildinfo["relocate_binaries"] |
77 | | - ] |
78 | | - if bins_to_relocate: |
79 | | - if "macho" in platform.binary_formats: |
80 | | - relocate.relocate_macho_binaries(bins_to_relocate, prefix_to_prefix) |
81 | | - if "elf" in platform.binary_formats: |
82 | | - relocate.relocate_elf_binaries(bins_to_relocate, prefix_to_prefix) |
83 | | - relocate.relocate_text_bin(binaries=bins_to_relocate, prefix_to_prefix=prefix_to_prefix) |
84 | | - shutil.rmtree(tempdir) |
85 | | - install_manifest = os.path.join( |
86 | | - spec.prefix, |
87 | | - spack.store.STORE.layout.metadata_dir, |
88 | | - spack.store.STORE.layout.manifest_file_name, |
89 | | - ) |
90 | | - try: |
91 | | - os.unlink(install_manifest) |
92 | | - except FileNotFoundError: |
93 | | - pass |
94 | | - # Write the spliced spec into spec.json. Without this, Database.add would fail because it |
95 | | - # checks the spec.json in the prefix against the spec being added to look for mismatches |
96 | | - spack.store.STORE.layout.write_spec(spec, spack.store.STORE.layout.spec_file_path(spec)) |
97 | | - # add to database, not sure about explicit |
98 | | - spack.store.STORE.db.add(spec, explicit=explicit) |
99 | | - |
100 | | - # run post install hooks |
| 43 | + # run post install hooks and add to db |
101 | 44 | spack.hooks.post_install(spec, explicit) |
| 45 | + spack.store.STORE.db.add(spec, explicit=explicit) |
102 | 46 |
|
103 | 47 |
|
104 | 48 | class RewireError(spack.error.SpackError): |
|
0 commit comments