Пример #1
0
def buildit(rootdir, srcdir, builddir, installdir, svnpath, stamp, revision, datestamp, assertions, update, nprocs=1):
  """
  Do a full checkout and build
  """

  arch = getArch()
  log.info("Building for architecture " + arch)

  #
  # If source dir already exists, we're doing an incremental checkout. If not, we're
  # doing a full checkout. 
  #
  incremental = True
  if not os.path.exists(srcdir):
    if not update:
      log.error("No svn update requested, but source dir '%s' does not exist.", srcdir)
      raise Exception()
    else:
      incremental = False
      log.info("Source directory %s does not exist. Will do a full checkout", srcdir)
  else:
    if not os.path.isdir(srcdir):
      log.error("Source directory %s is not a directory.", srcdir)
      raise Exception()


  log.debug("Creating release directory %s", installdir)
  utils.createDir(installdir, True)
  utils.changeDir(os.path.join(installdir, os.pardir))
  buildfilename = os.path.join(installdir, ".buildinfo")

  #
  # Bring source tree up to date if requested
  #
  if update:
    log.info("Bringing source tree up to date at svnpath %s revision %s", svnpath, revision)
    svn.checkout(srcdir, repo=svnpath, revision=revision, incremental=incremental, keepLocalMods=False)
  else:
    log.warn("Skipping bringing up to date. Build will be tainted")
    utils.touchFile(os.path.join(installdir, "TAINTED_BUILD"))

  #
  # Revision may not be a number. May be "HEAD" or "PREV" or something else, so
  # retrieve it from svn
  #
  revisionnum = svn.getRevision(srcdir)

  #
  # place a temporary file in the install dir to indicate a build in progress
  # the file is removed at the end of the build process
  #
  build_in_progress_filename = os.path.join(installdir,"UNFINISHED_BUILD." + arch)
  utils.touchFile(build_in_progress_filename)


  log.debug("Updating build description file " + buildfilename)
  try:
    f = open(buildfilename, mode = "a")
    print >> f, "============================="
    print >> f, "Timestamp: " + datestamp
    print >> f, "Arch:      " + arch
    print >> f, "Buildhost: " + platform.node()
    print >> f, "Svnpath:   " + svnpath
    print >> f, "Revision:  " + str(revisionnum)
    print >> f, "Rootdir:   " + rootdir
    print >> f, "Srcdir:    " + srcdir
    print >> f, "Stamp:     " + stamp
    print >> f, "Assertions:" + str(assertions)
    print >> f, "Update:    " + str(update)
    print >> f, ""
    f.close()
  except Exception, e:
    raise Exception("Error writing to build description file '%s'", buildfilename)
Пример #2
0
    tests_ok = True
    if dotests:
        try:
          (passed, failed, disabled) = \
              test.runTestsInSeparateDirectory(installdir, srcdir, testlist="standard")

          test.logTestResults((passed, failed, disabled), (True, True, True), "Primary Tests", log)

          if len(failed) != 0:
            tests_ok = False
        except Exception, e:
            log.exception("Caught exception from testit routine: %s", e)
            tests_ok = False
    else:
        log.info("Tests skipped")
        utils.touchFile(os.path.join(installdir, "UNTESTED_BUILD." + arch))

    if not tests_ok:
        log.error("Tests FAILED. Exiting")
        sys.exit(1)

    release_ok = True
    if dorelease:
        log.info("Building customer releases")
        try:
            destDir = os.path.join(rootdir, "releases", stamp)
            createReleases(destDir, installdir, srcdir, stamp)
        except Exception, e:
            log.exception("Caught exception in createReleases: %s" % e)
            release_ok = False