def removepackages( pkgnames, forcedeletebundles=False, listfiles=False, rebuildpkgdb=False, noremovereceipts=False, noupdateapplepkgdb=False, ): """ Our main function, called by installer.py to remove items based on receipt info. """ if pkgnames == []: munkicommon.display_error("You must specify at least one package to remove!") return -2 if not initDatabase(forcerebuild=rebuildpkgdb): munkicommon.display_error("Could not initialize receipt database.") return -3 pkgkeyslist = getpkgkeys(pkgnames) if len(pkgkeyslist) == 0: return -4 if munkicommon.stopRequested(): return -128 removalpaths = getpathstoremove(pkgkeyslist) if munkicommon.stopRequested(): return -128 if removalpaths: if listfiles: removalpaths.sort() for item in removalpaths: print "/" + item.encode("UTF-8") else: if munkicommon.munkistatusoutput: munkistatus.disableStopButton() removeFilesystemItems(removalpaths, forcedeletebundles) else: munkicommon.display_status_minor("Nothing to remove.") if munkicommon.munkistatusoutput: time.sleep(2) if not listfiles: if not noremovereceipts: removeReceipts(pkgkeyslist, noupdateapplepkgdb) if munkicommon.munkistatusoutput: munkistatus.enableStopButton() munkicommon.display_status_minor("Package removal complete.") time.sleep(2) return 0
def removepackages(pkgnames, forcedeletebundles=False, listfiles=False, rebuildpkgdb=False, noremovereceipts=False, noupdateapplepkgdb=False): """ Our main function, called by installer.py to remove items based on receipt info. """ if pkgnames == []: munkicommon.display_error( "You must specify at least one package to remove!") return -2 if not initDatabase(forcerebuild=rebuildpkgdb): munkicommon.display_error("Could not initialize receipt database.") return -3 pkgkeyslist = getpkgkeys(pkgnames) if len(pkgkeyslist) == 0: return -4 if munkicommon.stopRequested(): return -128 removalpaths = getpathstoremove(pkgkeyslist) if munkicommon.stopRequested(): return -128 if removalpaths: if listfiles: removalpaths.sort() for item in removalpaths: print "/" + item.encode('UTF-8') else: if munkicommon.munkistatusoutput: munkistatus.disableStopButton() removeFilesystemItems(removalpaths, forcedeletebundles) else: munkicommon.display_status_minor('Nothing to remove.') if munkicommon.munkistatusoutput: time.sleep(2) if not listfiles: if not noremovereceipts: removeReceipts(pkgkeyslist, noupdateapplepkgdb) if munkicommon.munkistatusoutput: munkistatus.enableStopButton() munkicommon.display_status_minor('Package removal complete.') time.sleep(2) return 0