当前位置: 首页>>代码示例>>Python>>正文


Python PackageUtils.PackageUtils类代码示例

本文整理汇总了Python中PackageUtils.PackageUtils的典型用法代码示例。如果您正苦于以下问题:Python PackageUtils类的具体用法?Python PackageUtils怎么用?Python PackageUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PackageUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: installToolChainRPMS

    def installToolChainRPMS(self,chrootID):
        cmdUtils = CommandUtils()
        self.prepareBuildRoot(chrootID)
        self.logger.info("Installing Tool Chain RPMS.......")
        rpmFiles = ""
        packages = ""
        for package in constants.listToolChainRPMPkgsToBuild:
            pkgUtils=PackageUtils(self.logName,self.logPath)
            rpmFile=pkgUtils.findRPMFileForGivenPackage(package)
            if rpmFile is None:
                rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
                if rpmFile is None:
                    self.logger.error("Unable to find rpm "+ package +" in current and previous versions")
                    raise "Input Error"
            rpmFiles += " " + rpmFile
            packages += " " + package

        self.logger.debug("Installing rpms:"+packages)
        cmd=self.rpmCommand + " -i --nodeps --force --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFiles
        process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE)
        retval = process.wait()
        if retval != 0:
            self.logger.error("Installing tool chain  failed")
            raise "RPM installation failed"
            
        self.logger.info("Successfully installed all Tool Chain RPMS in Chroot:"+chrootID)    
开发者ID:sarchoi,项目名称:photon,代码行数:26,代码来源:ToolChainUtils.py

示例2: loadPackagesData

 def loadPackagesData(self):
     listPackages = SPECS.getData().getListPackages()
     listPackages.sort()
     cmdUtils = CommandUtils()
     for package in listPackages:
         for version in SPECS.getData().getVersions(package):
             release = SPECS.getData().getRelease(package, version)
             listRPMPackages = SPECS.getData().getRPMPackages(package, version)
             srpmFileName = package + "-" + version + "-" + release + ".src.rpm"
             srpmFiles = cmdUtils.findFile(srpmFileName, constants.sourceRpmPath)
             srpmFile = None
             if len(srpmFiles) == 1:
                 srpmFile = srpmFiles[0]
             debugrpmFileName = package + "-debuginfo-" + version + "-" + release + "*"
             debugrpmFiles = cmdUtils.findFile(debugrpmFileName, constants.rpmPath)
             debugrpmFile = None
             if len(debugrpmFiles) == 1:
                 debugrpmFile = debugrpmFiles[0]
             pkgUtils = PackageUtils(self.logName, self.logPath)
             for rpmPkg in listRPMPackages:
                 rpmFile = pkgUtils.findRPMFile(rpmPkg, version)
                 if rpmFile is not None:
                     listPkgAttributes = {"sourcerpm":srpmFile, "rpm":rpmFile,
                                          "debugrpm":debugrpmFile}
                     self.pkgList[rpmPkg+"-"+version] = listPkgAttributes
                     self.logger.debug("Added " + rpmPkg + "-" + version + " to the package info json")
                 else:
                     self.logger.debug("Missing rpm file for package:" + rpmPkg)
开发者ID:frapposelli,项目名称:photon,代码行数:28,代码来源:PackageInfo.py

示例3: buildCoreToolChainPackages

 def buildCoreToolChainPackages(self):
     self.logger.info("Building core tool chain packages.....")
     chrootID=None
     try:
         pkgUtils=PackageUtils(self.logName,self.logPath)
         for package in constants.listCoreToolChainRPMPackages:
             rpmPkg=pkgUtils.findRPMFileForGivenPackage(package)
             if rpmPkg is not None:
                 continue
             chrUtils = ChrootUtils(self.logName,self.logPath)
             chrootName="build-core-toolchain"
             destLogPath=constants.logPath+"/build-"+package
             if not os.path.isdir(destLogPath):
                 cmdUtils = CommandUtils()
                 cmdUtils.runCommandInShell("mkdir -p "+destLogPath)
             returnVal,chrootID = chrUtils.createChroot(chrootName)
             if not returnVal:
                 self.logger.error("Creating chroot failed")
                 raise Exception("creating chroot failed")
             self.installToolChainRPMS(chrootID)
             pkgUtils.buildRPMSForGivenPackage(package, chrootID,destLogPath)
             chrUtils.destroyChroot(chrootID)
             chrootID=None
         self.logger.info("Successfully built toolchain")
     except Exception as e:
         self.logger.error("Unable to build tool chain.")
         raise e
     finally:
         if chrootID is not None:
             chrUtils.destroyChroot(chrootID)
