Skip to content

Commit e765f57

Browse files
committed
cleaned up all files and set version to 0.1
1 parent cd72809 commit e765f57

File tree

3 files changed

+58
-16
lines changed

3 files changed

+58
-16
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
# quickpkg
1+
# `quickpkg`
2+
3+
This tool will quickly and easily build a package from an installed application, a disk image file or zip archive with an enclosed application bundle. It will also extract the application name and version and use it to name the resulting `pkg` file.
4+
5+
The tool will look for applications on the first level of the disk image or archive. If it finds no or more than one application it will error.
6+
7+
The name of the resulting package will be of the form `{name}-{version}.pkg`. Spaces will be removed from the name. The package will be written to the current working directory.
8+
9+
## Examples
10+
11+
Build package from installed application:
12+
13+
```
14+
quickpkg /Applications/Numbers.app
15+
```
16+
17+
Build package from a disk image:
18+
19+
```
20+
quickpkg ~/Downloads/Firefox\ 43.0.4.dmg
21+
```
22+
23+
Build package from a zip archive:
24+
25+
```
26+
quickpkg ~/Downloads/Things.zip
27+
```
28+
29+
## Background
230

331
OS X has had the `pkgbuild` tool since Xcode 3.2 on Snow Leopard. With pkgbuild you can directly build a installer package from an application in the `/Applications` folder:
432

@@ -16,4 +44,14 @@ pkgbuild --component /Volumes/Firefox/Firefox.app \
1644

1745
This tool even does the work of determining a bundle's identifier and version and sets the identifier and version of the pkg to the same values.
1846

19-
However, `pkgbuild` does not
47+
However, `pkgbuild` does not automatically name the package.
48+
49+
## `quickpkg` vs `autopkg`
50+
51+
This tool is not meant to replace [`autopkg`](https://github.com/autopkg/autopkg). `autopkg` will automate the download, the re-packaging (if necessary) and the upload to and configuration of your client management system. It can also handle much more complex setups than `quickpkg`. `autopkg` is far superior and should be your tool of choice.
52+
53+
However, there are situations where `autopkg` does not work well. The most common reason is if the download cannot be automated because the download page is behind a paywall. Also `autopkg` requires a recipe for a given piece of software. If no recipe exists, `quickpkg` may be a simple alternative. (Though if `quickpkg` works, creating an `autopkg` recipe should not be hard.)
54+
55+
## Warning
56+
57+
All `quickpkg` does is identify an application bundle and package it in a way that the package will install that application bundle into the `/Applications` folder. If the application needs other files (libraries, frameworks, configuration files, license files, preferences etc.) to run and work they are your responsibility.

quickpkg

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import tempfile
99
import shutil
1010

1111

12-
quickpkg_version = '0.0'
12+
quickpkg_version = '0.1'
1313
supported_extensions = ['dmg', 'app', 'zip']
1414

1515
# quickpkg
@@ -118,16 +118,17 @@ def appNameAndVersion(app_path):
118118
app_name = info_plist.get("CFBundleName", None)
119119
app_identifier = info_plist.get("CFBundleIdentifier", None)
120120
app_version = info_plist.get("CFBundleShortVersionString", None)
121-
if app_version == None:
121+
if app_version is None:
122122
app_version = info_plist.get("CFBundleVersion", None)
123123
return (app_name, app_identifier, app_version)
124124

125125

126126
if __name__ == "__main__":
127+
127128
# for convenience link to argparse tutorial:
128129
# https://docs.python.org/2/howto/argparse.html#id1
129130
parser = argparse.ArgumentParser(description="Attempts to build a pkg from the input.",
130-
epilog="""Installer item can be a dmg, or app.
131+
epilog="""Installer item can be a dmg, zip, or app.
131132
132133
Example:
133134
quickpkg /path/to/installer_item""", formatter_class=argparse.RawTextHelpFormatter)
@@ -162,6 +163,7 @@ if __name__ == "__main__":
162163
app_path = item_path
163164

164165
dmgvolumepaths = []
166+
tmp_path = None
165167

166168
# if item is a dmg, mount it and find useful contents
167169
if item_extension == 'dmg':
@@ -179,7 +181,7 @@ if __name__ == "__main__":
179181
print foundapps
180182
detachpaths(dmgvolumepaths)
181183
exit(1)
182-
184+
183185
app_path = foundapps[0]
184186

185187
# if item is zip, unzip to tmp location and find useful contents
@@ -201,19 +203,19 @@ if __name__ == "__main__":
201203
print foundapps
202204
shutil.rmtree(tmp_path)
203205
exit(1)
204-
206+
205207
app_path = foundapps[0]
206208

207209
logger("Found application: %s" % app_path, 1)
208-
210+
209211
# extract version and other metadata
210212
(app_name, app_identifier, app_version) = appNameAndVersion(app_path)
211213

212-
logger("Name: %s, ID: %s, Version: %s" %(app_name, app_identifier, app_version))
214+
logger("Name: %s, ID: %s, Version: %s" % (app_name, app_identifier, app_version))
213215

214216
# TODO: get name syntax from prefs or parameter
215217
pkg_name = "{name}-{version}.pkg".format(name=app_name, version=app_version, identifier=app_identifier)
216-
pkg_name = pkgname.replace(' ', '') # remove spaces
218+
pkg_name = pkg_name.replace(' ', '') # remove spaces
217219
# run pkgutil to build result
218220

219221
pkgcmd = ["/usr/bin/pkgbuild",
@@ -232,4 +234,5 @@ if __name__ == "__main__":
232234
print pkg_name
233235

234236
detachpaths(dmgvolumepaths)
235-
237+
if tmp_path is not None:
238+
shutil.rmtree(tmp_path)

todo.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
- deal with agreements in dmgs (Evernote has one)
22
- deal with already mounted dmgs
3+
- use some preference setting to determine package name syntax
34
- add option to add scripts
45
√ look into and decompress zip files
5-
- support for tar, gzip and bzip
66
- build packages from filelists
77
- use file lists from composer files
8-
- identify app just by name or id
8+
- add option to build a munki-pkg project folder rather than build a package
9+
- signature support
910
- identify shell scripts and build a payload free package
1011
- identify mobileconfigs and build a package installer
11-
- signature support
1212
- other possible file formats: fonts, prefpanes, Safari extensions?
13-
- use some preference setting to determine package name syntax
14-
- add option to build a munki-pkg project folder rather than build a package
1513
√ remove spaces from pkg_name
14+
- support the --ownership flag
15+
- support for tar, gzip and bzip
16+
- identify app just by name or id (could use: mdfind "kMDItemKind == 'Application' && kMDItemDisplayName == 'iTunes'")

0 commit comments

Comments
 (0)