Esempio n. 1
0
    def _buildPackagePrepareFunction(self, package, version, doneList):
        self.package = package
        self.version = version
        self.logName = "build-" + package + "-" + version
        self.logPath = constants.logPath + "/" + package + "-" + version
        if not os.path.isdir(self.logPath):
            cmdUtils = CommandUtils()
            cmdUtils.runCommandInShell("mkdir -p " + self.logPath)
        self.logger = Logger.getLogger(self.logName, self.logPath, constants.logLevel)
        self.doneList = doneList

        if self.sandboxType == "chroot":
            sandbox = Chroot(self.logger)
        elif self.sandboxType == "container":
            sandbox = Container(self.logger)
        else:
            raise Exception("Unknown sandbox type: " + sandboxType)

        self.sandbox = sandbox
Esempio n. 2
0
    def _buildPackage(self):
        #should initialize a logger based on package name
        containerTaskName = "build-" + self.package + "-" + self.version
        container = None
        try:
            container = Container(self.logger)
            container.create(containerTaskName)

            tcUtils = ToolChainUtils(self.logName, self.logPath)
            tcUtils.installCustomToolChainRPMS(container, self.package,
                                               self.version)

            listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = (
                self._findDependentPackagesAndInstalledRPM(container))

            pkgUtils = PackageUtils(self.logName, self.logPath)

            if listDependentPackages:
                self.logger.debug(
                    "Installing the build time dependent packages......")
                for pkg in listDependentPackages:
                    packageName, packageVersion = StringUtils.splitPackageNameAndVersion(
                        pkg)
                    self._installPackage(pkgUtils, packageName, packageVersion,
                                         container, 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, container,
                                             self.logPath,
                                             listInstalledPackages,
                                             listInstalledRPMs)
                pkgUtils.installRPMSInOneShot(container)
                self.logger.debug(
                    "Finished installing the build time dependent packages...."
                )

            self.logger.debug(
                "BuildContainer-buildPackage: Start building the package: " +
                self.package)
            pkgUtils.adjustGCCSpecs(container, self.package, self.version)
            pkgUtils.buildRPMSForGivenPackage(container, self.package,
                                              self.version, self.logPath)
            self.logger.debug(
                "BuildContainer-buildPackage: Successfully built the package: "
                + self.package)
        except Exception as e:
            self.logger.error("Failed while building package:" + self.package)
            if container is not None:
                self.logger.debug("Container " + container.getID() +
                                  " retained for debugging.")
            logFileName = os.path.join(self.logPath, self.package + ".log")
            fileLog = os.popen('tail -n 20 ' + logFileName).read()
            self.logger.debug(fileLog)
            raise e

        # Remove the container
        if container:
            container.destroy()