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 #should initialize a logger based on package name containerTaskName = "build-" + self.base.package containerID = None chrootID = None isToolChainPackage = False if self.base.package in constants.listToolChainPackages: isToolChainPackage = True destLogPath = constants.logPath + "/build-" + self.base.package try: containerID, chrootID = self.prepareBuildContainer( containerTaskName, self.base.package, isToolChainPackage) tcUtils = ToolChainUtils(self.base.logName, self.base.logPath) if self.base.package in constants.perPackageToolChain: self.base.logger.debug( constants.perPackageToolChain[self.base.package]) tcUtils.installCustomToolChainRPMSinContainer( containerID, constants.perPackageToolChain[self.base.package], self.base.package) listInstalledPackages, listInstalledRPMs = self.base.findInstalledPackages( containerID) self.base.logger.info(listInstalledPackages) 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( "BuildContainer-buildPackage: Installing dependent packages.." ) self.base.logger.info(listDependentPackages) for pkg in listDependentPackages: self.base.installPackage(pkgUtils, pkg, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShotInContainer( containerID, destLogPath) self.base.logger.info( "Finished installing the build time dependent packages......" ) self.base.logger.info( "BuildContainer-buildPackage: Start building the package: " + self.base.package) pkgUtils.adjustGCCSpecsInContainer(self.base.package, containerID, destLogPath) pkgUtils.buildRPMSForGivenPackageInContainer( self.base.package, containerID, self.base.listBuildOptionPackages, self.base.pkgBuildOptionFile, destLogPath) self.base.logger.info( "BuildContainer-buildPackage: Successfully built the package: " + self.base.package) except Exception as e: self.base.logger.error("Failed while building package:" + self.base.package) if containerID is not None: self.base.logger.debug("Container " + containerID.short_id + " retained for debugging.") logFileName = os.path.join(destLogPath, self.base.package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.base.logger.debug(fileLog) raise e # Remove the container if containerID is not None: containerID.remove(force=True) # Remove the dummy chroot if chrootID is not None: chrUtils = ChrootUtils(self.base.logName, self.base.logPath) 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 #should initialize a logger based on package name containerTaskName = "build-" + self.package containerID = None chrootID = None isToolChainPackage = False if self.package in constants.listToolChainPackages: isToolChainPackage = True destLogPath = constants.logPath + "/build-" + self.package try: containerID, chrootID = self._prepareBuildContainer( containerTaskName, self.package, isToolChainPackage) tcUtils = ToolChainUtils(self.logName, self.logPath) if self.package in constants.perPackageToolChain: self.logger.debug(constants.perPackageToolChain[self.package]) tcUtils.installCustomToolChainRPMSinContainer( containerID, constants.perPackageToolChain[self.package], self.package) listDependentPackages, listDependentPackagesParseObj, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(containerID, index)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info("BuildContainer-buildPackage: " + "Installing dependent packages..") self.logger.info(listDependentPackages) for pkg in listDependentPackages: flag = False for objName in listDependentPackagesParseObj: if objName.package == pkg: properVersion = self._getProperVersion( pkg, objName) self._installPackage(pkgUtils, pkg, properVersion, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) flag = True break if flag == False: self._installPackage(pkgUtils, pkg, "*", containerID, destLogPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShotInContainer( containerID, destLogPath) self.logger.info( "Finished installing the build time dependent packages...." ) self.logger.info( "BuildContainer-buildPackage: Start building the package: " + self.package) pkgUtils.adjustGCCSpecsInContainer(self.package, containerID, destLogPath, index) pkgUtils.buildRPMSForGivenPackageInContainer( self.package, containerID, destLogPath, index) self.logger.info( "BuildContainer-buildPackage: Successfully built the package: " + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) if containerID is not None: self.logger.debug("Container " + containerID.short_id + " retained for debugging.") logFileName = os.path.join(destLogPath, self.package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e # Remove the container if containerID is not None: containerID.remove(force=True) # Remove the dummy chroot if chrootID is not None: chrUtils = ChrootUtils(self.logName, self.logPath) chrUtils.destroyChroot(chrootID)
def _buildPackage(self): #should initialize a logger based on package name containerTaskName = "build-" + self.package containerID = None chrootID = None isToolChainPackage = False if self.package in constants.listToolChainPackages: isToolChainPackage = True destLogPath = constants.logPath + "/build-" + self.package try: containerID, chrootID = self._prepareBuildContainer( containerTaskName, self.package, self.version, isToolChainPackage) tcUtils = ToolChainUtils(self.logName, self.logPath) if self.package in constants.perPackageToolChain: self.logger.debug(constants.perPackageToolChain[self.package]) tcUtils.installCustomToolChainRPMSinContainer( containerID, constants.perPackageToolChain[self.package].get( platform.machine(), []), self.package) listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(containerID)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info("BuildContainer-buildPackage: " + "Installing dependent packages..") self.logger.info(listDependentPackages) for pkg in listDependentPackages: packageName, packageVersion = StringUtils.splitPackageNameAndVersion( pkg) self._installPackage(pkgUtils, packageName, packageVersion, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) for pkg in listTestPackages: packageName, packageVersion = StringUtils.splitPackageNameAndVersion( pkg) flag = False for depPkg in listDependentPackages: depPackageName, depPackageVersion = StringUtils.splitPackageNameAndVersion( depPkg) if depPackageName == packageName: flag = True break if flag == False: self._installPackage(pkgUtils, packageName, packageVersion, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShotInContainer( containerID, destLogPath) self.logger.info( "Finished installing the build time dependent packages...." ) self.logger.info( "BuildContainer-buildPackage: Start building the package: " + self.package) pkgUtils.adjustGCCSpecsInContainer(self.package, self.version, containerID, destLogPath) pkgUtils.buildRPMSForGivenPackageInContainer( self.package, self.version, containerID, destLogPath) self.logger.info( "BuildContainer-buildPackage: Successfully built the package: " + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) if containerID is not None: self.logger.debug("Container " + containerID.short_id + " retained for debugging.") logFileName = os.path.join(destLogPath, self.package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e # Remove the container if containerID is not None: containerID.remove(force=True) # Remove the dummy chroot if chrootID is not None: chrUtils = ChrootUtils(self.logName, self.logPath) 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 #should initialize a logger based on package name containerTaskName = "build-" + self.package containerID = None chrootID = None isToolChainPackage = False if self.package in constants.listToolChainPackages: isToolChainPackage = True destLogPath = constants.logPath + "/build-" + self.package try: containerID, chrootID = self._prepareBuildContainer( containerTaskName, self.package, isToolChainPackage) tcUtils = ToolChainUtils(self.logName, self.logPath) if self.package in constants.perPackageToolChain: self.logger.debug(constants.perPackageToolChain[self.package]) tcUtils.installCustomToolChainRPMSinContainer( containerID, constants.perPackageToolChain[self.package], self.package) listDependentPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(containerID)) pkgUtils = PackageUtils(self.logName, self.logPath) if listDependentPackages: self.logger.info("BuildContainer-buildPackage: " + "Installing dependent packages..") self.logger.info(listDependentPackages) for pkg in listDependentPackages: self._installPackage(pkgUtils, pkg, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShotInContainer(containerID, destLogPath) self.logger.info("Finished installing the build time dependent packages....") self.logger.info("BuildContainer-buildPackage: Start building the package: " + self.package) pkgUtils.adjustGCCSpecsInContainer(self.package, containerID, destLogPath) pkgUtils.buildRPMSForGivenPackageInContainer( self.package, containerID, destLogPath) self.logger.info("BuildContainer-buildPackage: Successfully built the package: " + self.package) except Exception as e: self.logger.error("Failed while building package:" + self.package) if containerID is not None: self.logger.debug("Container " + containerID.short_id + " retained for debugging.") logFileName = os.path.join(destLogPath, self.package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e # Remove the container if containerID is not None: containerID.remove(force=True) # Remove the dummy chroot if chrootID is not None: chrUtils = ChrootUtils(self.logName, self.logPath) 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 containerTaskName = "build-" + package containerID = None isToolChainPackage = False if package in constants.listToolChainPackages: isToolChainPackage = True destLogPath = constants.logPath + "/build-" + package try: containerID = self.prepareBuildContainer(containerTaskName, package, isToolChainPackage) if not os.path.isdir(destLogPath): cmdUtils = CommandUtils() cmdUtils.runCommandInShell("mkdir -p " + destLogPath) tcUtils = ToolChainUtils(self.logName, self.logPath) if package in constants.perPackageToolChain: self.logger.debug(constants.perPackageToolChain[package]) tcUtils.installCustomToolChainRPMSinContainer( containerID, constants.perPackageToolChain[package], package) listInstalledPackages, listInstalledRPMs = self.findInstalledPackages( containerID) self.logger.info(listInstalledPackages) listDependentPackages = self.findBuildTimeRequiredPackages(package) if constants.rpmCheck and package in constants.testForceRPMS: listDependentPackages.extend( self.findBuildTimeCheckRequiredPackages(package)) testPackages = set( constants.listMakeCheckRPMPkgtoInstall) - set( listInstalledPackages) - set([package]) listDependentPackages.extend(testPackages) listDependentPackages = list(set(listDependentPackages)) pkgUtils = PackageUtils(self.logName, self.logPath) if len(listDependentPackages) != 0: self.logger.info( "BuildContainer-buildPackage: Installing dependent packages.." ) self.logger.info(listDependentPackages) for pkg in listDependentPackages: self.installPackage(pkgUtils, pkg, containerID, destLogPath, listInstalledPackages, listInstalledRPMs) # Special case sqlite due to package renamed from sqlite-autoconf to sqlite if "sqlite" in listInstalledPackages or "sqlite-devel" in listInstalledPackages or "sqlite-libs" in listInstalledPackages: if "sqlite" not in listInstalledPackages: self.installPackage(pkgUtils, "sqlite", containerID, destLogPath, listInstalledPackages, listInstalledRPMs) if "sqlite-devel" not in listInstalledPackages: self.installPackage(pkgUtils, "sqlite-devel", containerID, destLogPath, listInstalledPackages, listInstalledRPMs) if "sqlite-libs" not in listInstalledPackages: self.installPackage(pkgUtils, "sqlite-libs", containerID, destLogPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInAOneShotInContainer( containerID, destLogPath) pkgUtils.adjustGCCSpecsInContainer(package, containerID, destLogPath) pkgUtils.buildRPMSForGivenPackageInContainer( package, containerID, self.listBuildOptionPackages, self.pkgBuildOptionFile, destLogPath) self.logger.info( "BuildContainer-buildPackage: Successfully built the package: " + package) except Exception as e: self.logger.error("Failed while building package:" + package) if containerID is not None: self.logger.debug("Container " + containerID.short_id + " retained for debugging.") logFileName = os.path.join(destLogPath, package + ".log") fileLog = os.popen('tail -n 20 ' + logFileName).read() self.logger.debug(fileLog) raise e # Remove the container if containerID is not None: containerID.remove(force=True)