def buildPackage(self, package): #do not build if RPM is already built #test only if the package is in the testForceRPMS with rpmCheck #build only if the package is not in the testForceRPMS with rpmCheck if self.checkIfPackageIsAlreadyBuilt(package): if not constants.rpmCheck: self.logger.info("Skipping building the package:" + package) return elif constants.rpmCheck and package not in constants.testForceRPMS: self.logger.info("Skipping testing the package:" + package) return #should initialize a logger based on package name chrUtils = ChrootUtils(self.logName, self.logPath) chrootName = "build-" + package chrootID = None try: chrootID = self.prepareBuildRoot(chrootName, package) destLogPath = constants.logPath + "/build-" + package if not os.path.isdir(destLogPath): cmdUtils = CommandUtils() cmdUtils.runCommandInShell("mkdir -p " + destLogPath) listInstalledPackages = self.findInstalledPackages(chrootID) listDependentPackages = self.findBuildTimeRequiredPackages(package) if constants.rpmCheck and package in constants.testForceRPMS: testPackages = set( constants.listMakeCheckRPMPkgtoInstall) - set( listInstalledPackages) - set([package]) listDependentPackages.extend(testPackages) pkgUtils = PackageUtils(self.logName, self.logPath) if len(listDependentPackages) != 0: self.logger.info( "Installing the build time dependent packages......") for pkg in listDependentPackages: self.installPackage(pkgUtils, pkg, chrootID, destLogPath, listInstalledPackages) pkgUtils.installRPMSInAOneShot(chrootID, destLogPath) self.logger.info( "Finished installing the build time dependent packages......" ) pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath) pkgUtils.buildRPMSForGivenPackage(package, chrootID, self.listBuildOptionPackages, self.pkgBuildOptionFile, 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.") logFileName = os.path.join(destLogPath, package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
def _buildPackage(self): chrUtils = ChrootUtils(self.logName, self.logPath) chrootID = None try: chrootID = self._prepareBuildRoot() listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(chrootID)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info( "Installing the build time dependent packages......") for pkg in listDependentPackages: packageName, packageVersion = StringUtils.splitPackageNameAndVersion( pkg) self._installPackage(pkgUtils, packageName, packageVersion, chrootID, self.logPath, listInstalledPackages, listInstalledRPMs) for pkg in listTestPackages: flag = False packageName, packageVersion = StringUtils.splitPackageNameAndVersion( pkg) for depPkg in listDependentPackages: depPackageName, depPackageVersion = StringUtils.splitPackageNameAndVersion( depPkg) if depPackageName == packageName: flag = True break if flag == False: self._installPackage(pkgUtils, packageName, packageVersion, chrootID, self.logPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShot(chrootID, self.logPath) self.logger.info( "Finished installing the build time dependent packages...." ) pkgUtils.adjustGCCSpecs(self.package, self.version, chrootID, self.logPath) pkgUtils.buildRPMSForGivenPackage(self.package, self.version, chrootID, self.logPath) self.logger.info("Successfully built the package:" + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.") logFileName = os.path.join(self.logPath, self.package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
def buildPackage(self,package): #do not build if RPM is already built #test only if the package is in the testForceRPMS with rpmCheck #build only if the package is not in the testForceRPMS with rpmCheck if self.checkIfPackageIsAlreadyBuilt(package): if not constants.rpmCheck: self.logger.info("Skipping building the package:"+package) return elif constants.rpmCheck and package not in constants.testForceRPMS: self.logger.info("Skipping testing the package:"+package) return #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) listDependentPackages=self.findBuildTimeRequiredPackages(package) if constants.rpmCheck and package in constants.testForceRPMS: testPackages=set(constants.listMakeCheckRPMPkgtoInstall)-set(listInstalledPackages)-set([package]) listDependentPackages.extend(testPackages) pkgUtils = PackageUtils(self.logName,self.logPath) if len(listDependentPackages) != 0: self.logger.info("Installing the build time dependent packages......") for pkg in listDependentPackages: self.installPackage(pkgUtils, pkg,chrootID,destLogPath,listInstalledPackages) pkgUtils.installRPMSInAOneShot(chrootID,destLogPath) self.logger.info("Finished installing the build time dependent packages......") pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath) pkgUtils.buildRPMSForGivenPackage(package,chrootID,self.listBuildOptionPackages,self.pkgBuildOptionFile,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.") logFileName = os.path.join(destLogPath, package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
def _buildPackage(self, index=0): #do not build if RPM is already built #test only if the package is in the testForceRPMS with rpmCheck #build only if the package is not in the testForceRPMS with rpmCheck if self._checkIfPackageIsAlreadyBuilt(index): if not constants.rpmCheck: self.logger.info("Skipping building the package:" + self.package) return elif constants.rpmCheck and self.package not in constants.testForceRPMS: self.logger.info("Skipping testing the package:" + self.package) return chrUtils = ChrootUtils(self.logName, self.logPath) chrootID = None try: chrootID = self._prepareBuildRoot() listDependentPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(chrootID, index)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info( "Installing the build time dependent packages......") for pkg in listDependentPackages: self._installPackage(pkgUtils, pkg, chrootID, self.logPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShot(chrootID, self.logPath) self.logger.info( "Finished installing the build time dependent packages...." ) pkgUtils.adjustGCCSpecs(self.package, chrootID, self.logPath, index) pkgUtils.buildRPMSForGivenPackage(self.package, chrootID, self.logPath, index) self.logger.info("Successfully built the package:" + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.") logFileName = os.path.join(self.logPath, self.package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
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) pkgUtils = PackageUtils(self.logName, self.logPath) if len(listDependentPackages) != 0: self.logger.info( "Installing the build time dependent packages......") for pkg in listDependentPackages: self.installPackage(pkgUtils, pkg, chrootID, destLogPath, listInstalledPackages) pkgUtils.installRPMSInAOneShot(chrootID, destLogPath) self.logger.info( "Finished installing the build time dependent packages......" ) pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath) 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.") logFileName = os.path.join(destLogPath, package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
def _buildPackage(self): #do not build if RPM is already built #test only if the package is in the testForceRPMS with rpmCheck #build only if the package is not in the testForceRPMS with rpmCheck if self._checkIfPackageIsAlreadyBuilt(): if not constants.rpmCheck: self.logger.info("Skipping building the package:" + self.package) return elif constants.rpmCheck and self.package not in constants.testForceRPMS: self.logger.info("Skipping testing the package:" + self.package) return chrUtils = ChrootUtils(self.logName, self.logPath) chrootID = None try: chrootID = self._prepareBuildRoot() listDependentPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(chrootID)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info("Installing the build time dependent packages......") for pkg in listDependentPackages: self._installPackage(pkgUtils, pkg, chrootID, self.logPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShot(chrootID, self.logPath) self.logger.info("Finished installing the build time dependent packages....") pkgUtils.adjustGCCSpecs(self.package, chrootID, self.logPath) pkgUtils.buildRPMSForGivenPackage(self.package, chrootID, self.logPath) self.logger.info("Successfully built the package:" + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.") logFileName = os.path.join(self.logPath, self.package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
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) pkgUtils = PackageUtils(self.logName,self.logPath) if len(listDependentPackages) != 0: self.logger.info("Installing the build time dependent packages......") for pkg in listDependentPackages: self.installPackage(pkgUtils, pkg,chrootID,destLogPath,listInstalledPackages) pkgUtils.installRPMSInAOneShot(chrootID,destLogPath) self.logger.info("Finished installing the build time dependent packages......") pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath) 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.") logFileName = os.path.join(destLogPath, package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)
def buildPackage(self): #do not build if RPM is already built #test only if the package is in the testForceRPMS with rpmCheck #build only if the package is not in the testForceRPMS with rpmCheck if self.base.checkIfPackageIsAlreadyBuilt(): if not constants.rpmCheck: self.base.logger.info("Skipping building the package:" + self.base.package) return elif constants.rpmCheck and self.base.package not in constants.testForceRPMS: self.base.logger.info("Skipping testing the package:" + self.base.package) return chrUtils = ChrootUtils(self.base.logName, self.base.logPath) chrootID = None try: chrootID = self.prepareBuildRoot() listInstalledPackages, listInstalledRPMs = self.base.findInstalledPackages( chrootID) listDependentPackages = self.base.findBuildTimeRequiredPackages() if constants.rpmCheck and self.base.package in constants.testForceRPMS: listDependentPackages.extend( self.base.findBuildTimeCheckRequiredPackages()) testPackages = set( constants.listMakeCheckRPMPkgtoInstall) - set( listInstalledPackages) - set([self.base.package]) listDependentPackages.extend(testPackages) listDependentPackages = list(set(listDependentPackages)) pkgUtils = PackageUtils(self.base.logName, self.base.logPath) if len(listDependentPackages) != 0: self.base.logger.info( "Installing the build time dependent packages......") for pkg in listDependentPackages: self.base.installPackage(pkgUtils, pkg, chrootID, self.base.logPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShot(chrootID, self.base.logPath) self.base.logger.info( "Finished installing the build time dependent packages......" ) pkgUtils.adjustGCCSpecs(self.base.package, chrootID, self.base.logPath) pkgUtils.buildRPMSForGivenPackage( self.base.package, chrootID, self.base.listBuildOptionPackages, self.base.pkgBuildOptionFile, self.base.logPath) self.base.logger.info("Successfully built the package:" + self.base.package) except Exception as e: self.base.logger.error("Failed while building package:" + self.base.package) self.base.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.") logFileName = os.path.join(self.base.logPath, self.base.package + ".log") fileLog = os.popen('tail -n 100 ' + logFileName).read() self.base.logger.debug(fileLog) raise e if chrootID is not None: chrUtils.destroyChroot(chrootID)