Created
November 26, 2024 14:02
-
-
Save paulgessinger/7ac6787afd630dbd4fd299140302fea9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f5635ce86b5cb83ee14727cd2dc71faee6046641 Mon Sep 17 00:00:00 2001 | |
From: Paul Gessinger <[email protected]> | |
Date: Tue, 26 Nov 2024 15:01:40 +0100 | |
Subject: [PATCH] apply install_name_tool to copy of file | |
--- | |
lib/spack/spack/relocate.py | 18 ++++++++++++++++-- | |
1 file changed, 16 insertions(+), 2 deletions(-) | |
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py | |
index 627c9e2b05..bfb0d2806b 100644 | |
--- a/lib/spack/spack/relocate.py | |
+++ b/lib/spack/spack/relocate.py | |
@@ -6,7 +6,9 @@ | |
import itertools | |
import os | |
import re | |
+import shutil | |
import sys | |
+import tempfile | |
from collections import OrderedDict | |
from typing import List, Optional | |
@@ -276,9 +278,21 @@ def modify_macho_object(cur_path, rpaths, deps, idpath, paths_to_paths): | |
# Deduplicate and flatten | |
args = list(itertools.chain.from_iterable(llnl.util.lang.dedupe(args))) | |
if args: | |
- args.append(str(cur_path)) | |
install_name_tool = executable.Executable("install_name_tool") | |
- install_name_tool(*args) | |
+ | |
+ tmp_fd, tmp_name = tempfile.mkstemp( | |
+ dir=os.path.dirname(cur_path), prefix=f"{os.path.basename(cur_path)}." | |
+ ) | |
+ try: | |
+ with open(cur_path, "rb") as f, os.fdopen(tmp_fd, "wb", closefd=False) as g: | |
+ shutil.copyfileobj(f, g) | |
+ args.append(tmp_name) | |
+ install_name_tool(*args) | |
+ with open(tmp_name, "rb") as g, open(cur_path, "wb") as f: | |
+ shutil.copyfileobj(g, f) | |
+ finally: | |
+ os.close(tmp_fd) | |
+ os.unlink(tmp_name) | |
def macholib_get_paths(cur_path): | |
-- | |
2.39.5 (Apple Git-154) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment