""" A buildroot based on yum """ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2004 Dries Verachtert import getopt, os, sys, Queue, posix, posixpath, string, re, os.path, shutil, commands from log4py import Logger from buildroot import BuildRoot from buildrootresult import BuildRootResult import config #from specfile import SpecFile class YumBasedBuildRoot(BuildRoot): def __init__(self,buildRootTag): self._cat = Logger().get_instance(self) brr = BuildRootResult(self) self.__config = config.Config.getInstance() self._setBuildRootTag( buildRootTag) self.__setVars(brr) self._cat.debug("initialized") self.__useCacheOnly = False #return brr def __setVars(self,brr): self.yumConfFile = "/etc/pydar2/yum/" + self.__config.getBuildMachineId() + "/" + self.getBuildRootTag() + ".conf" if os.path.exists(self.yumConfFile): self._cat.debug("using userdefined yum conf: " + self.yumConfFile) else: self.yumConfFile = "/etc/pydar2/yum/" + self.getBuildRootTag() + ".conf" self._cat.debug("using normal yum conf: " + self.yumConfFile) self.yumCacheDir = "/var/lib/pydar2/yum/cache/" + self.getBuildRootTag() self.rootdir = "/var/lib/pydar2/roots/yum-" + self.getBuildRootTag() self._setGeneralVars() brr.logDebugLine("rootdir:" + self.rootdir) def installRpms(self,builddepsarr): brr = BuildRootResult(self) # todo auto remove all deps which are already installed , not only perl if len(builddepsarr) > 0 and not (len(builddepsarr) == 1 and builddepsarr[0] == "perl"): commandpart = "" for b in builddepsarr: commandpart = commandpart + " " + b cacheParam = "" if self.__useCacheOnly: cacheParam = " -C " cmd = "sudo yum " + cacheParam + " -c " + self.yumConfFile + " -y -t --installroot=" + self.rootdir + " install " + commandpart self.logCommand(cmd,brr) return brr # makes a new root def prepareRoot(self): brr = BuildRootResult(self) cmd = self._getGeneralPrepareRootCommands() # use a central yum cache cmd.append("sudo mkdir -p " + self.yumCacheDir) cmd.append("sudo ln -s " + self.yumCacheDir + " " + self.rootdir + "/var/cache/yum") # install the rpms cacheParam = "" if self.__useCacheOnly: cacheParam = " -C " if self.minimalRpmsPart1 != "": cmd.append("sudo yum " + cacheParam + " -c " + self.yumConfFile + " -y -t --installroot=" + self.rootdir + " install " + self.minimalRpmsPart1) if self.minimalRpmsPart2 != "": cmd.append("sudo yum " + cacheParam + " -c " + self.yumConfFile + " -y -t --installroot=" + self.rootdir + " install " + self.minimalRpmsPart2) if self.minimalRpmsPart3 != "": cmd.append("sudo yum " + cacheParam + " -c " + self.yumConfFile + " -y -t --installroot=" + self.rootdir + " install " + self.minimalRpmsPart3) if self.minimalRpmsPart4 != "": cmd.append("sudo yum " + cacheParam + " -c " + self.yumConfFile + " -y -t --installroot=" + self.rootdir + " install " + self.minimalRpmsPart4) cmd.append("sudo chmod -R a+rwx " + self.rootdir + "/usr/src/redhat/ " + self.rootdir + "/home/pydar2slave ") self.logCommands(cmd,brr) return brr ## tests #myRoot = YumBasedBuildRoot("","fedora-3-i386-core") #myRoot.cleanRoot() #myRoot.prepareRoot() #spec = SpecFile('/home/dries/projects/rap-svn/svn/trunk/rpms/aldo/aldo.spec',' --define "fc3 1" ') #myRoot.installRpms(spec.getBuildRequires()) ##myRoot. #print myRoot.logText