开发者ID:harishspqr,项目名称:photon,代码行数:30,代码来源:ToolChainUtils.py

示例4: installToolChain

    def installToolChain(self,chrootID):
        self.logger.info("Installing toolchain.....")
        self.prepareBuildRoot(chrootID)
        cmdUtils = CommandUtils()

        rpmFiles = ""
        packages = ""
        for package in constants.listToolChainRPMPkgsToInstall:
            pkgUtils=PackageUtils(self.logName,self.logPath)
            rpmFile=pkgUtils.findRPMFileForGivenPackage(package)
            if rpmFile is None:
                rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
                if rpmFile is None:
                    if package == "util-linux-devel":
                        self.logger.info("No old verion of util-linux-devel exists, skip until the new version is built")
                        continue
                    if package == "flex-devel":
                        self.logger.info("No old verion of flex-devel exists, skip until the new version is built")
                        continue

                    self.logger.error("Unable to find rpm "+ package +" in current and previous versions")
                    raise Exception("Input Error")
            rpmFiles += " " + rpmFile
            packages += " " + package

        self.logger.debug("Installing toolchain rpms:" + packages)
        cmd=self.rpmCommand + " -i --nodeps --force --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFiles
        process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE)
        retval = process.wait()
        if retval != 0:
            self.logger.error("Installing toolchain rpms failed")
            raise Exception("RPM installation failed")
        
        self.logger.info("Installed toolchain successfully on chroot:"+chrootID)
开发者ID:jacob-vmware,项目名称:photon,代码行数:34,代码来源:ToolChainUtils.py

示例5: readAlreadyAvailablePackages

 def readAlreadyAvailablePackages(self):
     listAvailablePackages=[]
     listRPMFiles=[]
     listDirectorys=[]
     listDirectorys.append(constants.rpmPath)
     if constants.inputRPMSPath is not None:
         listDirectorys.append(constants.inputRPMSPath)
     
     while len(listDirectorys) > 0:
         dirPath=listDirectorys.pop()
         for dirEntry in os.listdir(dirPath):
             dirEntryPath = os.path.join(dirPath, dirEntry)
             if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".rpm"):
                 listRPMFiles.append(dirEntryPath)
             elif os.path.isdir(dirEntryPath):
                 listDirectorys.append(dirEntryPath)
     pkgUtils = PackageUtils(self.logName,self.logPath)
     for rpmfile in listRPMFiles:
         package,version,release = pkgUtils.findPackageInfoFromRPMFile(rpmfile)
         if constants.specData.isRPMPackage(package):
             specVersion=constants.specData.getVersion(package)
             specRelease=constants.specData.getRelease(package)
             if version == specVersion and release == specRelease:
                 listAvailablePackages.append(package)
     self.logger.info("List of Already built packages")
     self.logger.info(listAvailablePackages)
     return listAvailablePackages
开发者ID:DheerajSShetty,项目名称:photon,代码行数:27,代码来源:PackageManager.py

示例6: loadPackagesData

 def loadPackagesData(self):
     listPackages =  constants.specData.getListPackages()
     listPackages.sort()
     listRPMFiles = []
     cmdUtils = CommandUtils()
     for package in listPackages:
         release = constants.specData.getRelease(package)
         version = constants.specData.getVersion(package)
         listRPMPackages = constants.specData.getRPMPackages(package)
         srpmFileName = package+"-"+version+"-"+release+".src.rpm"
         srpmFiles = cmdUtils.findFile(srpmFileName, constants.sourceRpmPath)
         srpmFile = None
         if len(srpmFiles) == 1:
             srpmFile = srpmFiles[0]
         debugrpmFileName = package+"-debuginfo-"+version+"-"+release+"*"
         debugrpmFiles = cmdUtils.findFile(debugrpmFileName, constants.rpmPath)
         debugrpmFile = None
         if len(debugrpmFiles) == 1:
             debugrpmFile = debugrpmFiles[0]
         pkgUtils = PackageUtils(self.logName,self.logPath)
         for rpmPkg in listRPMPackages:
             rpmFile = pkgUtils.findRPMFileForGivenPackage(rpmPkg)
             if rpmFile is not None:
                 listRPMFiles.append(rpmFile)
                 listPkgAttributes = {"sourcerpm":srpmFile, "rpm":rpmFile, "debugrpm":debugrpmFile}
                 self.pkgList[rpmPkg] = listPkgAttributes
                 self.logger.debug("Added "+rpmPkg +" rpm package to the list")
             else:
                 self.logger.error("Missing rpm file for package:"+rpmPkg)
