Don't uninstall common files if there is more than one wxPython installed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -13,19 +13,31 @@ yourself.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, os, glob
|
import sys, os, glob
|
||||||
|
from fnmatch import fnmatchcase
|
||||||
import cPickle, urllib
|
import cPickle, urllib
|
||||||
|
|
||||||
RCPTDIR = "/Library/Receipts"
|
RCPTDIR = "/Library/Receipts"
|
||||||
RSRCDIR = "Contents/Resources"
|
RSRCDIR = "Contents/Resources"
|
||||||
|
|
||||||
# only clean up dirs that have one of these as a prefix. We do this
|
# Only completly clean out dirs that have one of these as a prefix.
|
||||||
# because the file list returned from lsbom will include /, /usr,
|
# We do this because the file list returned from lsbom will include /,
|
||||||
# /usr/local, etc.
|
# /usr, /usr/local, etc.
|
||||||
PREFIXES = [ '/Library/Python/2.3/',
|
PREFIXES = [ '/Library/Python/2.3/',
|
||||||
'/Library/Python/2.4/',
|
'/Library/Python/2.4/',
|
||||||
|
'/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-pacakges/',
|
||||||
|
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-pacakges/',
|
||||||
'/usr/local/lib/',
|
'/usr/local/lib/',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# The files that match one of the items in this list will only be
|
||||||
|
# removed if the last installation of wxPython on the system is being
|
||||||
|
# uninstalled.
|
||||||
|
COMMON_FILES = [ '/usr/local/bin/*',
|
||||||
|
'wx.pth',
|
||||||
|
'wxversion.py',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AccessError(Exception):
|
class AccessError(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -87,10 +99,18 @@ class InstalledReceipt(object):
|
|||||||
handleDir(dirpath)
|
handleDir(dirpath)
|
||||||
|
|
||||||
|
|
||||||
|
def testCommon(self, name):
|
||||||
|
for cmn in COMMON_FILES:
|
||||||
|
if fnmatchcase(name, cmn) or fnmatchcase(os.path.basename(name), cmn):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def showFiles(self):
|
def showFiles(self):
|
||||||
def show(name):
|
def show(name):
|
||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
|
if not self.lastInstall and self.testCommon(name):
|
||||||
|
return
|
||||||
print "Will remove:", name
|
print "Will remove:", name
|
||||||
self.walkFiles(show, show)
|
self.walkFiles(show, show)
|
||||||
|
|
||||||
@@ -98,6 +118,8 @@ class InstalledReceipt(object):
|
|||||||
def testUninstallAccess(self):
|
def testUninstallAccess(self):
|
||||||
def testFile(name):
|
def testFile(name):
|
||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
|
if not self.lastInstall and self.testCommon(name):
|
||||||
|
return
|
||||||
if not os.access(name, os.W_OK):
|
if not os.access(name, os.W_OK):
|
||||||
raise AccessError(name)
|
raise AccessError(name)
|
||||||
self.walkFiles(testFile, testFile)
|
self.walkFiles(testFile, testFile)
|
||||||
@@ -106,13 +128,15 @@ class InstalledReceipt(object):
|
|||||||
def doUninstall(self):
|
def doUninstall(self):
|
||||||
def removeFile(name):
|
def removeFile(name):
|
||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
|
if not self.lastInstall and self.testCommon(name):
|
||||||
|
return
|
||||||
print "Removing:", name
|
print "Removing:", name
|
||||||
os.unlink(name)
|
os.unlink(name)
|
||||||
def removeDir(name):
|
def removeDir(name):
|
||||||
print "Removing:", name
|
print "Removing:", name
|
||||||
if os.path.exists(name):
|
if os.path.exists(name):
|
||||||
hasFiles = os.listdir(name)
|
hasFiles = os.listdir(name)
|
||||||
if hasFiles: # perhaps some left over symlinks, or .pyc files
|
if hasFiles: # perhaps some stale symlinks, or .pyc files
|
||||||
for file in hasFiles:
|
for file in hasFiles:
|
||||||
os.unlink(os.path.join(name, file))
|
os.unlink(os.path.join(name, file))
|
||||||
os.rmdir(name)
|
os.rmdir(name)
|
||||||
@@ -167,6 +191,7 @@ def main():
|
|||||||
if ans in ['Q', 'q']:
|
if ans in ['Q', 'q']:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
inst = installed[int(ans) - 1]
|
inst = installed[int(ans) - 1]
|
||||||
|
inst.lastInstall = len(installed) == 1
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print
|
print
|
||||||
|
Reference in New Issue
Block a user