mirror of
https://github.com/munki/munki.git
synced 2026-05-11 23:09:46 -05:00
Add support for uninstall_method of type 'uninstall_package'
This commit is contained in:
@@ -170,7 +170,7 @@ def handle_apple_package_install(item, itempath):
|
||||
"suppress_bundle_relocation: %s", suppress_bundle_relocation)
|
||||
if pkgutils.hasValidDiskImageExt(itempath):
|
||||
display.display_status_minor(
|
||||
"Mounting disk image %s" % item["installer_item"])
|
||||
"Mounting disk image %s" % os.path.basename(itempath))
|
||||
mount_with_shadow = suppress_bundle_relocation
|
||||
# we need to mount the diskimage as read/write to be able to
|
||||
# modify the package to suppress bundle relocation
|
||||
@@ -545,6 +545,26 @@ def process_removals(removallist, only_unattended=False):
|
||||
munkilog.log(
|
||||
"Uninstall of %s was successful." % display_name)
|
||||
|
||||
elif uninstallmethod == "uninstall_package":
|
||||
# install a package to remove the software
|
||||
if "uninstaller_item" in item:
|
||||
managedinstallbase = prefs.pref('ManagedInstallDir')
|
||||
itempath = os.path.join(managedinstallbase, 'Cache',
|
||||
item["uninstaller_item"])
|
||||
if not os.path.exists(itempath):
|
||||
display.display_error(
|
||||
"%s package for %s was missing from the cache."
|
||||
% (uninstallmethod, item['name']))
|
||||
continue
|
||||
(retcode, need_to_restart) = handle_apple_package_install(
|
||||
item, itempath)
|
||||
if need_to_restart:
|
||||
restart_flag = True
|
||||
else:
|
||||
display.display_error(
|
||||
"No uninstall item specified for %s" % item['name'])
|
||||
continue
|
||||
|
||||
elif uninstallmethod.startswith("Adobe"):
|
||||
retcode = adobeutils.do_adobe_removal(item)
|
||||
|
||||
|
||||
@@ -848,7 +848,8 @@ def process_removal(manifestitem, cataloglist, installinfo):
|
||||
elif uninstallmethod in ['remove_copied_items',
|
||||
'remove_app',
|
||||
'uninstall_script',
|
||||
'remove_profile']:
|
||||
'remove_profile',
|
||||
'uninstall_package']:
|
||||
uninstall_item = found_item
|
||||
else:
|
||||
# uninstall_method is a local script.
|
||||
@@ -1025,7 +1026,28 @@ def process_removal(manifestitem, cataloglist, installinfo):
|
||||
iteminfo['remove_app_info'] = uninstall_item['installs'][0]
|
||||
elif uninstallmethod == 'uninstall_script':
|
||||
iteminfo['uninstall_script'] = uninstall_item.get('uninstall_script', '')
|
||||
|
||||
elif uninstallmethod == "uninstall_package":
|
||||
location = uninstall_item.get('uninstaller_item_location')
|
||||
if not location:
|
||||
display.display_warning(
|
||||
'Can\'t uninstall %s because there is no URL for the uninstall '
|
||||
'package.', iteminfo['name'])
|
||||
return False
|
||||
try:
|
||||
download.download_installeritem(
|
||||
uninstall_item, installinfo, uninstalling=True)
|
||||
filename = os.path.split(location)[1]
|
||||
iteminfo['uninstaller_item'] = filename
|
||||
except fetch.PackageVerificationError:
|
||||
display.display_warning(
|
||||
'Can\'t uninstall %s because the integrity check '
|
||||
'failed.', iteminfo['name'])
|
||||
return False
|
||||
except fetch.Error as errmsg:
|
||||
display.display_warning(
|
||||
'Failed to download the uninstaller for %s because %s',
|
||||
iteminfo['name'], errmsg)
|
||||
return False
|
||||
# before we add this removal to the list,
|
||||
# check for installed updates and add them to the
|
||||
# removal list as well:
|
||||
|
||||
Reference in New Issue
Block a user