Ticket #333: buildbot-0.7.8-FtpTar.patch
| File buildbot-0.7.8-FtpTar.patch, 8.4 kB (added by dtrosset, 5 months ago) |
|---|
-
old-buildbot/buildbot/slave/commands.py
old new 2 2 3 3 import os, re, signal, shutil, types, time 4 4 from stat import ST_CTIME, ST_MTIME, ST_SIZE 5 from ftplib import FTP 5 6 6 7 from zope.interface import implements 7 8 from twisted.internet.protocol import ProcessProtocol … … 1603 1604 1604 1605 registerSlaveCommand("svn", SVN, command_version) 1605 1606 1607 class FtpTar(SourceBase): 1608 """FTP and untar operation. In addition to the arguments 1609 handled by SourceBase, this command reads the following keys: 1610 1611 ['ftphost'] (required): the FTP hostname 1612 ['ftpfile'] (required): the FTP file to download 1613 ['ftpuser'] (required): the FTP username 1614 ['ftppass'] (required): the FTP password 1615 ['striplevel'] (optional): the argument given to 'tar --strip %d' 1616 """ 1617 1618 header = "ftptar operation" 1619 1620 def setup(self, args): 1621 SourceBase.setup(self, args) 1622 self.tarexe = getCommand("tar") 1623 self.ftphost = args['ftphost'] 1624 self.ftpfile = args['ftpfile'] 1625 self.ftpuser = args['ftpuser'] 1626 self.ftppass = args['ftppass'] 1627 self.striplevel = args['striplevel'] 1628 self.sourcedata = "%s\n" % self.ftpfile 1629 1630 def sourcedirIsUpdateable(self): 1631 return False 1632 1633 def doVCFull(self): 1634 # Delete and create ftp download directory 1635 dd = os.path.join(self.builder.basedir, 'ftp') 1636 if os.path.isdir(dd): 1637 rmdirRecursive(dd) 1638 os.mkdir(dd) 1639 # Download the file 1640 ftp = FTP(self.ftphost) 1641 if self.ftpuser and self.ftppass: 1642 ftp.login(self.ftpuser, self.ftppass) 1643 f = os.path.join(dd, os.path.basename(self.ftpfile)) 1644 ftp.retrbinary('RETR '+self.ftpfile, open(f, 'wb').write) 1645 ftp.quit() 1646 # Create build directory 1647 db = os.path.join(self.builder.basedir, self.srcdir) 1648 os.mkdir(db) 1649 # Untar source in build directory 1650 striplevel = '%s' % (self.striplevel or 1) 1651 command = [self.tarexe, 'axvf', f, '--strip', striplevel] 1652 c = ShellCommand(self.builder, command, db, 1653 sendRC=False, timeout=self.timeout, 1654 keepStdout=True) 1655 self.command = c 1656 return c.start() 1657 1658 def parseGotRevision(self): 1659 return None 1660 1661 1662 registerSlaveCommand("ftptar", FtpTar, command_version) 1663 1606 1664 class Darcs(SourceBase): 1607 1665 """Darcs-specific VC operation. In addition to the arguments 1608 1666 handled by SourceBase, this command reads the following keys: -
old-buildbot/buildbot/steps/source.py
old new 473 473 self.startCommand(cmd, warnings) 474 474 475 475 476 class FtpTar(Source): 477 """I perform FTP download and decompression of a tar source archive file. 478 """ 479 480 name = 'ftptar' 481 482 def __init__(self, ftphost=None, ftpuser=None, ftppass=None, ftpfile=None, 483 striplevel=None, directory=None, **kwargs): 484 """ 485 @type ftphost: string 486 @param ftphost: hostname of the FTP server to connect to. 487 488 @type ftpfile: string 489 @param ftpfile: full path to the file to retreive from FTP server. On 490 slave, only the last path component of this path will 491 be used. 492 493 @type ftpuser: string 494 @param ftpuser: username to use for logging on the FTP server. 495 496 @type ftphost: string 497 @param ftphost: password to use for logging on the FTP server. 498 499 @type striplevel: integer 500 @param striplevel: Number of directories that must be removed from 501 the filenames extracted form the archive. It 502 defaults to 1, usually stripping the name-X.y.z/ 503 part of the files extracted, thus providing a 504 Makefile directly in the build directory. 505 506 """ 507 508 if not kwargs.has_key('workdir') and directory is not None: 509 # deal with old configs 510 warn("Please use workdir=, not directory=", DeprecationWarning) 511 kwargs['workdir'] = directory 512 513 self.ftphost = ftphost 514 self.ftpfile = ftpfile 515 self.ftpuser = ftpuser 516 self.ftppass = ftppass 517 self.striplevel = striplevel 518 519 Source.__init__(self, **kwargs) 520 self.addFactoryArguments(ftphost=ftphost, 521 ftpfile=ftpfile, 522 ftpuser=ftpuser, 523 ftppass=ftppass, 524 striplevel=striplevel, 525 directory=directory, 526 ) 527 528 if not ftpfile or not ftphost: 529 raise ValueError("you must specify ftphost and ftpfile") 530 531 532 def computeSourceRevision(self, changes): 533 return None 534 535 def startVC(self, branch, revision, patch): 536 537 warnings = [] 538 539 if self.args['mode'] != "update": 540 warnings.append("WARNING: FtpTar slave can only do full retreival" 541 ", do not specify mode other than update") 542 543 self.args['ftphost'] = self.ftphost 544 self.args['ftpfile'] = self.ftpfile 545 self.args['ftpuser'] = self.ftpuser 546 self.args['ftppass'] = self.ftppass 547 self.args['striplevel'] = self.striplevel 548 self.args['revision'] = revision 549 self.args['patch'] = patch 550 551 revstuff = [] 552 if branch is not None and branch != self.branch: 553 revstuff.append("[branch]") 554 if revision is not None: 555 revstuff.append("r%s" % revision) 556 if patch is not None: 557 revstuff.append("[patch]") 558 self.description.extend(revstuff) 559 self.descriptionDone.extend(revstuff) 560 561 cmd = LoggedRemoteCommand("ftptar", self.args) 562 self.startCommand(cmd, warnings) 563 564 476 565 class Darcs(Source): 477 566 """Check out a source tree from a Darcs repository at 'repourl'. 478 567 -
old-buildbot/docs/buildbot.texinfo
old new 207 207 * Bzr:: 208 208 * P4:: 209 209 * Git:: 210 * FtpTar:: 210 211 211 212 Simple ShellCommand Subclasses 212 213 … … 4388 4389 * Bzr:: 4389 4390 * P4:: 4390 4391 * Git:: 4392 * FtpTar:: 4391 4393 @end menu 4392 4394 4393 4395 @node CVS, SVN, Source Checkout, Source Checkout … … 4763 4765 @end table 4764 4766 4765 4767 4766 @node Git, , P4, Source Checkout4768 @node Git, FtpTar, P4, Source Checkout 4767 4769 @subsubsection Git 4768 4770 4769 4771 @cindex Git Checkout … … 4789 4791 @end table 4790 4792 4791 4793 4794 @node FtpTar, , Git, Source Checkout 4795 @subsubsection FtpTar 4796 @cindex CVS Checkout 4797 @bsindex buildbot.steps.source.FtpTar 4798 4799 4800 The @code{FtpTar} build step performs a download of a specified file from 4801 an FTP server (usually a source archive), and untar it into a build 4802 directory, just as it could have bee got from another VCS operation. 4803 4804 The FtpTar step does not use the mode argument. It should be left to the 4805 default update mode, despite it generates a new source tree at each build. 4806 4807 The FtpTar step takes the following arguments: 4808 4809 @table @code 4810 @item ftphost 4811 (required): The hostname of the FTP server to connect to. 4812 4813 @item ftpfile 4814 (required): The full path to the file to dowload from the FTP server. The FTP 4815 download is done using image (binary) mode. 4816 4817 @item ftpuser 4818 (optional): The username to use for logging on the FTP server. 4819 4820 @item ftppass 4821 (optional): The password to use for logging on the FTP server. 4822 4823 @item striplevel 4824 (optional): The number of directory names to remove from the path of the 4825 files extracted form the archive. It defaults to 1, which usually strips the 4826 name-X.y.z/ part of the files extracted, providing a Makefile directly in 4827 the build directory. 4828 4829 @end table 4830 4831 4832 4792 4833 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps 4793 4834 @subsection ShellCommand 4794 4835
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)