Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Response: Check that cvs checkout is against the correct repository #423

Merged
merged 6 commits into from May 20, 2012
@@ -184,13 +184,15 @@ def setupProperties(self):
def setupSlaveBuilder(self, slavebuilder):
self.slavebuilder = slavebuilder
+ self.path_module = slavebuilder.slave.path_module
+
# navigate our way back to the L{buildbot.buildslave.BuildSlave}
# object that came from the config, and get its properties
buildslave_properties = slavebuilder.slave.properties
self.getProperties().updateFromProperties(buildslave_properties)
if slavebuilder.slave.slave_basedir:
self.setProperty("workdir",
- slavebuilder.slave.path_module.join(
+ self.path_module.join(
slavebuilder.slave.slave_basedir,
self.builder.config.slavebuilddir),
"slave")
@@ -20,6 +20,7 @@
from twisted.internet import defer
from buildbot.process import buildstep
+from buildbot.steps.shell import StringFileWriter
from buildbot.steps.source.base import Source
from buildbot.interfaces import BuildSlaveTooOldError
@@ -72,7 +73,7 @@ def incremental(self):
if updatable:
rv = yield self.doUpdate()
else:
- rv = yield self.doCheckout(self.workdir)
+ rv = yield self.clobber()
defer.returnValue(rv)
@defer.inlineCallbacks
@@ -161,13 +162,13 @@ def evaluate(rc):
return d
def doCheckout(self, dir):
- command = ['-d', self.cvsroot, '-z3', 'checkout', '-d', dir,
- self.cvsmodule]
+ command = ['-d', self.cvsroot, '-z3', 'checkout', '-d', dir ]
command = self.global_options + command + self.extra_options
if self.branch:
command += ['-r', self.branch]
if self.revision:
command += ['-D', self.revision]
+ command += [ self.cvsmodule ]
d = self._dovccmd(command, '')
return d
@@ -221,17 +222,40 @@ def evaluateCommand(cmd):
d.addCallback(lambda _: evaluateCommand(cmd))
return d
+ @defer.inlineCallbacks
def _sourcedirIsUpdatable(self):
- cmd = buildstep.RemoteCommand('stat', {'file': self.workdir + '/CVS',
- 'logEnviron': self.logEnviron})
- cmd.useLog(self.stdio_log, False)
- d = self.runCommand(cmd)
- def _fail(tmp):
- if cmd.rc != 0:
- return False
- return True
- d.addCallback(_fail)
- return d
+ myFileWriter = StringFileWriter()
+ args = {
+ 'workdir': self.build.path_module.join(self.workdir, 'CVS'),
+ 'writer': myFileWriter,
+ 'maxsize': None,
+ 'blocksize': 32*1024,
+ }
+
+ cmd = buildstep.RemoteCommand('uploadFile',
+ dict(slavesrc='Root', **args),
+ ignore_updates=True)
+ yield self.runCommand(cmd)
+ if cmd.rc is not None and cmd.rc != 0:
+ defer.returnValue(False)
+ return
+ if myFileWriter.buffer.strip() != self.cvsroot:
+ defer.returnValue(False)
+ return
+
+ myFileWriter.buffer = ""
+ cmd = buildstep.RemoteCommand('uploadFile',
+ dict(slavesrc='Repository', **args),
+ ignore_updates=True)
+ yield self.runCommand(cmd)
+ if cmd.rc is not None and cmd.rc != 0:
+ defer.returnValue(False)
+ return
+ if myFileWriter.buffer.strip() != self.cvsmodule:
+ defer.returnValue(False)
+ return
+
+ defer.returnValue(True)
def parseGotRevision(self, res):
revision = time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())
@@ -14,6 +14,7 @@
# Copyright Buildbot Team Members
import mock
+import posixpath
from twisted.python import components
from buildbot.process import properties
from buildbot import interfaces
@@ -34,6 +35,7 @@ class FakeBuild(mock.Mock, properties.PropertiesMixin):
def __init__(self, *args, **kwargs):
mock.Mock.__init__(self, *args, **kwargs)
self.build_status = FakeBuildStatus()
+ self.path_module = posixpath
pr = self.build_status.properties = properties.Properties()
pr.build = self
Oops, something went wrong.