开发者ID:megacoder,项目名称:photon,代码行数:29,代码来源:PackageInfo.py

示例7: buildPackage

 def buildPackage(self,package):
     #should initialize a logger based on package name
     chrUtils = ChrootUtils(self.logName,self.logPath)
     chrootName="build-"+package
     chrootID=None
     isToolChainPackage=False
     if package in constants.listToolChainPackages:
         isToolChainPackage=True
     try:
         chrootID = self.prepareBuildRoot(chrootName,isToolChainPackage)
         destLogPath=constants.logPath+"/build-"+package
         if not os.path.isdir(destLogPath):
             cmdUtils = CommandUtils()
             cmdUtils.runCommandInShell("mkdir -p "+destLogPath)
         
         listInstalledPackages=self.findInstalledPackages(chrootID)
         self.logger.info("List of installed packages")
         self.logger.info(listInstalledPackages)
         listDependentPackages=self.findBuildTimeRequiredPackages(package)
         
         if len(listDependentPackages) != 0:
             self.logger.info("Installing the build time dependent packages......")
             for pkg in listDependentPackages:
                 self.installPackage(pkg,chrootID,destLogPath,listInstalledPackages)
             self.logger.info("Finished installing the build time dependent packages......")
         self.adjustGCCSpecs(package, chrootID, destLogPath)
         pkgUtils = PackageUtils(self.logName,self.logPath)
         pkgUtils.buildRPMSForGivenPackage(package,chrootID,destLogPath)
         self.logger.info("Successfully built the package:"+package)
     except Exception as e:
         self.logger.error("Failed while building package:" + package)
         self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.")
         raise e
     if chrootID is not None:
         chrUtils.destroyChroot(chrootID)
开发者ID:johnt337,项目名称:photon,代码行数:35,代码来源:PackageBuilder.py

示例8: installCoreToolChainPackages

    def installCoreToolChainPackages(self,chrootID):
        self.logger.info("Installing toolchain.....")
        cmdUtils = CommandUtils()
        self.prepareBuildRoot(chrootID)

        rpmFiles = ""
        packages = ""
        for package in constants.listToolChainRPMPkgsToBuild:
            pkgUtils=PackageUtils(self.logName,self.logPath)
            rpmFile = None
            if package in constants.listCoreToolChainRPMPackages:
                rpmFile=pkgUtils.findRPMFileForGivenPackage(package)
            else:
                rpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
            if rpmFile is None:
                self.logger.error("Unable to find rpm "+ package)
                raise Exception("Input Error")
            rpmFiles += " " + rpmFile
            packages += " " + package

        self.logger.debug("Installing core toolchain rpms:" + packages)
        cmd=self.rpmCommand + " -i --nodeps --force --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFiles
        process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE)
        retval = process.wait()
        if retval != 0:
            self.logger.error("Installing toolchain rpms failed")
            raise Exception("RPM installation failed")
            
        self.logger.info("Installed core tool chain packages successfully on chroot:"+chrootID)    
开发者ID:jacob-vmware,项目名称:photon,代码行数:29,代码来源:ToolChainUtils.py

示例9: _findInstalledPackages

 def _findInstalledPackages(self, sandbox):
     pkgUtils = PackageUtils(self.logName, self.logPath)
     listInstalledRPMs = pkgUtils.findInstalledRPMPackages(sandbox)
     listInstalledPackages = []
     for installedRPM in listInstalledRPMs:
         pkg = self._findPackageNameAndVersionFromRPMFile(installedRPM)
         if pkg is not None:
             listInstalledPackages.append(pkg)
     return listInstalledPackages, listInstalledRPMs
