def _buildPackage(self): chroot = None try: chroot = Chroot(self.logger) chroot.create(self.package + "-" + self.version) tUtils = ToolChainUtils(self.logName, self.logPath) tUtils.installToolChainRPMS(chroot, self.package, self.version, self.logPath) listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = ( self._findDependentPackagesAndInstalledRPM(chroot)) 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, chroot, 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, chroot, self.logPath, listInstalledPackages, listInstalledRPMs) pkgUtils.installRPMSInOneShot(chroot) self.logger.debug( "Finished installing the build time dependent packages...." ) pkgUtils.adjustGCCSpecs(chroot, self.package, self.version) pkgUtils.buildRPMSForGivenPackage(chroot, 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("Chroot: " + chroot.getPath() + " 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 chroot: chroot.destroy()
def createBuildContainer(self): self.logger.info("Generating photon build container..") try: #TODO image name constants.buildContainerImageName self.dockerClient.images.remove("photon_build_container:latest", 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 chrootID = None try: #TODO: constants.tcrootname chrUtils = ChrootUtils("toolchain-chroot", self.logPath) returnVal, chrootID = chrUtils.createChroot("toolchain-chroot") self.logger.debug("Created tool-chain chroot: " + chrootID) if not returnVal: raise Exception("Unable to prepare tool-chain chroot") tcUtils = ToolChainUtils("toolchain-chroot", self.logPath) tcUtils.installToolChainRPMS(chrootID, "dummy") except Exception as e: if chrootID is not None: self.logger.debug("Deleting chroot: " + chrootID) chrUtils.destroyChroot(chrootID) raise e self.logger.info("VDBG-PU-createBuildContainer: chrootID: " + chrootID) # Create photon build container using toolchain chroot #TODO: Coalesce logging cmdUtils = CommandUtils() cmd = "./umount-build-root.sh " + chrootID cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot1.log") cmd = "cd " + chrootID + " && tar -czvf ../tcroot.tar.gz ." cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot2.log") cmd = "mv " + chrootID + "/../tcroot.tar.gz ." cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot3.log") #TODO: Container name, docker file name from constants. self.dockerClient.images.build( tag="photon_build_container:latest", path=".", rm=True, dockerfile="Dockerfile.photon_build_container") # Cleanup cmd = "rm -f ./tcroot.tar.gz" cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot4.log") chrUtils.destroyChroot(chrootID) self.logger.info("Photon build container successfully created.")
def prepareBuildRoot(self, chrootName, packageName): chrootID = None try: chrUtils = ChrootUtils(self.logName, self.logPath) returnVal, chrootID = chrUtils.createChroot(chrootName) self.logger.debug("Created new chroot: " + chrootID) if not returnVal: raise Exception("Unable to prepare build root") tUtils = ToolChainUtils(self.logName, self.logPath) tUtils.installToolChainRPMS(chrootID, packageName) except Exception as e: if chrootID is not None: self.logger.debug("Deleting chroot: " + chrootID) chrUtils.destroyChroot(chrootID) raise e return chrootID
def prepareBuildRoot(self,chrootName, packageName): chrootID=None try: chrUtils = ChrootUtils(self.logName,self.logPath) returnVal,chrootID = chrUtils.createChroot(chrootName) self.logger.debug("Created new chroot: " + chrootID) if not returnVal: raise Exception("Unable to prepare build root") tUtils=ToolChainUtils(self.logName,self.logPath) tUtils.installToolChainRPMS(chrootID, packageName) except Exception as e: if chrootID is not None: self.logger.debug("Deleting chroot: " + chrootID) chrUtils.destroyChroot(chrootID) raise e return chrootID
def _createBuildContainer(self): self.logger.info("Generating photon build container..") try: #TODO image name constants.buildContainerImageName self.dockerClient.images.remove("photon_build_container:latest", 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 chrootID = None try: #TODO: constants.tcrootname chrUtils = ChrootUtils("toolchain-chroot", self.logPath) returnVal, chrootID = chrUtils.createChroot("toolchain-chroot") self.logger.debug("Created tool-chain chroot: " + chrootID) if not returnVal: raise Exception("Unable to prepare tool-chain chroot") tcUtils = ToolChainUtils("toolchain-chroot", self.logPath) tcUtils.installToolChainRPMS(chrootID, "dummy") except Exception as e: if chrootID is not None: self.logger.debug("Deleting chroot: " + chrootID) chrUtils.destroyChroot(chrootID) raise e self.logger.info("VDBG-PU-createBuildContainer: chrootID: " + chrootID) # Create photon build container using toolchain chroot #TODO: Coalesce logging cmdUtils = CommandUtils() cmd = "./umount-build-root.sh " + chrootID cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot1.log") cmd = "cd " + chrootID + " && tar -czvf ../tcroot.tar.gz ." cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot2.log") cmd = "mv " + chrootID + "/../tcroot.tar.gz ." cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot3.log") #TODO: Container name, docker file name from constants. self.dockerClient.images.build(tag="photon_build_container:latest", path=".", rm=True, dockerfile="Dockerfile.photon_build_container") # Cleanup cmd = "rm -f ./tcroot.tar.gz" cmdUtils.runCommandInShell(cmd, self.logPath + "/toolchain-chroot4.log") chrUtils.destroyChroot(chrootID) self.logger.info("Photon build container successfully created.")
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.")