Skip to content

Commit 765049b

Browse files
authored
Fix issue with codesign not supporting bundles that have spaces (#2732)
1 parent 7ee3cc5 commit 765049b

File tree

4 files changed

+94
-6
lines changed

4 files changed

+94
-6
lines changed

apple/internal/codesigning_support.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,13 @@ def _post_process_and_sign_archive_action(
694694
output = process_and_sign_expanded_template,
695695
is_executable = True,
696696
substitutions = {
697-
"%ipa_post_processor%": ipa_post_processor_path or "",
698-
"%output_path%": output_archive.path,
697+
"%ipa_post_processor%": shell.quote(ipa_post_processor_path) or "",
698+
"%output_path%": shell.quote(output_archive.path),
699699
"%should_compress%": "1" if should_compress else "",
700700
"%should_verify%": "1", # always verify the crc
701701
"%signing_command_lines%": signing_command_lines,
702-
"%unprocessed_archive_path%": input_archive.path,
703-
"%work_dir%": output_archive_root_path,
702+
"%unprocessed_archive_path%": shell.quote(input_archive.path),
703+
"%work_dir%": shell.quote(output_archive_root_path),
704704
},
705705
)
706706

test/starlark_tests/ios_application_tests.bzl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,60 @@ Found "com.bazel.app.example" which does not match previously defined "com.altba
10351035
tags = [name],
10361036
)
10371037

1038+
archive_contents_test(
1039+
name = "{}_with_spaces_contents_test".format(name),
1040+
build_type = "simulator",
1041+
target_under_test = "//test/starlark_tests/targets_under_test/ios:app minimal has several spaces",
1042+
contains = [
1043+
"$BUNDLE_ROOT/Info.plist",
1044+
"$BUNDLE_ROOT/PkgInfo",
1045+
"$BUNDLE_ROOT/app minimal has several spaces",
1046+
],
1047+
tags = [name],
1048+
)
1049+
1050+
archive_contents_test(
1051+
name = "{}_tree_artifact_with_spaces_contents_test".format(name),
1052+
build_type = "simulator",
1053+
target_under_test = "//test/starlark_tests/targets_under_test/ios:app minimal has several spaces",
1054+
build_settings = {
1055+
build_settings_labels.use_tree_artifacts_outputs: "True",
1056+
},
1057+
contains = [
1058+
"$BUNDLE_ROOT/Info.plist",
1059+
"$BUNDLE_ROOT/PkgInfo",
1060+
"$BUNDLE_ROOT/app minimal has several spaces",
1061+
],
1062+
tags = [name],
1063+
)
1064+
1065+
archive_contents_test(
1066+
name = "{}_bundle_name_with_spaces_contents_test".format(name),
1067+
build_type = "simulator",
1068+
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_minimal_bundle_name_with_spaces",
1069+
contains = [
1070+
"$BUNDLE_ROOT/Info.plist",
1071+
"$BUNDLE_ROOT/PkgInfo",
1072+
"$BUNDLE_ROOT/app minimal bundle name has several spaces",
1073+
],
1074+
tags = [name],
1075+
)
1076+
1077+
archive_contents_test(
1078+
name = "{}_tree_artifact_bundle_name_with_spaces_contents_test".format(name),
1079+
build_type = "simulator",
1080+
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_minimal_bundle_name_with_spaces",
1081+
build_settings = {
1082+
build_settings_labels.use_tree_artifacts_outputs: "True",
1083+
},
1084+
contains = [
1085+
"$BUNDLE_ROOT/Info.plist",
1086+
"$BUNDLE_ROOT/PkgInfo",
1087+
"$BUNDLE_ROOT/app minimal bundle name has several spaces",
1088+
],
1089+
tags = [name],
1090+
)
1091+
10381092
native.test_suite(
10391093
name = name,
10401094
tags = [name],

test/starlark_tests/targets_under_test/ios/BUILD

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,37 @@ package(
7272
# notap to avoid them being built/tested when testing the //test/...
7373
# package.
7474

75+
ios_application(
76+
name = "app minimal has several spaces",
77+
bundle_id = "com.google.example",
78+
families = ["iphone"],
79+
infoplists = [
80+
"//test/starlark_tests/resources:Info.plist",
81+
],
82+
minimum_os_version = common.min_os_ios.baseline,
83+
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
84+
tags = common.fixture_tags,
85+
deps = [
86+
"//test/starlark_tests/resources:objc_main_lib",
87+
],
88+
)
89+
90+
ios_application(
91+
name = "app_minimal_bundle_name_with_spaces",
92+
bundle_id = "com.google.example",
93+
bundle_name = "app minimal bundle name has several spaces",
94+
families = ["iphone"],
95+
infoplists = [
96+
"//test/starlark_tests/resources:Info.plist",
97+
],
98+
minimum_os_version = common.min_os_ios.baseline,
99+
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
100+
tags = common.fixture_tags,
101+
deps = [
102+
"//test/starlark_tests/resources:objc_main_lib",
103+
],
104+
)
105+
75106
ios_application(
76107
name = "app_minimal",
77108
bundle_id = "com.google.example",

tools/bundletool/bundletool_experimental.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import filecmp
5151
import json
5252
import os
53+
import shlex
5354
import shutil
5455
import sys
5556
import zipfile
@@ -300,9 +301,11 @@ def _sign_bundle(self, bundle_root, command_lines):
300301
Args:
301302
bundle_root: The path to the bundle.
302303
command_lines: A newline-separated list of command lines that should be
303-
executed in the bundle to sign it.
304+
executed in the bundle to sign it.
304305
"""
305-
exit_code = os.system('WORK_DIR="%s"\n%s' % (bundle_root, command_lines))
306+
exit_code = os.system(
307+
'WORK_DIR=%s\n%s' % (shlex.quote(bundle_root), command_lines)
308+
)
306309
if exit_code:
307310
raise CodeSignError(exit_code)
308311

0 commit comments

Comments
 (0)