开发者ID:frapposelli,项目名称:photon,代码行数:9,代码来源:PackageBuilder.py

示例10: findInstalledPackages

 def findInstalledPackages(self,chrootID):
     pkgUtils = PackageUtils(self.logName,self.logPath)
     listInstalledRPMs=pkgUtils.findInstalledRPMPackages(chrootID)
     listInstalledPackages=[]
     for installedRPM in listInstalledRPMs:
         packageName=self.findPackageNameFromRPMFile(installedRPM)
         if packageName is not None:
             listInstalledPackages.append(packageName)
     return listInstalledPackages
开发者ID:megacoder,项目名称:photon,代码行数:9,代码来源:PackageBuilder.py

示例11: installToolChain2

    def installToolChain2(self,chrootID,packagesInToolChain):
        self.logger.info("Installing toolchain.....")
        self.prepareBuildRoot(chrootID)
        cmdUtils = CommandUtils()

        rpmFiles = ""
        packages = ""
        for package in packagesInToolChain:
            pkgUtils=PackageUtils(self.logName,self.logPath)
            currentRpmFile=pkgUtils.findRPMFileForGivenPackage(package)

            prevPublishedRpmFile=None
            if currentRpmFile is None or ("-devel" not in package and "-lib" not in package and "perl" not in package):
                prevPublishedRpmFile=self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
                if prevPublishedRpmFile is None:
                    if package == "util-linux-devel":
                        self.logger.info("No old verion of util-linux-devel exists, skip until the new version is built")
                        continue
                    if package == "flex-devel":
                        self.logger.info("No old verion of flex-devel exists, skip until the new version is built")
                        continue

                    self.logger.error("Unable to find rpm "+ package +" in current and previous versions")
                    raise Exception("Input Error")

            if (currentRpmFile is not None) and (prevPublishedRpmFile is not None):
                temp = currentRpmFile[len(package)+ 1:]
                currentRpmVersion = temp[:temp.find('-')]
                temp = prevPublishedRpmFile[len(package)+1:]
                prevPublishedRpmVersion = temp[:temp.find('-')]
                if(currentRpmVersion != prevPublishedRpmVersion):
                    rpmFiles += " " + prevPublishedRpmFile
                    packages += " " + package
                rpmFiles += " " + currentRpmFile
                packages += " " + package

            else:
                if  prevPublishedRpmFile is not None:
                    rpmFiles += " " + prevPublishedRpmFile
                    packages += " " + package

                if currentRpmFile is not None:
                    rpmFiles += " " + currentRpmFile
                    packages += " " + package


        self.logger.debug("Installing toolchain rpms:" + packages)
        self.logger.debug("Installing toolchain rpms:" + rpmFiles)
        cmd=self.rpmCommand + " -i --nodeps --force --root "+chrootID+" --define \'_dbpath /var/lib/rpm\' "+ rpmFiles
        process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE)
        retval = process.wait()
        if retval != 0:
            self.logger.error("Installing toolchain rpms failed")
            raise Exception("RPM installation failed")
        
        self.logger.info("Installed toolchain successfully on chroot:"+chrootID)
开发者ID:corebug,项目名称:photon,代码行数:56,代码来源:ToolChainUtils.py

示例12: checkIfPackageIsAlreadyBuilt

 def checkIfPackageIsAlreadyBuilt(self, package):
     basePkg=constants.specData.getSpecName(package)
     listRPMPackages=constants.specData.getRPMPackages(basePkg)
     packageIsAlreadyBuilt=True
     pkgUtils = PackageUtils(self.logName,self.logPath)
     for pkg in listRPMPackages:
         if pkgUtils.findRPMFileForGivenPackage(pkg) is None:
             packageIsAlreadyBuilt=False
             break
     return packageIsAlreadyBuilt
开发者ID:megacoder,项目名称:photon,代码行数:10,代码来源:PackageBuilder.py

示例13: _checkIfPackageIsAlreadyBuilt

 def _checkIfPackageIsAlreadyBuilt(self):
     basePkg = SPECS.getData().getSpecName(self.package)
     listRPMPackages = SPECS.getData().getRPMPackages(basePkg)
     packageIsAlreadyBuilt = True
     pkgUtils = PackageUtils(self.logName, self.logPath)
     for pkg in listRPMPackages:
         if pkgUtils.findRPMFileForGivenPackage(pkg) is None:
             packageIsAlreadyBuilt = False
             break
     return packageIsAlreadyBuilt
