@@ -191,7 +191,6 @@ if __name__ == "__main__":
191
191
Installer item can be a dmg, zip, or app.""" ,
192
192
epilog = """Example: quickpkg /path/to/installer_item""" )
193
193
194
-
195
194
# takes a path as input
196
195
parser .add_argument ('item_path' , help = "path to the installer item" )
197
196
@@ -201,8 +200,16 @@ if __name__ == "__main__":
201
200
scripts respectively. If you give both the --scripts and either one or both of --preinstall
202
201
and --postinstall, quickpkg will attempt to merge, but throw an error if it cannot.''' )
203
202
scripts_group .add_argument ('--scripts' , help = "path to a folder with scripts" )
204
- scripts_group .add_argument ('--preinstall' , help = "path to the preinstall script" )
205
- scripts_group .add_argument ('--postinstall' , help = "path to the postinstall script" )
203
+ scripts_group .add_argument ('--preinstall' , '--pre' , help = "path to the preinstall script" )
204
+ scripts_group .add_argument ('--postinstall' , '--post' , help = "path to the postinstall script" )
205
+
206
+ parser .add_argument ('--ownership' , choices = ['recommended' , 'preserve' , 'preserve-other' ],
207
+ help = "will be passed through to pkgbuild" )
208
+ parser .add_argument ('--output' , '--out' , '-o' ,
209
+ help = '''path where the package file will be created. If you give the full filename
210
+ then you can use '{name}', '{version}' and '{identifier}' as placeholders.
211
+ If this is a directory, then the
212
+ package will be created with the default filename {name}-{version}.pkg''' )
206
213
207
214
parser .add_argument ("-v" , "--verbosity" , action = "count" , default = 0 , help = "controls amount of logging output (max -vvv)" )
208
215
parser .add_argument ('--version' , help = 'prints the version' , action = 'version' , version = quickpkg_version )
@@ -282,17 +289,27 @@ if __name__ == "__main__":
282
289
283
290
logger ("Name: %s, ID: %s, Version: %s" % (app_name , app_identifier , app_version ), 1 )
284
291
285
- # TODO: get name syntax from prefs or parameter
286
- pkg_name = "{name}-{version}.pkg" .format (name = app_name , version = app_version , identifier = app_identifier )
287
- pkg_name = pkg_name .replace (' ' , '' ) # remove spaces
288
- # run pkgutil to build result
292
+ pkg_name = "{name}-{version}.pkg"
293
+ if args .output :
294
+ if os .path .isdir (args .output ):
295
+ pkg_path = os .path .join (args .output , pkg_name )
296
+ else :
297
+ pkg_path = args .output
298
+ else :
299
+ pkg_path = pkg_name
300
+ nospace_app_name = app_name .replace (' ' , '' ) # remove spaces
301
+ pkg_path = pkg_path .format (name = nospace_app_name , version = app_version , identifier = app_identifier )
302
+
303
+ if not pkg_path .endswith ('pkg' ):
304
+ pkg_path += '.pkg'
289
305
306
+ # run pkgutil to build result
290
307
pkgcmd = ["/usr/bin/pkgbuild" ,
291
308
"--component" , app_path ,
292
309
"--identifier" , app_identifier ,
293
310
"--version" , app_version ,
294
311
"--install-location" , "/Applications" ,
295
- pkg_name ]
312
+ pkg_path ]
296
313
297
314
if args .scripts and not os .path .exists (args .scripts ):
298
315
print "scripts folder %s does not exist!" % args .scripts
@@ -312,7 +329,7 @@ if __name__ == "__main__":
312
329
if os .path .exists (postinstall_path ):
313
330
print "postinstall script already exists in %s" % args .scripts
314
331
cleanup_and_exit (1 )
315
- logger ("copying %s to %s" % (args .postinstall , postinstall_path ))
332
+ logger ("copying %s to %s" % (args .postinstall , postinstall_path ), 1 )
316
333
shutil .copy2 (args .postinstall , postinstall_path )
317
334
os .chmod (postinstall_path , stat .S_IRUSR | stat .S_IWUSR | stat .S_IXUSR |
318
335
stat .S_IRGRP | stat .S_IXGRP |
@@ -325,18 +342,21 @@ if __name__ == "__main__":
325
342
if os .path .exists (preinstall_path ):
326
343
print "preinstall script already exists in %s" % args .scripts
327
344
cleanup_and_exit (1 )
328
- logger ("copying %s to %s" % (args .preinstall , preinstall_path ))
345
+ logger ("copying %s to %s" % (args .preinstall , preinstall_path ), 1 )
329
346
shutil .copy2 (args .preinstall , preinstall_path )
330
347
os .chmod (preinstall_path , stat .S_IRUSR | stat .S_IWUSR | stat .S_IXUSR |
331
348
stat .S_IRGRP | stat .S_IXGRP |
332
349
stat .S_IROTH | stat .S_IXOTH )
333
350
334
351
if tmp_scripts_path :
335
- logger ("scripts path: %s" % tmp_scripts_path )
352
+ logger ("scripts path: %s" % tmp_scripts_path , 1 )
336
353
pkgcmd .extend (["--scripts" , tmp_scripts_path ])
337
354
elif args .scripts :
338
- logger ("scripts path: %s" % args .scripts )
355
+ logger ("scripts path: %s" % args .scripts , 1 )
339
356
pkgcmd .extend (["--scripts" , args .scripts ])
357
+
358
+ if args .ownership :
359
+ pkgcmd .extend (["--ownership" , args .ownership ])
340
360
341
361
result = cmdexec (pkgcmd )
342
362
@@ -345,6 +365,6 @@ if __name__ == "__main__":
345
365
print "Error Code: %d " % result ["return_code" ]
346
366
print result ["stderr" ]
347
367
else :
348
- print pkg_name
368
+ print pkg_path
349
369
350
370
cleanup_and_exit (0 )
0 commit comments