@@ -83,9 +83,9 @@ def read_config(args):
83
83
config = ConfigParser .SafeConfigParser ()
84
84
config .optionxform = str # set to str to prevent transforming into lower cases
85
85
config .read (args .config_file )
86
- check_options (config , 'Sign' , ['ApplicationIdentity' , 'ParentEntitlements' , 'ChildEntitlements' ], 'Missed options in [%s]: %s' )
86
+ check_options (config , 'Sign' , ['ApplicationIdentity' ], 'Missed options in [%s]: %s' )
87
87
if args .pkg :
88
- check_options (config , 'Sign ' , ['InstallerIdentity' ], 'Missed options for --pkg in [%s]: %s' )
88
+ check_options (config , 'Package ' , ['InstallerIdentity' ], 'Missed options for --pkg in [%s]: %s' )
89
89
return config
90
90
91
91
def copy_to_output (args ):
@@ -161,36 +161,52 @@ def codesign_app(config, args):
161
161
bundleid = get_bundle_id (args )
162
162
163
163
identity = config .get ('Sign' , 'ApplicationIdentity' )
164
- parent = config .get ('Sign' , 'ParentEntitlements' )
165
- child = config .get ('Sign' , 'ChildEntitlements' )
164
+ sandbox = True
165
+ if config .has_option ('Sign' , 'Sandbox' ):
166
+ sandbox = config .getboolean ('Sign' , 'Sandbox' )
166
167
167
- ( _ , tmp_parent_entitlements ) = tempfile . mkstemp ()
168
- parent_entitlements = plistlib . readPlist ( parent )
169
- teamid = get_from_info_plist ( args , 'NWTeamID ' , default = None )
170
- if teamid is None :
171
- groupid = bundleid
168
+ ## sign child frameworks and helpers
169
+ ( _ , tmp_child_entitlements ) = tempfile . mkstemp ( )
170
+ if config . has_option ( 'Sign ' , 'ChildEntitlements' ):
171
+ child = config . get ( 'Sign' , 'ChildEntitlements' )
172
+ child_entitlements = plistlib . readPlist ( child )
172
173
else :
173
- groupid = '%s.%s' % (teamid , bundleid )
174
+ child_entitlements = {
175
+ 'com.apple.security.app-sandbox' : sandbox ,
176
+ 'com.apple.security.inherit' : True
177
+ }
174
178
175
- (_ , tmp_child_entitlements ) = tempfile .mkstemp ()
176
- child_entitlements = plistlib .readPlist (child )
177
179
plistlib .writePlist (child_entitlements , tmp_child_entitlements )
178
180
info ('Child entitlements: %s' % tmp_child_entitlements )
179
181
framework = glob (args .output , 'nwjs Framework.framework' , returnOnFound = True )
180
182
system ('codesign -f --verbose -s "%s" --entitlements %s --deep "%s"' % (identity , tmp_child_entitlements , framework ))
181
183
helperApp = glob (args .output , 'nwjs Helper.app' , returnOnFound = True )
182
184
system ('codesign -f --verbose -s "%s" --entitlements %s --deep "%s"' % (identity , tmp_child_entitlements , helperApp ))
183
185
186
+ ## sign parent app
187
+ (_ , tmp_parent_entitlements ) = tempfile .mkstemp ()
188
+ if config .has_option ('Sign' , 'ParentEntitlements' ):
189
+ parent = config .get ('Sign' , 'ParentEntitlements' )
190
+ parent_entitlements = plistlib .readPlist (parent )
191
+ else :
192
+ parent_entitlements = {}
193
+ teamid = get_from_info_plist (args , 'NWTeamID' , default = None )
194
+ if teamid is None :
195
+ groupid = bundleid
196
+ else :
197
+ groupid = '%s.%s' % (teamid , bundleid )
198
+ parent_entitlements ['com.apple.security.app-sandbox' ] = sandbox
184
199
parent_entitlements ['com.apple.security.application-groups' ] = [groupid ]
185
200
plistlib .writePlist (parent_entitlements , tmp_parent_entitlements )
201
+
186
202
info ('Parent entitlements: %s' % tmp_parent_entitlements )
187
203
system ('codesign -f --verbose -s "%s" --entitlements %s --deep "%s"' % (identity , tmp_parent_entitlements , args .output ))
188
204
189
205
def productbuild (config , args ):
190
206
print '\n Running productbuild'
191
- installer_identity = config .get ('Sign ' , 'InstallerIdentity' )
192
- if config .has_option ('Sign ' , 'InstallPath' ):
193
- install_path = config .get ('Sign ' , 'InstallPath' )
207
+ installer_identity = config .get ('Package ' , 'InstallerIdentity' )
208
+ if config .has_option ('Package ' , 'InstallPath' ):
209
+ install_path = config .get ('Package ' , 'InstallPath' )
194
210
else :
195
211
install_path = '/Applications'
196
212
system ('productbuild --component "%s" "%s" --sign "%s" "%s"' % (args .output , install_path , installer_identity , args .pkg ))
@@ -200,28 +216,21 @@ def main():
200
216
parser .add_argument ('-C' , '--config-file' , default = 'build.cfg' , help = 'config file. (default: build.cfg)' )
201
217
parser .add_argument ('-I' , '--input' , default = 'nwjs.app' , help = 'path to input app. (default: nwjs.app)' )
202
218
parser .add_argument ('-O' , '--output' , default = 'nwjs_output.app' , help = 'path to output app. (default: nwjs_output.app)' )
203
- parser .add_argument ('-S' , '--sign-only ' , default = False , help = 'run codesign without patching the app. (default: False)' , action = 'store_true' )
219
+ parser .add_argument ('-S' , '--skip-patching ' , default = False , help = 'run codesign without patching the app. (default: False)' , action = 'store_true' )
204
220
parser .add_argument ('-P' , '--pkg' , default = None , help = 'run productbuild to generate .pkg after codesign. (default: None)' )
205
221
parser .add_argument ('-V' , '--verbose' , default = False , help = 'display detailed information. (default: False)' , action = 'store_true' )
206
222
args = parser .parse_args ()
207
223
208
224
global verbose
209
225
verbose = args .verbose
210
226
211
- if args .sign_only :
212
- info ('Running in Sign Only mode. Only [Sign] section is used in config file' )
213
-
214
- if args .pkg :
215
- info ('--pkg is ignored in Sign Only mode.' )
216
-
217
-
218
227
# read config file
219
228
config = read_config (args )
220
229
221
230
# make a copy
222
231
copy_to_output (args )
223
232
224
- if not args .sign_only :
233
+ if not args .skip_patching :
225
234
# patch Info.plist
226
235
patch_info_plist (config , args )
227
236
@@ -235,7 +244,7 @@ def main():
235
244
# codesign
236
245
codesign_app (config , args )
237
246
238
- if not args . sign_only and args .pkg :
247
+ if args .pkg :
239
248
productbuild (config , args )
240
249
241
250
print '\n Done.'
0 commit comments