From 4487a6efb2545699b1dd06c2cedd8afc8663947b Mon Sep 17 00:00:00 2001
From: AlQuemist <alquemist@Lyriks>
Date: Tue, 10 Oct 2023 11:48:07 +0200
Subject: [PATCH] mac_package: capture errors resulting from subprocesses

---
 devtools/deploy/mac/mac_package.py.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/devtools/deploy/mac/mac_package.py.in b/devtools/deploy/mac/mac_package.py.in
index 8ced5d6df28..7c7325b7d4b 100644
--- a/devtools/deploy/mac/mac_package.py.in
+++ b/devtools/deploy/mac/mac_package.py.in
@@ -800,23 +800,30 @@ print("\n%s: Add proper RPATHs to the binaries..." % TITLE)
 for lib in (l for l in pkg.dst_tbl.values() if l.rpaths):
     # eg. RPATHS for 'lib/libA.dylib': ../Library , ../Frameworks/Qt
     # eg. install_name_tool libA.so -add_rpath RPATH1 -add_rpath RPATH2 ...
-    _cmd_list = ["install_name_tool", lib.dst]
+    _cmd_list = []
     for cmd in (["-add_rpath", r] for r in lib.rpaths):
         _cmd_list.extend(cmd)
     # execute the command
-    subp.check_output(_cmd_list)
+    if not _cmd_list: continue
+    _prc = subp.run(["install_name_tool", lib.dst, *_cmd_list])
+    if _prc.returncode != 0:
+        print("%s: Command failed: %s" % (TITLE, _prc.args))
 
 # modify the library references;
 # eg. '/usr/local/opt/foo.dylib' => '@rpath/foo.dylib'
 print("\n%s: Change library references in binaries..." % TITLE)
 for lib in (l for l in pkg.dst_tbl.values() if l.dependencies):
     # eg. install_name_tool libA.so -change REF1_old REF1_new -change REF2_old REF2_new ...
-    _cmd_list = ["install_name_tool", lib.dst]
+    _cmd_list = []
     for ref_old in lib.dependencies:
         ref_new = pkg.ref_tbl[ref_old]
         if ref_old != ref_new: _cmd_list.extend(["-change", ref_old,ref_new])
     # execute the command
-    subp.check_output(_cmd_list)
+    if not _cmd_list: continue
+    _prc = subp.run(["install_name_tool", lib.dst, *_cmd_list])
+    if _prc.returncode != 0:
+        print("%s: Command failed: %s" % (TITLE, _prc.args))
+
 
 #-- END
 print("\n%s: Done.\n" % TITLE)
-- 
GitLab