Skip to content

Commit 77e45c2

Browse files
committed
update: enhance macOS signing process to handle Linux platform and streamline xattr removal
1 parent 6c8ede9 commit 77e45c2

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

.github/patches/upstream/tools-signing-macos-mach_commands.py.patch

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/tools/signing/macos/mach_commands.py b/tools/signing/macos/mach_commands.py
2-
index 721790b0d0..e615461d11 100644
2+
index 4227363da7..4872c1d592 100644
33
--- a/tools/signing/macos/mach_commands.py
44
+++ b/tools/signing/macos/mach_commands.py
55
@@ -10,6 +10,8 @@ import plistlib
@@ -11,7 +11,7 @@ index 721790b0d0..e615461d11 100644
1111

1212
import yaml
1313
from mach.decorators import (
14-
@@ -154,6 +156,17 @@ def macos_sign(
14+
@@ -153,6 +155,17 @@ def macos_sign(
1515
"""
1616
command_context._set_log_level(verbose_arg)
1717

@@ -29,26 +29,29 @@ index 721790b0d0..e615461d11 100644
2929
# Check appdir and remove trailing slasshes
3030
if not os.path.isdir(app_arg):
3131
command_context.log(
32-
@@ -323,24 +336,30 @@ def macos_sign(
32+
@@ -321,27 +334,25 @@ def macos_sign(
3333
"by-hardened-signing-type"
3434
][entitlements_key]
3535

3636
- command_context.log(
3737
- logging.INFO, "macos-sign", {}, "Stripping existing xattrs and signatures"
3838
- )
39+
-
40+
- # Remove extended attributes. Per Apple "Technical Note TN2206",
41+
- # code signing uses extended attributes to store signatures for
42+
- # non-Mach-O executables such as script files. We want to avoid
43+
- # any complications that might be caused by existing extended
44+
- # attributes.
45+
- # Bug 2005439: xattr -r is not valid on linux
46+
- xattr_cmd = (
47+
- ["xattr", "-c", app] if sys.platform == "linux" else ["xattr", "-cr", app]
48+
- )
49+
- run(command_context, xattr_cmd, capture_output=not verbose_arg)
3950
+ if current_platform == "Darwin" and use_rcodesign_arg is False:
4051
+ command_context.log(
4152
+ logging.INFO, "macos-sign", {}, "Stripping existing xattrs and signatures"
4253
+ )
4354

44-
# Remove extended attributes. Per Apple "Technical Note TN2206",
45-
# code signing uses extended attributes to store signatures for
46-
# non-Mach-O executables such as script files. We want to avoid
47-
# any complications that might be caused by existing extended
48-
# attributes.
49-
- xattr_cmd = ["xattr", "-cr", app]
50-
- run(command_context, xattr_cmd, capture_output=not verbose_arg)
51-
-
5255
- # Remove existing signatures. The codesign command only replaces
5356
- # signatures if the --force option used. Remove all signatures so
5457
- # subsequent signing commands with different options will result
@@ -72,7 +75,7 @@ index 721790b0d0..e615461d11 100644
7275

7376
if use_rcodesign_arg is True:
7477
sign_with_rcodesign(
75-
@@ -366,7 +385,11 @@ def macos_sign(
78+
@@ -367,7 +378,11 @@ def macos_sign(
7679
app,
7780
)
7881

@@ -85,7 +88,7 @@ index 721790b0d0..e615461d11 100644
8588

8689

8790
def entitlement_repo_path(entitlements_key, entitlement_file):
88-
@@ -717,3 +740,143 @@ def strip_restricted_entitlements(plist_file):
91+
@@ -723,3 +738,143 @@ def strip_restricted_entitlements(plist_file):
8992
temp_file_obj.close()
9093

9194
return temp_file_path

0 commit comments

Comments
 (0)