Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a8d64e

Browse files
implemented the --output option
1 parent 19ee041 commit 6a8d64e

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

‎quickpkg‎

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ if __name__ == "__main__":
191191
Installer item can be a dmg, zip, or app.""",
192192
epilog="""Example: quickpkg /path/to/installer_item""")
193193

194-
195194
# takes a path as input
196195
parser.add_argument('item_path', help="path to the installer item")
197196

@@ -201,8 +200,16 @@ if __name__ == "__main__":
201200
scripts respectively. If you give both the --scripts and either one or both of --preinstall
202201
and --postinstall, quickpkg will attempt to merge, but throw an error if it cannot.''')
203202
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''')
206213

207214
parser.add_argument("-v", "--verbosity", action="count", default=0, help="controls amount of logging output (max -vvv)")
208215
parser.add_argument('--version', help='prints the version', action='version', version=quickpkg_version)
@@ -282,17 +289,27 @@ if __name__ == "__main__":
282289

283290
logger("Name: %s, ID: %s, Version: %s" % (app_name, app_identifier, app_version), 1)
284291

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'
289305

306+
# run pkgutil to build result
290307
pkgcmd = ["/usr/bin/pkgbuild",
291308
"--component", app_path,
292309
"--identifier", app_identifier,
293310
"--version", app_version,
294311
"--install-location", "/Applications",
295-
pkg_name]
312+
pkg_path]
296313

297314
if args.scripts and not os.path.exists(args.scripts):
298315
print "scripts folder %s does not exist!" % args.scripts
@@ -312,7 +329,7 @@ if __name__ == "__main__":
312329
if os.path.exists(postinstall_path):
313330
print "postinstall script already exists in %s" % args.scripts
314331
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)
316333
shutil.copy2(args.postinstall, postinstall_path)
317334
os.chmod(postinstall_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
318335
stat.S_IRGRP | stat.S_IXGRP |
@@ -325,18 +342,21 @@ if __name__ == "__main__":
325342
if os.path.exists(preinstall_path):
326343
print "preinstall script already exists in %s" % args.scripts
327344
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)
329346
shutil.copy2(args.preinstall, preinstall_path)
330347
os.chmod(preinstall_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
331348
stat.S_IRGRP | stat.S_IXGRP |
332349
stat.S_IROTH | stat.S_IXOTH)
333350

334351
if tmp_scripts_path:
335-
logger("scripts path: %s" % tmp_scripts_path)
352+
logger("scripts path: %s" % tmp_scripts_path, 1)
336353
pkgcmd.extend(["--scripts", tmp_scripts_path])
337354
elif args.scripts:
338-
logger("scripts path: %s" % args.scripts)
355+
logger("scripts path: %s" % args.scripts, 1)
339356
pkgcmd.extend(["--scripts", args.scripts])
357+
358+
if args.ownership:
359+
pkgcmd.extend(["--ownership", args.ownership])
340360

341361
result = cmdexec(pkgcmd)
342362

@@ -345,6 +365,6 @@ if __name__ == "__main__":
345365
print "Error Code: %d " % result["return_code"]
346366
print result["stderr"]
347367
else:
348-
print pkg_name
368+
print pkg_path
349369

350370
cleanup_and_exit(0)

‎todo.txt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
- use some preference setting to determine package name syntax
1+
- use some preference setting to determine default package name syntax
22
√ add option to add scripts (--scripts, like the scripts folder)
3-
- add option to add --preinstall script
4-
- add option for --postinstall script
5-
- support the --ownership flag
6-
- option to output pkg to a different dir than cwd
3+
add option to add --preinstall script
4+
add option for --postinstall script
5+
support the --ownership flag
6+
option to output pkg to a different dir than cwd
77
- signature support
88
- identify shell scripts and build a payload free package
99
- identify mobileconfigs and build a package installer if make-profile-pkg is present

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /