Macos 从Mac OS X 10.7.4卸载Qt 4.5.3

Macos 从Mac OS X 10.7.4卸载Qt 4.5.3,macos,qt,qt4,Macos,Qt,Qt4,执行sudopython'/Developer/Tools/uninstall qt.py'会得到以下输出: removing package docs docs is not installed, skipping. removing package headers headers is not installed, skipping. removing package examples examples is not installed, skipping. removing package

执行
sudopython'/Developer/Tools/uninstall qt.py'
会得到以下输出:

removing package docs
docs is not installed, skipping.
removing package headers
headers is not installed, skipping.
removing package examples
examples is not installed, skipping.
removing package plugins
plugins is not installed, skipping.
removing package tools
tools is not installed, skipping.
removing package libraries
libraries is not installed, skipping.
removing package debuglibraries
debuglibraries is not installed, skipping.
removing package translations
translations is not installed, skipping.
此脚本未删除Qt 4.5.3二进制软件包。脚本本身正在查找不存在的
/Library/Receipts/Qt
文件。这是Qt4.5.3二进制软件包的错误吗

#!/usr/bin/env python

#############################################################################
##
## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
## Contact: Nokia Corporation (qt-info@nokia.com)
##
## This file is part of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:LGPL$
## No Commercial Usage
## This file contains pre-release code and may not be distributed.
## You may use this file in accordance with the terms and conditions
## contained in the either Technology Preview License Agreement or the
## Beta Release License Agreement.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file.  Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Nokia gives you certain
## additional rights. These rights are described in the Nokia Qt LGPL
## Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
## package.
##
## GNU General Public License Usage
## Alternatively, this file may be used under the terms of the GNU
## General Public License version 3.0 as published by the Free Software
## Foundation and appearing in the file LICENSE.GPL included in the
## packaging of this file.  Please review the following information to
## ensure the GNU General Public License version 3.0 requirements will be
## met: http://www.gnu.org/copyleft/gpl.html.
##
## If you are unsure which license is appropriate for your use, please
## contact the sales department at http://qt.nokia.com/contact.
## $QT_END_LICENSE$
##
#############################################################################

import commands, sys, os, shutil, glob

trace = False
justTest = False
# Globals
AllPackages = ['docs', 'headers', 'examples', 'plugins', 'tools', 'libraries', 'debuglibraries', 'translations' ]

packagesToRemove = AllPackages

# Travese the list and remove values that won't work.
def realPackagesToRemove(packageList):
    for package in packageList:
        if package not in AllPackages:
            print "%s is NOT a valid package, removing it from the list" % (package)
            packageList.remove(package)
    return packageList

#Remove the files in the list
def removeFiles(fileList, helperFunc=0):
    directories = []
    for file in fileList:
        file = file[1:]
        if not os.path.islink(file) and os.path.isdir(file):
            directories.append(file)
        elif len(file) > 0:
            if os.path.exists(file) or os.path.islink(file):
                if trace:
                    print "remove file: " + file
                if not justTest:
                    os.remove(file) 
            elif not 'uninstall-qt.py' in file:
                print "file: %s does not exist, skipping" % file


    # Now remove any empty directories
    directories.reverse()
    for dir in directories:
        if helperFunc:
            helperFunc(dir)
        if (os.path.exists(dir)) and len(os.listdir(dir)) == 0:
            if trace:
                print "remove dir: " + dir
            if not justTest:
                os.rmdir(dir)
        elif trace and os.path.exists(dir):
            print "NOT removing " + dir

def removeExampleGeneratedFiles(dir):
    extraList = []
    extraList.append(os.path.join(dir, "Info.plist"))
    extraList.append(os.path.join(dir, ".DS_Store"))
    extraList.append(os.path.join(dir, ".qmake.cache"))
    extraList.append(os.path.join(dir, "Makefile"))
    extraList.append(os.path.join(dir, ".obj"))
    extraList.append(os.path.join(dir, ".moc"))

    xcodeprojects = glob.glob(dir + "/*" + os.path.basename(dir) + "*.xcode*")
    xcodeprojects += glob.glob(dir + "/.xcode*")  # Grab the items from qmake mess-up in 4.0.1

    for file in xcodeprojects:
        if trace:
            print "  removing the tree in " + file
        shutil.rmtree(file)

    for file in extraList:
        if os.path.exists(file):
            if trace:
                print "  removing the file in " + file
            if os.path.isdir(file):
                shutil.rmtree(file)
            else:
                os.remove(file)


# Remove the package
def removePackage(package):
    print "removing package " + package
    realPackageName = "/Library/Receipts/Qt_" + package + ".pkg"
    bomLocation = os.path.join(realPackageName, "Contents/Archive.bom")
    if os.path.exists(realPackageName) and os.path.isdir(realPackageName):
        fileList = commands.getoutput("/usr/bin/lsbom -f -p f -d -l " + bomLocation).split()
        if len(fileList) > 0:
            if (package == "examples"):
                removeFiles(fileList, removeExampleGeneratedFiles)
            else:
                removeFiles(fileList)
            shutil.rmtree(realPackageName)
    else:
        print "%s is not installed, skipping." % package


################# Here's where the actual script starts ########################################
if os.getuid() != 0:
    print sys.argv[0] + ": This script must be run as root or with sudo, exiting now."
    sys.exit(-1)

# Take the names of packages on the command-line
if len(sys.argv) > 1:
    packagesToRemove = sys.argv[1:]

packagesToRemove = realPackagesToRemove(packagesToRemove)

if len(packagesToRemove) < 1:
    print "\nNo valid packages to uninstall.\nusage: %s [package ...]" % (sys.argv[0])
    sys.exit(1)

for package in packagesToRemove:
    removePackage(package)
#/usr/bin/env python
#############################################################################
##
##版权所有(C)2009诺基亚公司和/或其子公司。
##联系人:诺基亚公司(qt)-info@nokia.com)
##
##此文件是Qt工具包的一部分。
##
##$QT\u开始\u许可证:LGPL$
##没有商业用途
##此文件包含预发布代码,可能不会分发。
##您可以根据条款和条件使用此文件
##包含在技术预览许可协议或
##测试版发布许可协议。
##
##GNU次要通用公共许可证使用
##或者,该文件可根据GNU协议条款使用
##由自由软件发布的通用公共许可证版本2.1
在文件LIXESE.LGPL中出现的
##此文件的打包。请查看以下信息,以便
##确保符合GNU Lesser通用公共许可证2.1版的要求
##将满足以下要求:http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
##此外,作为一个特殊的例外,诺基亚为您提供了
##其他权利。诺基亚Qt LGPL中介绍了这些权利
##异常版本1.0,包含在本文档中的文件LGPL_Exception.txt中
##包裹。
##
##GNU通用公共许可证使用
##或者,该文件可根据GNU的条款使用
##由自由软件发布的通用公共许可证3.0版
在文件LIXESE.GPL中出现的
##此文件的打包。请查看以下信息,以便
##确保符合GNU通用公共许可证3.0版要求
##会议:http://www.gnu.org/copyleft/gpl.html.
##
##如果您不确定哪个许可证适合您的使用,请
##联系销售部,电话:http://qt.nokia.com/contact.
##$QT_END_许可证$
##
#############################################################################
导入命令、sys、os、shutil、glob
跟踪=假
justTest=False
#全球的
AllPackages=['docs','headers','examples','plugins','tools','libraries','debuglibraries','translations']
packagesToRemove=所有包
#Travese列表并删除不起作用的值。
def realPackagesToRemove(packageList):
对于包装商中的包装:
如果包不在所有包中:
打印“%s”不是有效的包,正在将其从列表“%(包)中删除
包装商。移除(包装)
退货包装商
#删除列表中的文件
def removeFiles(文件列表,helperFunc=0):
目录=[]
对于文件列表中的文件:
file=文件[1:]
如果不是os.path.islink(文件)和os.path.isdir(文件):
目录.append(文件)
elif len(文件)>0:
如果os.path.exists(文件)或os.path.islink(文件):
如果跟踪:
打印“删除文件:”+文件
如果没有测试:
删除(文件)
如果文件中没有“卸载qt.py”:
打印“文件:%s不存在,跳过“%s”文件
#现在删除所有空目录
目录。反向()
对于目录中的目录:
如果helperFunc:
helperFunc(目录)
如果(os.path.exists(dir))和len(os.listdir(dir))==0:
如果跟踪:
打印“删除目录:”+dir
如果没有测试:
os.rmdir(dir)
elif跟踪和os.path.exists(目录):
打印“未删除”+目录
def removeExampleGeneratedFiles(目录):
外部列表=[]
append(os.path.join(dir,“Info.plist”))
extraList.append(os.path.join(dir,“.DS\u存储”))
append(os.path.join(dir,“.qmake.cache”))
append(os.path.join(dir,“Makefile”))
extraList.append(os.path.join(dir,“.obj”))
附加(os.path.join(dir,“.moc”))
xcodeprojects=glob.glob(dir+“/*”+os.path.basename(dir)+“*.xcode*”)
xcodeprojects+=glob.glob(dir+“/.xcode*”)#从4.0.1中的qmake mass-up中获取项目
对于Xcode项目中的文件:
如果跟踪:
打印“删除“+文件中的树”
rmtree(文件)
对于外部列表中的文件:
如果os.path.exists(文件):
如果跟踪:
打印“+文件”中的“删除文件”
如果os.path.isdir(文件):
rmtree(文件)
其他:
删除(文件)
#取下包装
def removePackage(软件包):
打印“移除包装”+包装
realPackageName=“/Library/Receipts/Qt_”+package+”.pkg”
bomLocation=os.path.join(realPackageName,“Contents/Archive.bom”)
如果os.path.exists(realPackageName)和os.path.isdir(realPackageName)存在:
fileList=commands.getoutput(“/usr/bin/lsbom-f-pf-d-l”+bomLocation).split()
如果len(文件列表)>0:
如果(包==“示例”):
removeFiles(文件列表,removeExampleGeneratedFiles)
其他:
移除文件(文件列表)
shutil.rmtree(realPackageName)
其他:
未安装打印“%s”,正在跳过。“%s”
#################这里是实际脚本的开始########################################
如果os.getuid()!=0:
print sys.argv[0]+“:此脚本必须以root用户身份运行,或者使用sudo运行,现在退出。”
系统出口(-1)
#在命令行上获取包的名称
如果len(sys.argv)>1:
packagesToRemove=sys.argv[1:]
packagesToRemove=realPackagesToRemove(packagesToRemove)
如果len(packagesToRemove)<1:
打印“\n没有要卸载的有效包。\n用法:%s[包…]”%(sys.argv[0])
系统出口(1)
对于packagesToRemo中的包
sudo python /Developer/Tools/uninstall-qt.py
#!/usr/bin/env python

#############################################################################
##
## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
## Contact: Nokia Corporation (qt-info@nokia.com)
##
## This file is part of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:LGPL$
## No Commercial Usage
## This file contains pre-release code and may not be distributed.
## You may use this file in accordance with the terms and conditions
## contained in the either Technology Preview License Agreement or the
## Beta Release License Agreement.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file.  Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Nokia gives you certain
## additional rights. These rights are described in the Nokia Qt LGPL
## Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
## package.
##
## GNU General Public License Usage
## Alternatively, this file may be used under the terms of the GNU
## General Public License version 3.0 as published by the Free Software
## Foundation and appearing in the file LICENSE.GPL included in the
## packaging of this file.  Please review the following information to
## ensure the GNU General Public License version 3.0 requirements will be
## met: http://www.gnu.org/copyleft/gpl.html.
##
## If you are unsure which license is appropriate for your use, please
## contact the sales department at http://qt.nokia.com/contact.
## $QT_END_LICENSE$
##
#############################################################################

import commands, sys, os, shutil, glob

trace = False
justTest = False
# Globals
AllPackages = ['docs', 'headers', 'examples', 'plugins', 'tools', 'libraries', 'debuglibraries', 'translations' ]

packagesToRemove = AllPackages

# Travese the list and remove values that won't work.
def realPackagesToRemove(packageList):
    for package in packageList:
        if package not in AllPackages:
            print "%s is NOT a valid package, removing it from the list" % (package)
            packageList.remove(package)
    return packageList

#Remove the files in the list
def removeFiles(fileList, helperFunc=0):
    directories = []
    for file in fileList:
        file = file[1:]
        if not os.path.islink(file) and os.path.isdir(file):
            directories.append(file)
        elif len(file) > 0:
            if os.path.exists(file) or os.path.islink(file):
                if trace:
                    print "remove file: " + file
                if not justTest:
                    os.remove(file) 
            elif not 'uninstall-qt.py' in file:
                print "file: %s does not exist, skipping" % file


    # Now remove any empty directories
    directories.reverse()
    for dir in directories:
        if helperFunc:
            helperFunc(dir)
        if (os.path.exists(dir)) and len(os.listdir(dir)) == 0:
            if trace:
                print "remove dir: " + dir
            if not justTest:
                os.rmdir(dir)
        elif trace and os.path.exists(dir):
            print "NOT removing " + dir

def removeExampleGeneratedFiles(dir):
    extraList = []
    extraList.append(os.path.join(dir, "Info.plist"))
    extraList.append(os.path.join(dir, ".DS_Store"))
    extraList.append(os.path.join(dir, ".qmake.cache"))
    extraList.append(os.path.join(dir, "Makefile"))
    extraList.append(os.path.join(dir, ".obj"))
    extraList.append(os.path.join(dir, ".moc"))

    xcodeprojects = glob.glob(dir + "/*" + os.path.basename(dir) + "*.xcode*")
    xcodeprojects += glob.glob(dir + "/.xcode*")  # Grab the items from qmake mess-up in 4.0.1

    for file in xcodeprojects:
        if trace:
            print "  removing the tree in " + file
        shutil.rmtree(file)

    for file in extraList:
        if os.path.exists(file):
            if trace:
                print "  removing the file in " + file
            if os.path.isdir(file):
                shutil.rmtree(file)
            else:
                os.remove(file)


# Look for the receipts in two locations: /Library/Receipts/ and
# /var/db/receipts/. (The receipts are not copied into
# /Library/Receipts when installing on Snow Leopard.)
def findReceipt(package):
    realPackageName = "/Library/Receipts/Qt_" + package + ".pkg"
    slashLibraryLocation = os.path.join(realPackageName, "Contents/Archive.bom")
    if os.path.exists(realPackageName) and os.path.exists(slashLibraryLocation):
        return slashLibraryLocation, realPackageName;

    slashPrivateLocation = "/var/db/receipts/com.trolltech.qt4." + package + ".bom"
    if os.path.exists(slashPrivateLocation):
        return slashPrivateLocation, slashPrivateLocation;

    if (package == "libraries"):
        package = "libs"
    if (package == "debuglibraries"):
        package = "debuglibs";

    slashPrivateLocation = "/var/db/receipts/com.trolltech.qt4." + package + ".bom"
    if os.path.exists(slashPrivateLocation):
        return slashPrivateLocation, slashPrivateLocation;

    return "", ""

# Remove the package
def removePackage(package):
    print "removing package " + package
    bomLocation, realPackageName = findReceipt(package)
#    print "package receipt at " + bomLocation + " " + realPackageName
    if os.path.exists(realPackageName):
        fileList = commands.getoutput("/usr/bin/lsbom -f -p f -d -l " + bomLocation).split('\n')
        if len(fileList) > 0:
            if (package == "examples"):
                removeFiles(fileList, removeExampleGeneratedFiles)
            else:
                removeFiles(fileList)

            if (os.path.isfile(realPackageName)):
                os.remove(realPackageName)
            else:
                shutil.rmtree(realPackageName)
 #   else:
 #       print "%s is not installed, skipping." % package

################# Here's where the actual script starts ########################################
if os.getuid() != 0:
    print sys.argv[0] + ": This script must be run as root or with sudo, exiting now."
    sys.exit(-1)

# Take the names of packages on the command-line
if len(sys.argv) > 1:
    packagesToRemove = sys.argv[1:]

packagesToRemove = realPackagesToRemove(packagesToRemove)

if len(packagesToRemove) < 1:
    print "\nNo valid packages to uninstall.\nusage: %s [package ...]" % (sys.argv[0])
    sys.exit(1)

for package in packagesToRemove:
    removePackage(package)