Пример #1
0
    def _buildPackage(self):
        try:
            self.sandbox.create(self.package + "-" + self.version)

            tUtils = ToolChainUtils(self.logName, self.logPath)
            if self.sandbox.hasToolchain():
                tUtils.installCustomToolChainRPMS(self.sandbox, self.package, self.version)
            else:
                tUtils.installToolChainRPMS(self.sandbox, self.package, self.version)

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

            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, self.sandbox, 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, self.sandbox, self.logPath,listInstalledPackages, listInstalledRPMs)
                pkgUtils.installRPMSInOneShot(self.sandbox)
                self.logger.debug("Finished installing the build time dependent packages....")

            pkgUtils.adjustGCCSpecs(self.sandbox, self.package, self.version)
            pkgUtils.buildRPMSForGivenPackage(self.sandbox, self.package, self.version,
                                              self.logPath)
            self.logger.debug("Successfully built the package: " + self.package)
        except Exception as e:
            self.logger.error("Failed while building package: " + self.package)
            self.logger.debug("Sandbox: " + self.sandbox.getID() +
                              " not deleted for debugging.")
            logFileName = os.path.join(self.logPath, self.package + ".log")
            fileLog = os.popen('tail -n 100 ' + logFileName).read()
            self.logger.info(fileLog)
            raise e
        if self.sandbox:
            self.sandbox.destroy()
Пример #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()