示例#1
0
def checkoutNoPysvn(dir, repo="trunk", revision="HEAD", incremental=False, keepLocalMods=False):
  url = baseurl + repo

  log.info("checkoutNoPysvn: checking out repo '%s' at revision '%s' incremental: %s keepLocalMods: %s", 
           repo, revision, incremental, keepLocalMods)

  if incremental:
    if not os.path.exists(dir) or not os.path.isdir(dir):
      log.error("checkout: %s does not exist or is not a directory", dir);
      raise Exception()
    try:
      actualUrl = utils.backquote("svn info %s | grep URL | awk '{print $2}'" % dir)
    except:
      log.error("checkout: unable to get svn info from directory %s", dir)
      raise Exception()
    if actualUrl != url:
      log.error("checkout: subversion url does not match for directory %s", dir)
      log.error("checkout: expected: %s", url)
      log.error("checkout: got: %s", actualUrl)
      raise Exception()

    clean(dir, doCleanup=(not keepLocalMods))
    log.info("Updating tree to revision %s", revision)
    utils.runCommand("svn update -r %s %s" % (revision, dir))
    if not keepLocalMods:
      try:
        # Throws an exception if it is not completely clean
        verify(dir)
      except:
        log.warn("Verification of repository failed. Trying one more clean/update cycle")
        clean(dir, doCleanup=True)
        log.info("Updating tree to revision %s", revision)
        utils.runCommand("svn update -r %s %s" % (revision, dir))
        verify(dir)
  else:
    # not incremental
    if os.path.exists(dir):
      log.error("checkout: directory %s already exists. Full checkout requested", dir)
      raise Exception()
    log.info("Doing fresh checkout of repo '%s' into directory '%s'", 
             repo, revision)
    utils.runCommand("svn checkout -r %s %s %s" % (revision, url, dir))
示例#2
0
def getRevisionNoPysvn(dir):
  revisionnum = utils.backquote("svn info %s | grep Revision: | awk '{print $2}'" % dir)
  return int(revisionnum)
示例#3
0
def getHeadRevisionNoPysvn(dir):
  revisionnum = utils.backquote("svn info -r HEAD %s | grep 'Last Changed Rev': | awk '{print $4}'" % dir)
  return int(revisionnum)
示例#4
0
def buildPlugins(binaryTarball, pluginTarball, srcDir, integrateScript=None, pluginList=None):
  """
  Test a plugin source release by
  1. extract binary tarball
  2. extract algorithm source tarball
  3. integrate test code into algorithm source tarball
     if integrate script is not None, run:  integrateScript algorithmSrcDir srcDir
  4. build from algorithm source and install into binary release
  4a. move all plugins from lib to testlib directory in binary release

  @param binaryTarball   Absolute pathname to the binary tarball
  @param pluginTarball   Absolute path to plugin source release tarball
  @param srcDir          Absolute path to source tree (where tests may reside)
  @param integrateScript Script for integrating test code into algorithm source directory
  @param testlist        Name of testlist. If None, no tests are performed. 
  @param short           If True, short version of tests is run
  @param pluginList      File containing a list of directories that will be integrated into the source
                         Must be set if integrateScript is set
  @retval                tuple of (binaryDir, tmpDir)
                         binaryDir is in tmpDir; tmpDir must be deleted by called
  """
  # XXX PORT FOR WINDOWS
  # METHOD IS CURRENTLY UNUSED?
  if integrateScript is not None:
    assert os.path.exists(integrateScript), "integrateScript '%s' does not exist" % integrateScript
    assert pluginList is not None
    assert os.path.exists(pluginList), "pluginList '%s' does not exist" % pluginList

  tmpDir = utils.backquote("mktemp -d -q /tmp/plugin_test.XXXXXX")
  binaryDir = utils.extractArchive(binaryTarball, tmpDir)
  pluginSrcDir = utils.extractArchive(pluginTarball, tmpDir)



  try:
    # Move the original plugins out of the way. Save them in case we want to use t hem. 
    libDir = os.path.join(binaryDir, "lib")
    origPluginDir = os.path.join(binaryDir, "origLib")
    os.mkdir(origPluginDir)
    for file in os.listdir(libDir):
      (base, ext) = os.path.splitext(file)
      if ext == ".so" or ext == ".dylib":
        os.rename(os.path.join(libDir, file),
                  os.path.join(origPluginDir, file))

    if integrateScript is not None:
      command = ["python", integrateScript, pluginSrcDir, srcDir, pluginList]
      utils.runCommand(command)
      
    buildDir = os.path.join(tmpDir, "build")
    os.mkdir(buildDir)
    if integrateScript is not None:
      utils.changeDir(pluginSrcDir)
      command = "/bin/sh autogen.sh"
      utils.runCommand(command)
    
    # configure
    utils.changeDir(buildDir)
    command = "%s/configure --prefix=%s" % (pluginSrcDir, binaryDir)
    utils.runCommand(command)

    # build
    command = "make -k install"
    utils.runCommand(command)

    # With an integrate script, put all the plugins in a "testLib" directory
    # and let the tests copy in the plugins they need
    if integrateScript is not None:
      testPluginDir = os.path.join(binaryDir, "testLib")
      os.mkdir(testPluginDir)
      for file in os.listdir(libDir):
        (base, ext) = os.path.splitext(file)
        if ext == ".so" or ext == ".dylib":
          os.rename(os.path.join(libDir, file),
                    os.path.join(testPluginDir, file))

  except Exception, e:
    # import traceback
    # traceback.print_exc()
    raise Exception("Caught exception in integrate/build: %s" % e)