forked from rowanj/gitx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.py
executable file
·52 lines (42 loc) · 1.52 KB
/
package.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# Original work by Rowan James
# This is free and unencumbered software released into the public domain.
# http://unlicense.org
import argparse
import subprocess
import tempfile
import shutil
import os
def package(app, bundle, name, verbose=False):
appBase = os.path.dirname(app)
appName = os.path.basename(app)
tmp_dir = tempfile.mkdtemp(dir=appBase)
movedApp = os.path.join(tmp_dir, appName)
shutil.move(app, movedApp)
if verbose:
print('appBase: ' + appBase)
print('appName: ' + appName)
print('tmp_dir: ' + tmp_dir)
hdiutil = ['hdiutil',
'create', bundle,
'-srcfolder', tmp_dir,
'-volname', name]
subprocess.call(hdiutil)
shutil.move(movedApp, app)
shutil.rmtree(tmp_dir)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Package an app into a redistributable DMG')
parser.add_argument('--app',
required=True,
help='the app bundle to package')
parser.add_argument('--output','-o',
required=True,
help='the destination file name')
parser.add_argument('--name','-n',
required=True,
help='the name given to the volume')
parser.add_argument('--verbose','-v',
help='show details of signing process',
action='count')
args = parser.parse_args()
package(args.app, args.output, args.name, args.verbose)