from aux import * # to be removed import os,portage import sync class CvsConnection(sync.Connection): def __init__(self, src, dest, settings): self.transtype = "cvs" self.syncuri = src[6:] if not self.syncuri[0] == ":": self.syncuri = ":"+self.syncuri self.portdir = dest self.settings = settings def setup(self): # checking for old SYNC form if self.syncuri.count(":") == 1: info("The old syntax for cvs-sync with the implicit gentoo-x86 module is") info("deprecated. Please change your make.conf to the new syntax:") info(" cvs://access:user@server:cvsroot:cvsmodule") info("(access should be \"ext\" for ssh-based CVS as used by Gentoo)") self.cvsaccess = "ext" self.cvsroot = self.syncuri self.cvsmodule = "gentoo-x86" elif self.syncuri.count(":") in [3, 4]: self.cvsaccess=self.syncuri.split(":")[1] mpos=self.syncuri.rindex(":") self.cvsmodule=self.syncuri[mpos+1:] self.cvsroot=self.syncuri[:mpos] else: warn("invalid cvs SYNC setting: cvs://%s, syntax is:" % self.syncuri) warn(" cvs://:access:user@server:cvsroot:cvsmodule") return -1 if not self.toolcheck("/usr/bin/cvs", "dev-util/cvs", quiet=False): return -1 def sync(self): cvsdir=os.path.dirname(self.portdir) if not os.path.exists(self.portdir+"/CVS"): #initial checkout msg(">>> starting initial cvs checkout with %s ...\n" % self.syncuri) if self.cvsaccess != "ext": rValue = portage.spawn("cd "+cvsdir+"; cvs -d "+self.cvsroot+" login",free=1) if rValue: warn("cvs login error [exitcode %d]; aborting." % rValue) return rValue if os.path.exists(cvsdir+"/"+self.cvsmodule): warn("existing %s/%s directory; aborting." % (cvsdir, self.cvsmodule)) return -1 rValue = portage.spawn("cd "+cvsdir+"; cvs -z0 -d "+self.cvsroot+" co "+self.cvsmodule,free=1) if rValue: warn("cvs checkout error [exitcode %d]; aborting." % rValue) return rValue if cvsdir != self.portdir: portage.movefile(cvsdir+"/"+self.cvsmodule,self.portdir) return 0 else: #cvs update msg(">>> starting cvs update with cvs://%s ..." % self.syncuri) rValue=portage.spawn("cd "+self.portdir+"; cvs -z0 -q update -dP",free=1) return rValue print "Loading cvs" sync.addTransport("cvs", CvsConnection)