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

            tUtils = ToolChainUtils(self.logName, self.logPath)
            if self.sandbox.hasToolchain():
                tUtils.installExtraToolchainRPMS(self.sandbox, self.package,
                                                 self.version)
            else:
                tUtils.installToolchainRPMS(self.sandbox,
                                            self.package,
                                            self.version,
                                            availablePackages=self.doneList)

            self._installDependencies(constants.buildArch)
            if constants.crossCompiling:
                self._installDependencies(constants.targetArch)

            pkgUtils = PackageUtils(self.logName, self.logPath)
            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):
        try:
            self.sandbox.create(self.package + "-" + self.version)

            tUtils = ToolChainUtils(self.logName, self.logPath)
            if self.sandbox.hasToolchain():
                tUtils.installExtraToolchainRPMS(self.sandbox, self.package, self.version)
            else:
                tUtils.installToolchainRPMS(self.sandbox, self.package, self.version, availablePackages=self.doneList)

            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()
Пример #3
0
    def _createBuildContainer(self, usePublishedRPMs):
        self.logger.debug("Generating photon build container..")
        try:
            #TODO image name constants.buildContainerImageName
            self.dockerClient.images.remove(constants.buildContainerImage,
                                            force=True)
        except Exception as e:
            #TODO - better handling
            self.logger.debug("Photon build container image not found.")

        # Create toolchain chroot and install toolchain RPMs
        chroot = None
        try:
            #TODO: constants.tcrootname
            chroot = Chroot(self.logger)
            chroot.create("toolchain-chroot")
            tcUtils = ToolChainUtils("toolchain-chroot", self.logPath)
            tcUtils.installToolchainRPMS(chroot,
                                         usePublishedRPMS=usePublishedRPMs)
        except Exception as e:
            if chroot:
                chroot.destroy()
            raise e
        self.logger.debug("createBuildContainer: " + chroot.getID())

        # Create photon build container using toolchain chroot
        chroot.unmountAll()
        #TODO: Coalesce logging
        cmdUtils = CommandUtils()
        cmd = "cd " + chroot.getID() + " && tar -czf ../tcroot.tar.gz ."
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        cmd = "mv " + chroot.getID() + "/../tcroot.tar.gz ."
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        #TODO: Container name, docker file name from constants.
        self.dockerClient.images.build(
            tag=constants.buildContainerImage,
            path=".",
            rm=True,
            dockerfile="Dockerfile.photon_build_container")

        # Cleanup
        cmd = "rm -f ./tcroot.tar.gz"
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        chroot.destroy()
        self.logger.debug("Photon build container successfully created.")
Пример #4
0
    def _createBuildContainer(self, usePublishedRPMs):
        self.logger.debug("Generating photon build container..")
        try:
            #TODO image name constants.buildContainerImageName
            self.dockerClient.images.remove(constants.buildContainerImage, force=True)
        except Exception as e:
            #TODO - better handling
            self.logger.debug("Photon build container image not found.")

        # Create toolchain chroot and install toolchain RPMs
        chroot = None
        try:
            #TODO: constants.tcrootname
            chroot = Chroot(self.logger)
            chroot.create("toolchain-chroot")
            tcUtils = ToolChainUtils("toolchain-chroot", self.logPath)
            tcUtils.installToolchainRPMS(chroot, usePublishedRPMS=usePublishedRPMs)
        except Exception as e:
            if chroot:
                chroot.destroy()
            raise e
        self.logger.debug("createBuildContainer: " + chroot.getID())

        # Create photon build container using toolchain chroot
        chroot.unmountAll()
        #TODO: Coalesce logging
        cmdUtils = CommandUtils()
        cmd = "cd " + chroot.getID() + " && tar -czf ../tcroot.tar.gz ."
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        cmd = "mv " + chroot.getID() + "/../tcroot.tar.gz ."
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        #TODO: Container name, docker file name from constants.
        self.dockerClient.images.build(tag=constants.buildContainerImage,
                                       path=".",
                                       rm=True,
                                       dockerfile="Dockerfile.photon_build_container")

        # Cleanup
        cmd = "rm -f ./tcroot.tar.gz"
        cmdUtils.runCommandInShell(cmd, logfn=self.logger.debug)
        chroot.destroy()
        self.logger.debug("Photon build container successfully created.")