mirror of
https://github.com/munki/munki.git
synced 2026-04-22 20:48:36 -05:00
Re-work of options in meaningful categories, complete with easier to read formatting
Also removed 'options.appdmg' check since this options no longer exists.
This commit is contained in:
+219
-211
@@ -137,26 +137,21 @@ def getCatalogInfoFromDmg(dmgpath, options):
|
||||
cataloginfo['version'] = \
|
||||
iteminfo.get('CFBundleShortVersionString', "0")
|
||||
cataloginfo['installs'] = [iteminfo]
|
||||
if options.appdmg:
|
||||
cataloginfo['installer_type'] = "appdmg"
|
||||
cataloginfo['uninstallable'] = True
|
||||
cataloginfo['uninstall_method'] = "remove_app"
|
||||
else:
|
||||
cataloginfo['installer_type'] = "copy_from_dmg"
|
||||
item_to_copy = {}
|
||||
item_to_copy['source_item'] = item
|
||||
item_to_copy['destination_path'] = \
|
||||
options.destinationpath or "/Applications"
|
||||
if options.user:
|
||||
item_to_copy['user'] = options.user
|
||||
if options.group:
|
||||
item_to_copy['group'] = options.group
|
||||
if options.mode:
|
||||
item_to_copy['mode'] = options.mode
|
||||
cataloginfo['items_to_copy'] = [item_to_copy]
|
||||
cataloginfo['uninstallable'] = True
|
||||
cataloginfo['uninstall_method'] = "remove_copied_items"
|
||||
|
||||
cataloginfo['installer_type'] = "copy_from_dmg"
|
||||
item_to_copy = {}
|
||||
item_to_copy['source_item'] = item
|
||||
item_to_copy['destination_path'] = \
|
||||
options.destinationpath or "/Applications"
|
||||
if options.user:
|
||||
item_to_copy['user'] = options.user
|
||||
if options.group:
|
||||
item_to_copy['group'] = options.group
|
||||
if options.mode:
|
||||
item_to_copy['mode'] = options.mode
|
||||
cataloginfo['items_to_copy'] = [item_to_copy]
|
||||
cataloginfo['uninstallable'] = True
|
||||
cataloginfo['uninstall_method'] = "remove_copied_items"
|
||||
|
||||
#eject the dmg
|
||||
munkicommon.unmountdmg(mountpoints[0])
|
||||
return cataloginfo
|
||||
@@ -278,179 +273,138 @@ def main():
|
||||
usage = """usage: %prog [options] [/path/to/installeritem]
|
||||
%prog --help for more information."""
|
||||
p = optparse.OptionParser(usage=usage)
|
||||
p.add_option('--verify-options-only', action="store_true", help=optparse.SUPPRESS_HELP)
|
||||
p.add_option('--version', '-V', action='store_true',
|
||||
help='Print the version of the munki tools and exit.')
|
||||
p.add_option(
|
||||
'--verify-options-only',
|
||||
action="store_true",
|
||||
help=optparse.SUPPRESS_HELP
|
||||
)
|
||||
p.add_option(
|
||||
'--version', '-V',
|
||||
action='store_true',
|
||||
help='Print the version of the munki tools and exit.'
|
||||
)
|
||||
|
||||
default_options = optparse.OptionGroup(p, 'Default Options',"Options specified will override information derived from the package.")
|
||||
default_options.add_option('--name',
|
||||
# Default override options
|
||||
default_override_options = optparse.OptionGroup(p, 'Default Override Options',
|
||||
"Options specified will override information automatically derived from the package.")
|
||||
default_override_options.add_option(
|
||||
'--name',
|
||||
metavar='NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Name of the package.''')
|
||||
default_options.add_option('--displayname',
|
||||
help='''Name of the package.'''
|
||||
)
|
||||
default_override_options.add_option(
|
||||
'--displayname',
|
||||
metavar='DISPLAY_NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Display name of the package.''')
|
||||
default_options.add_option('--description',
|
||||
help='''Display name of the package.'''
|
||||
)
|
||||
default_override_options.add_option(
|
||||
'--description',
|
||||
metavar='STRING|PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Description of the package.
|
||||
Can be a PATH to a file (plain text or html).''')
|
||||
default_options.add_option('--pkgvers',
|
||||
help='''Description of the package.
|
||||
Can be a PATH to a file (plain text or html).'''
|
||||
)
|
||||
default_override_options.add_option(
|
||||
'--pkgvers',
|
||||
metavar='PACKAGE_VERSION',
|
||||
help='''Optional flag.
|
||||
|
||||
Version of the package.''')
|
||||
default_options.add_option('--RestartAction',
|
||||
help='''Version of the package.'''
|
||||
)
|
||||
default_override_options.add_option(
|
||||
'--RestartAction',
|
||||
metavar='ACTION',
|
||||
help='''Optional flag.
|
||||
|
||||
Specify a 'RestartAction' for the package.
|
||||
|
||||
RequireRestart
|
||||
RequireLogout
|
||||
RecommendRestart''')
|
||||
p.add_option_group(default_options)
|
||||
help='''Specify a 'RestartAction' for the package.
|
||||
Supported actions:
|
||||
RequireRestart
|
||||
RequireLogout
|
||||
RecommendRestart'''
|
||||
)
|
||||
p.add_option_group(default_override_options)
|
||||
|
||||
bool_options = optparse.OptionGroup(p, 'Boolean Options')
|
||||
bool_options.add_option('--autoremove', action='store_true',
|
||||
help='''Optional flag.
|
||||
|
||||
Implies 'true' for 'autoremove' for the installer item.''')
|
||||
bool_options.add_option('--unattended_install', '--unattended-install', action='store_true',
|
||||
help='''Optional flag.
|
||||
|
||||
Implies 'true' for 'unattended_install' for the installer item.''')
|
||||
bool_options.add_option('--unattended_uninstall', '--unattended-uninstall', action='store_true',
|
||||
help='''Optional flag.
|
||||
|
||||
Implies 'true' for 'unattended_uninstall' for the installer item.''')
|
||||
bool_options.add_option('--installer_choices_xml', '--installer-choices-xml', action='store_true',
|
||||
help='''Optional flag (Apple metapackages only)
|
||||
|
||||
Generate installer choices.
|
||||
Note: Requires Mac OS X 10.6.6 or later.''')
|
||||
p.add_option_group(bool_options)
|
||||
|
||||
script_options = optparse.OptionGroup(p, 'Script Options')
|
||||
script_options.add_option('--preinstall_script', '--preinstall-script',
|
||||
# Script options
|
||||
script_options = optparse.OptionGroup(p, 'Script Options',
|
||||
'All scripts are read and embedded into the pkginfo.')
|
||||
script_options.add_option(
|
||||
'--preinstall_script', '--preinstall-script',
|
||||
metavar='SCRIPT_PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Path to an optional preinstall script to be run before
|
||||
installation of the item. The script will be read and
|
||||
embedded into the pkginfo.''')
|
||||
script_options.add_option('--postinstall_script', '--postinstall-script',
|
||||
help='''Path to an optional preinstall script to be run before
|
||||
installation of the item.'''
|
||||
)
|
||||
script_options.add_option(
|
||||
'--postinstall_script', '--postinstall-script',
|
||||
metavar='SCRIPT_PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Path to an optional postinstall script to be run after
|
||||
installation of the item. The script will be read and
|
||||
embedded into the pkginfo.''')
|
||||
script_options.add_option('--preuninstall_script', '--preuninstall-script',
|
||||
help='''Path to an optional postinstall script to be run after
|
||||
installation of the item.'''
|
||||
)
|
||||
script_options.add_option(
|
||||
'--preuninstall_script', '--preuninstall-script',
|
||||
metavar='SCRIPT_PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Path to an optional preuninstall script to be run before
|
||||
removal of the item. The script will be read and
|
||||
embedded into the pkginfo.''')
|
||||
script_options.add_option('--postuninstall_script', '--postuninstall-script',
|
||||
help='''Path to an optional preuninstall script to be run
|
||||
before removal of the item.'''
|
||||
)
|
||||
script_options.add_option(
|
||||
'--postuninstall_script', '--postuninstall-script',
|
||||
metavar='SCRIPT_PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Path to an optional postuninstall script to be run after
|
||||
removal of the item. The script will be read and
|
||||
embedded into the pkginfo.''')
|
||||
script_options.add_option('--uninstall_script', '--uninstall-script',
|
||||
help='''Path to an optional postuninstall script to be run
|
||||
after removal of the item.'''
|
||||
)
|
||||
script_options.add_option(
|
||||
'--uninstall_script', '--uninstall-script',
|
||||
metavar='SCRIPT_PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Path to an uninstall script to be run in order to
|
||||
uninstall this item. The script will be read and
|
||||
embedded into the pkginfo.''')
|
||||
help='''Path to an uninstall script to be run in order to uninstall this item.'''
|
||||
)
|
||||
p.add_option_group(script_options)
|
||||
|
||||
dragdrop_options = optparse.OptionGroup(p, 'Drag-n-Drop Options')
|
||||
dragdrop_options.add_option('--itemname', '-i', '--appname', '-a',
|
||||
# Drag-n-Drop options
|
||||
dragdrop_options = optparse.OptionGroup(p, 'Drag-n-Drop Options',
|
||||
'These options apply to installer items that are "drag-n-drop" disk images.')
|
||||
dragdrop_options.add_option(
|
||||
'--itemname', '-i', '--appname', '-a',
|
||||
metavar='ITEM',
|
||||
dest='item',
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk image with a
|
||||
drag-and-drop item, ITEMNAME is the name or
|
||||
relative path of the item to be installed.
|
||||
help='''Name or relative path of the item to be installed.
|
||||
Useful if there is more than one item at the
|
||||
root of the dmg.''')
|
||||
dragdrop_options.add_option('--destinationpath', '-d',
|
||||
root of the dmg.'''
|
||||
)
|
||||
dragdrop_options.add_option(
|
||||
'--destinationpath', '-d',
|
||||
metavar='PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk image with a
|
||||
drag-and-drop item, this is the path to which
|
||||
the item should be copied. Defaults to
|
||||
"/Applications".''')
|
||||
dragdrop_options.add_option('-o', '--owner',
|
||||
help='''Path to which the item should be copied.
|
||||
Defaults to "/Applications".'''
|
||||
)
|
||||
dragdrop_options.add_option(
|
||||
'-o', '--owner',
|
||||
metavar='USER',
|
||||
dest='user',
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk image used with
|
||||
the copy_from_dmg installer type, this sets the
|
||||
owner of the item specified by the --item flag.
|
||||
The owner may be either a UID or a symbolic name.
|
||||
The owner will be set recursively on the item.''')
|
||||
dragdrop_options.add_option('-g', '--group',
|
||||
help=('''Sets the owner of the item specified by the --item flag. '''
|
||||
'''The owner may be either a UID or a symbolic name. '''
|
||||
'''The owner will be set recursively on the item.''')
|
||||
)
|
||||
dragdrop_options.add_option(
|
||||
'-g', '--group',
|
||||
metavar='GROUP',
|
||||
dest='group',
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk image used with
|
||||
the copy_from_dmg installer type, this sets the
|
||||
group of the item specified by the --item flag.
|
||||
The group may be either a GID or a symbolic name.
|
||||
The group will be set recursively on the item.''')
|
||||
dragdrop_options.add_option('-m', '--mode',
|
||||
help=('''Sets the group of the item specified by the --item flag. '''
|
||||
'''The group may be either a GID or a symbolic name. '''
|
||||
'''The group will be set recursively on the item.''')
|
||||
)
|
||||
dragdrop_options.add_option(
|
||||
'-m', '--mode',
|
||||
metavar='MODE',
|
||||
dest='mode',
|
||||
action='callback',
|
||||
type='string',
|
||||
callback=check_mode,
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk used with
|
||||
the copy_from_dmg installer type, this sets the
|
||||
mode of the item specified by the --item flag.
|
||||
The specified mode must be in symbolic form.
|
||||
See the manpage for chmod(1) for more information.
|
||||
The mode is applied recursively.''')
|
||||
help=("Sets the mode of the item specified by the --item flag. "
|
||||
"The specified mode must be in symbolic form. "
|
||||
"See the manpage for chmod(1) for more information. "
|
||||
"The mode is applied recursively.")
|
||||
)
|
||||
p.add_option_group(dragdrop_options)
|
||||
|
||||
adobe_options = optparse.OptionGroup(p, 'Adobe Options')
|
||||
adobe_options.add_option('--uninstallerdmg', '-u',
|
||||
help='''Optional flag.
|
||||
|
||||
If the installer item is a disk image containing an
|
||||
Adobe CS4 Deployment Toolkit installation package or
|
||||
Adobe CS3 deployment package, UNINSTALLERDMG is a path
|
||||
to a disk image containing an AdobeUberUninstaller for
|
||||
this item.''')
|
||||
p.add_option_group(adobe_options)
|
||||
|
||||
additional_options = optparse.OptionGroup(p, 'Additional Options')
|
||||
additional_options.add_option('--file', '-f', action="append",
|
||||
metavar='PATH',
|
||||
help='''Path to a filesystem item installed by this
|
||||
package, typically an application. This generates an
|
||||
"installs" item for the pkginfo, an item munki can
|
||||
use to determine if this software has been installed.
|
||||
Can be specified multiple times.''')
|
||||
additional_options.add_option('--pkgname', '-p',
|
||||
help='''Optional flag.
|
||||
|
||||
-If the installer item is a disk image containing
|
||||
# Apple package specific options
|
||||
apple_options = optparse.OptionGroup(p, 'Apple Package Options')
|
||||
apple_options.add_option(
|
||||
'--pkgname', '-p',
|
||||
help='''-If the installer item is a disk image containing
|
||||
multiple packages, or the package to be installed
|
||||
is not at the root of the mounted disk image, PKGNAME
|
||||
is a relative path from the root of the mounted
|
||||
@@ -463,59 +417,113 @@ def main():
|
||||
mounted dmg.
|
||||
|
||||
If this flag is missing, the AdobeUber* files should
|
||||
be at the top level of the mounted dmg.''')
|
||||
additional_options.add_option('--minimum_os_version', '--minimum-os-version', '--min-os-ver',
|
||||
metavar='VERSION',
|
||||
help='''Optional flag.
|
||||
|
||||
Minimum OS version for the installer item.''')
|
||||
additional_options.add_option('--maximum_os_version', '--maximum-os-version', '--max-os-ver',
|
||||
metavar='VERSION',
|
||||
help='''Optional flag.
|
||||
|
||||
Maximum OS version for the installer item.''')
|
||||
additional_options.add_option('--force_install_after_date', '--force-install-after-date',
|
||||
be at the top level of the mounted dmg.'''
|
||||
)
|
||||
apple_options.add_option(
|
||||
'--installer_choices_xml', '--installer-choices-xml',
|
||||
action='store_true',
|
||||
help='''Generate installer choices for metapackages.
|
||||
Note: Requires Mac OS X 10.6.6 or later.'''
|
||||
)
|
||||
p.add_option_group(apple_options)
|
||||
|
||||
# Adobe package specific options
|
||||
adobe_options = optparse.OptionGroup(p, 'Adobe-specific Options')
|
||||
adobe_options.add_option(
|
||||
'--uninstallerdmg', '-U',
|
||||
help='''If the installer item is a disk image containing an
|
||||
Adobe CS4 Deployment Toolkit installation package or
|
||||
Adobe CS3 deployment package, UNINSTALLERDMG is a path
|
||||
to a disk image containing an AdobeUberUninstaller for
|
||||
this item.'''
|
||||
)
|
||||
p.add_option_group(adobe_options)
|
||||
|
||||
# Forced/Unattended (install) options
|
||||
forced_unattended_options = optparse.OptionGroup(p, 'Forced/Unattended Options')
|
||||
forced_unattended_options.add_option(
|
||||
'--unattended_install', '--unattended-install',
|
||||
action='store_true',
|
||||
help='''Implies 'true' for 'unattended_install' for the installer item.'''
|
||||
)
|
||||
forced_unattended_options.add_option(
|
||||
'--unattended_uninstall', '--unattended-uninstall',
|
||||
action='store_true',
|
||||
help='''Implies 'true' for 'unattended_uninstall' for the installer item.'''
|
||||
)
|
||||
forced_unattended_options.add_option(
|
||||
'--force_install_after_date', '--force-install-after-date',
|
||||
metavar='yyyy-dd-hhThh:mm:ssZ',
|
||||
help='''Optional flag.
|
||||
|
||||
Specify a date after which the package will be forcefully installed.
|
||||
|
||||
Example: '2011-08-03T13:00:00Z' equates to August 3rd 2011 at 1PM.''')
|
||||
additional_options.add_option('--update_for', '--update-for', '-U', action="append",
|
||||
help=('''Specify a date, in local time, after which the package will be forcefully installed. '''
|
||||
'''Example: '2011-08-11T12:55:00Z' equates to August 11th 2011 at 12:55 PM.''')
|
||||
)
|
||||
p.add_option_group(forced_unattended_options)
|
||||
|
||||
# 'installs' generation options (by itself since no installer_item needs to be specified)
|
||||
gen_installs_options = optparse.OptionGroup(p, '''Generating 'installs' items''')
|
||||
gen_installs_options.add_option(
|
||||
'--file', '-f',
|
||||
action="append",
|
||||
metavar='PATH',
|
||||
help=('''Path to a filesystem item installed by this package, typically an application. '''
|
||||
'''This generates an "installs" item for the pkginfo, to be used to determine if this software has been installed. '''
|
||||
'''Can be specified multiple times.''')
|
||||
)
|
||||
p.add_option_group(gen_installs_options)
|
||||
|
||||
# Additional options - misc. options that don't fit into other categories,
|
||||
# and don't necessarily warrant the creation of their own option group
|
||||
additional_options = optparse.OptionGroup(p, 'Additional Options')
|
||||
additional_options.add_option(
|
||||
'--autoremove',
|
||||
action='store_true',
|
||||
help='''Implies 'true' for 'autoremove' for the installer item.'''
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--minimum_os_version', '--minimum-os-version', '--min-os-ver',
|
||||
metavar='VERSION',
|
||||
help='''Minimum OS version for the installer item.'''
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--maximum_os_version', '--maximum-os-version', '--max-os-ver',
|
||||
metavar='VERSION',
|
||||
help='''Maximum OS version for the installer item.'''
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--update_for', '--update-for', '-u',
|
||||
action="append",
|
||||
metavar='PACKAGE_NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Specifies which package this is an update for.
|
||||
Can be specified multiple times
|
||||
to build an array of multiple packages.''')
|
||||
additional_options.add_option('--requires', '-r', action="append",
|
||||
help=('''Specifies which package this is an update for. '''
|
||||
'''Can be specified multiple times to build an array of multiple packages.''')
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--requires', '-r',
|
||||
action="append",
|
||||
metavar='PACKAGE_NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Specifies which package this package is requires.
|
||||
Can be specified multiple times
|
||||
to build an array of required packages.''')
|
||||
additional_options.add_option('--blocking_applications', '--blocking-applications', '-b', action="append",
|
||||
help=('''Specifies which package this package is requires. '''
|
||||
'''Can be specified multiple times to build an array of required packages.''')
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--blocking_applications', '--blocking-applications', '-b',
|
||||
action="append",
|
||||
metavar='APPLICATION_NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Specifies a blocking application that will prevent installation.
|
||||
Can be specified multiple times
|
||||
to build an array of blocking applications.''')
|
||||
additional_options.add_option('--catalog', '-c', action="append",
|
||||
help=('''Specifies an application that blocks installation. '''
|
||||
'''Can be specified multiple times to build an array of blocking applications.''')
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--catalog', '-c',
|
||||
action="append",
|
||||
metavar='CATALOG_NAME',
|
||||
help='''Optional flag.
|
||||
|
||||
Specifies in which catalog the item should appear. The
|
||||
default is 'testing'. Can be specified multiple times
|
||||
to add the item to multiple catalogs.''')
|
||||
additional_options.add_option('--notes',
|
||||
help=('''Specifies in which catalog the item should appear. '''
|
||||
'''The default is 'testing'. '''
|
||||
'''Can be specified multiple times to add the item to multiple catalogs.''')
|
||||
)
|
||||
additional_options.add_option(
|
||||
'--notes',
|
||||
metavar='STRING|PATH',
|
||||
help='''Optional flag.
|
||||
|
||||
Specifies administrator provided notes
|
||||
to be inserted into the pkginfo.
|
||||
Can be a PATH to a file.''')
|
||||
help=('''Specifies administrator provided notes to be inserted into the pkginfo.'''
|
||||
'''Can be a PATH to a file.''')
|
||||
)
|
||||
p.add_option_group(additional_options)
|
||||
|
||||
options, arguments = p.parse_args()
|
||||
|
||||
Reference in New Issue
Block a user