Skip to content

Commit a8ac18a

Browse files
committed
fix permission handling
1 parent 7ea3ded commit a8ac18a

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

tools/bundletool/bundletool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ def _entry_is_executable(self, src, dest, executable,
257257
if not normalize_bundle_file_permissions:
258258
return os.access(src, os.X_OK)
259259

260-
if dest.endswith('/Info.plist') or '/Resources/' in dest:
261-
return False
262260
if '/Contents/MacOS/' in dest:
263261
return True
264262
if dest.endswith('.dylib'):
265263
return True
266264
if '.framework/' in dest:
267265
framework_name = dest.split('.framework/', 1)[0].rsplit('/', 1)[-1]
268266
return os.path.basename(dest) == framework_name
267+
if dest.endswith('/Info.plist') or '/Resources/' in dest:
268+
return False
269269
return os.access(src, os.X_OK)
270270

271271
def _add_zip_contents(self, src, dest, out_zip, compress):

tools/bundletool/bundletool_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,39 @@ def test_bundle_merge_files_normalizes_bundle_permissions(self):
329329
'app.app/Contents/Frameworks/Foo.framework/Versions/A/Foo',
330330
True)
331331

332+
def test_bundle_merge_files_normalizes_nested_bundle_permissions_in_resources(self):
333+
os.makedirs(os.path.join(
334+
self._scratch_dir,
335+
'app.app',
336+
'Contents',
337+
'Resources',
338+
'Helper.app',
339+
'Contents',
340+
'MacOS'))
341+
self._scratch_file(
342+
'app.app/Contents/Resources/Helper.app/Contents/Info.plist',
343+
executable=True)
344+
self._scratch_file(
345+
'app.app/Contents/Resources/Helper.app/Contents/MacOS/Helper',
346+
executable=True)
347+
348+
out_zip = _run_bundler({
349+
'bundle_merge_files': [{
350+
'src': os.path.join(self._scratch_dir, 'app.app'),
351+
'dest': 'app.app',
352+
'normalize_bundle_file_permissions': True,
353+
}],
354+
})
355+
with zipfile.ZipFile(out_zip, 'r') as z:
356+
self._assert_zip_contains(
357+
z,
358+
'app.app/Contents/Resources/Helper.app/Contents/Info.plist',
359+
False)
360+
self._assert_zip_contains(
361+
z,
362+
'app.app/Contents/Resources/Helper.app/Contents/MacOS/Helper',
363+
True)
364+
332365
def test_bundle_merge_zips(self):
333366
foo_zip = self._scratch_zip('foo.zip',
334367
'foo.bundle/img.png', 'foo.bundle/strings.txt')

0 commit comments

Comments
 (0)