Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: build/config/mac/write_pkg_info.py

Issue 2055933002: [Mac/GN] Write PkgInfo files for .app bundles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/config/mac/rules.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import argparse
6 import os
7 import plistlib
8 import sys
9
10 # This script creates a PkgInfo file for an OS X .app bundle's plist.
11 # Usage: python write_pkg_info.py --plist Foo.app/Contents/Info.plist \
12 # --output Foo.app/Contents/PkgInfo
13
14 def Main():
15 parser = argparse.ArgumentParser(
16 description='A script to write PkgInfo files for .app bundles.')
17 parser.add_argument('--plist', required=True,
18 help='Path to the Info.plist for the .app.')
19 parser.add_argument('--output', required=True,
20 help='Path to the desired output file.')
21 args = parser.parse_args()
22
23 # Remove the output if it exists already.
24 if os.path.exists(args.output):
25 os.unlink(args.output)
26
27 plist = plistlib.readPlist(args.plist)
28 package_type = plist['CFBundlePackageType']
29 if package_type != 'APPL':
30 raise ValueError('Expected CFBundlePackageType to be %s, got %s' % \
31 ('AAPL', package_type))
32
33 # The format of PkgInfo is eight characters, representing the bundle type
34 # and bundle signature, each four characters. If that is missing, four
35 # '?' characters are used instead.
36 signature_code = plist.get('CFBundleSignature', '????')
37 if len(signature_code) != 4:
38 raise ValueError('CFBundleSignature should be exactly four characters, ' +
39 'got %s' % signature_code)
40
41 with open(args.output, 'w') as fp:
42 fp.write('%s%s' % (package_type, signature_code))
43 return 0
44
45
46 if __name__ == '__main__':
47 sys.exit(Main())
OLDNEW
« no previous file with comments | « build/config/mac/rules.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698