Skip to content

Commit 05f5c96

Browse files
committed
first working version
1 parent 956a099 commit 05f5c96

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

quickpkg

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def detachpaths(volpaths):
9191
detachcmd = ["/usr/bin/hdiutil", "detach", x]
9292
cmdexec(detachcmd)
9393

94+
9495
def finditemswithextension(dirpath, item_extension):
9596
foundapps = []
9697
if os.path.exists(dirpath):
@@ -104,6 +105,22 @@ def finditemswithextension(dirpath, item_extension):
104105
exit(1)
105106
return foundapps
106107

108+
109+
def appNameAndVersion(app_path):
110+
info_path = os.path.join(app_path, "Contents/Info.plist")
111+
if not os.path.exists(info_path):
112+
print "Application at path %s does not have Info.plist" % app_path
113+
# TODO: cleanup volumes here
114+
exit(1)
115+
info_plist = plistlib.readPlist(info_path)
116+
app_name = info_plist.get("CFBundleName", None)
117+
app_identifier = info_plist.get("CFBundleIdentifier", None)
118+
app_version = info_plist.get("CFBundleShortVersionString", None)
119+
if app_version == None:
120+
app_version = info_plist.get("CFBundleVersion", None)
121+
return (app_name, app_identifier, app_version)
122+
123+
107124
if __name__ == "__main__":
108125
# for convenience link to argparse tutorial:
109126
# https://docs.python.org/2/howto/argparse.html#id1
@@ -163,9 +180,28 @@ if __name__ == "__main__":
163180

164181
app_path = foundapps[0]
165182

166-
# extract version and other metadata
167-
print app_path
183+
logger("Found application: %s" % app_path, 1)
168184

185+
# extract version and other metadata
186+
(app_name, app_identifier, app_version) = appNameAndVersion(app_path)
187+
188+
logger("Name: %s, ID: %s, Version: %s" %(app_name, app_identifier, app_version))
189+
190+
pkg_name = "${app_name}-${app_version}.pkg"
191+
192+
pkgcmd = ["/usr/bin/pkgbuild",
193+
"--component", app_path,
194+
"--identifier", app_identifier,
195+
"--version", app_version,
196+
"--install-location", "/Applications",
197+
pkg_name]
198+
result = cmdexec(pkgcmd)
199+
200+
print result["stdout"]
201+
if result["return_code"] != 0:
202+
print "Error Code: " + result["return_code"]
203+
print result["stderr"]
204+
169205
# run pkgutil to build result
170206
detachpaths(dmgvolumepaths)
171207

0 commit comments

Comments
 (0)