开发者ID:vinaykul,项目名称:photon,代码行数:10,代码来源:PackageBuilder.py

示例14: _findInstalledPackages

 def _findInstalledPackages(self, instanceID):
     pkgUtils = PackageUtils(self.logName, self.logPath)
     if self.pkgBuildType == "chroot":
         listInstalledRPMs = pkgUtils.findInstalledRPMPackages(instanceID)
     elif self.pkgBuildType == "container":
         listInstalledRPMs = pkgUtils.findInstalledRPMPackagesInContainer(instanceID)
     listInstalledPackages = []
     for installedRPM in listInstalledRPMs:
         packageName = self._findPackageNameFromRPMFile(installedRPM)
         if packageName is not None:
             listInstalledPackages.append(packageName)
     return listInstalledPackages, listInstalledRPMs
开发者ID:vinaykul,项目名称:photon,代码行数:12,代码来源:PackageBuilder.py

示例15: prepareBuildRoot

    def prepareBuildRoot(self,chrootID):
        self.logger.info("Preparing build environment")
        cmdUtils = CommandUtils()
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+"/tmp")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath)
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/x86_64")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/RPMS/noarch")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SOURCES")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/SPECS")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/LOGS")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/BUILD")
        cmdUtils.runCommandInShell("mkdir -p "+chrootID+constants.topDirPath+"/BUILDROOT")

        package="filesystem"
        pkgUtils=PackageUtils(self.logName,self.logPath)
        rpmFile=pkgUtils.findRPMFileForGivenPackage(package)
        if rpmFile is None:
            specFile=constants.specData.getSpecFile(package)
            cmd=self.rpmbuildCommand+" -ba --nocheck --define \'_topdir "+chrootID+constants.topDirPath+"\' --define \'_dbpath "+chrootID+"/var/lib/rpm\' --define \'dist "+constants.dist+"\' "+specFile
            self.logger.info(cmd)
            cmdUtils.runCommandInShell(cmd,self.logPath+"/filesystem.log")
            filesystemrpmFile = cmdUtils.findFile(package+"-[0-9]*.rpm", chrootID+constants.topDirPath+"/RPMS")
            filesystemsrpmFile = cmdUtils.findFile(package+"-[0-9]*.src.rpm", chrootID+constants.topDirPath+"/SRPMS")
            if len(filesystemrpmFile) > 0:
                shutil.copy2(filesystemrpmFile[0],constants.rpmPath+"/x86_64/")
            if len(filesystemsrpmFile) > 0:
                shutil.copy2(filesystemsrpmFile[0],constants.sourceRpmPath+"/")
            rpmFile=pkgUtils.findRPMFileForGivenPackage(package)
            if rpmFile is None:
                self.logger.error("Cannot find filesystem rpm")
                raise Exception("Cannot find filesystem rpm")
        
        self.logger.debug("Installing filesystem rpms:" + package)
        if os.geteuid()==0:
            cmd=self.rpmCommand + " -i --nodeps --root "+chrootID+" --define '_dbpath /var/lib/rpm' "+ rpmFile
        else:
            cmd=self.rpmCommand + " -i --nodeps --badreloc --relocate /="+chrootID+" --define '_dbpath "+chrootID+"/var/lib/rpm' "+ rpmFile
        process = subprocess.Popen("%s" %cmd,shell=True,stdout=subprocess.PIPE)
        retval = process.wait()
        if retval != 0:
            self.logger.error("Installing filesystem rpm failed")
            raise Exception("RPM installation failed")
        
        prepareChrootCmd=self.prepareBuildRootCmd+" "+chrootID
        logFile=constants.logPath+"/prepareBuildRoot.log"
        returnVal=cmdUtils.runCommandInShell(prepareChrootCmd,logFile)
        if not returnVal:
            self.logger.error("Prepare build root script failed.Unable to prepare chroot.")
            raise Exception("Prepare build root script failed")

        self.logger.info("Successfully prepared chroot:"+chrootID)
开发者ID:MrScriptMaster,项目名称:photon,代码行数:51,代码来源:ToolChainUtils.py


注:本文中的PackageUtils.PackageUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。