""" A buildroot based on rsync and 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 # this class needs YumBasedBuildRoot from log4py import Logger import yumbasedbuildroot from buildroot import BuildRoot import buildrootresult import os.path #from specfile import SpecFile class RsyncYumBasedBuildRoot(BuildRoot): def __init__(self,buildRootTag): self.__cat = Logger().get_instance(self) self.__cat.debug("start") self.__yumBuildRoot = yumbasedbuildroot.YumBasedBuildRoot(buildRootTag) self._setBuildRootTag(buildRootTag) self.__needsRebuild = True def cleanRoot(self): self.__cat.debug("start, nothing to do") return buildrootresult.BuildRootResult(self) def setUseCacheOnly(self,bVar): self.__yumBuildRoot.setUseCacheOnly(bVar) # this prepares a buildroot so it can be used for building an rpm # this calls cleanRoot if needed # this creates the buildRoot from scratch if needed # the result is a BuildRootResult object def prepareRoot(self): self.__cat.debug("start") brr = buildrootresult.BuildRootResult(self) # is there a buildroot saved with rsync which can be used to recreate the buildroot for the YumBasedBuildRoot ? if self.__needsRebuild: self.__cat.debug("root needs a rebuild") cmd = "sudo rm -Rf " + self.__yumBuildRoot.rootdir + " " + self.__yumBuildRoot.rootdir + "-rsync" self.__yumBuildRoot.logCommand(cmd,brr) self.__needsRebuild = False if os.path.exists(self.__yumBuildRoot.rootdir + "-rsync"): # ok rsync self.__yumBuildRoot._umounts(brr) cmd = "sudo rsync -a -W -H --numeric-ids --delete " + self.__yumBuildRoot.rootdir + "-rsync/ " + self.__yumBuildRoot.rootdir + "/" self.__cat.debug("cmd: " + cmd) self.__yumBuildRoot.logCommand(cmd,brr) else: # ok create first and rsync in the other direction self.__yumBuildRoot.cleanRoot() self.__yumBuildRoot.prepareRoot() self.__yumBuildRoot._umounts(brr) os.mkdir(self.__yumBuildRoot.rootdir + "-rsync") cmd = "sudo rsync -a -W -H --numeric-ids --delete " + self.__yumBuildRoot.rootdir + "/ " + self.__yumBuildRoot.rootdir + "-rsync/" self.__cat.debug("cmd: " + cmd) self.__yumBuildRoot.logCommand(cmd,brr) return brr def buildRpm(self,command): self.__cat.debug("start") brr = buildrootresult.BuildRootResult(self) self.__yumBuildRoot._umounts(brr) self.__yumBuildRoot._mounts(brr) retval = self.__yumBuildRoot.buildRpm(command) self.__yumBuildRoot._umounts(brr) return retval def installRpms(self,rpms): self.__cat.debug("start") brr = self.__yumBuildRoot.installRpms(rpms) if brr.containsErrors(): self.__needsRebuild = True return brr