def createRelease(trunkDir, installDir, tmpDir="/tmp"):

    # Get a release directory
    baseName = os.path.join(tmpDir, "toolkit_release.")
    for i in xrange(0, 10):
        releaseDir = baseName + str(i)
        if not os.path.exists(releaseDir):
            break
    if os.path.exists(releaseDir):
        raise Exception("unable to find release directory in tmpDir %s" %
                        tmpDir)

    print "Creating release in %s" % releaseDir
    # install from the manifest
    pybuildDir = os.path.join(trunkDir, "build_system", "pybuild")
    sys.path.insert(0, pybuildDir)
    import manifest
    import utils
    utils.initlog(False)

    manifestFile = os.path.join(trunkDir, "release", "toolkit_release",
                                "manifests", "toolkit_release.manifest")
    manifest.installFromManifest(manifestFile,
                                 installDir,
                                 releaseDir,
                                 level=0,
                                 overwrite=False,
                                 destdirExists=False,
                                 allArchitectures=False)
    print "Finished creating release"
    return releaseDir
Beispiel #2
0
def create_demo_release(trunk, install_dir, work_dir, version="DEV"):
  """Create the demo release in the release_dir"""

  release_dir = os.path.join(work_dir, 'install')
  print "Creating demo release in %s from installation at %s" % (release_dir, install_dir)

  # Clean the target dir to make sure starting from scratch
  if os.path.isfile(work_dir):
    os.remove(work_dir)
  if os.path.isdir(work_dir):
    print "Removing %s" % work_dir
    shutil.rmtree(work_dir)
  assert not os.path.exists(work_dir)

  # Use build system utilities to create the release.
  pybuild_dir = os.path.normpath(os.path.join(trunk, 'build_system/pybuild'))
  assert os.path.isdir(pybuild_dir)
  sys.path.insert(0, pybuild_dir)
  import manifest
  import utils
  utils.initlog(False)
  manifestFile = os.path.join(trunk,
    'release/demo_release/manifests/demo_release.manifest')

  manifest.installFromManifest(manifestFile, install_dir, release_dir, level=0, overwrite=False, destdirExists=False, allArchitectures=False)

  # Create version file which will show up in the about box
  versionFile = os.path.join(work_dir, ".version")
  open(versionFile, "w").write(version)

  print "Done creating release"
def create_people_tracker_release(trunk_dir, install_dir, work_dir, version="DEV"):
  """Create the people tracker release in the release_dir"""
  # TODO: release_dir is a global

  print "Creating people tracker release in %s from installation at %s" % (release_dir, install_dir)

  # Clean the target dir to make sure starting from scratch
  if os.path.isfile(work_dir):
    os.remove(work_dir)
  if os.path.isdir(work_dir):
    print "Removing %s" % work_dir
    shutil.rmtree(work_dir)
  assert not os.path.exists(work_dir)

  # Use build system utilities to create the release.
  manifestFile = os.path.join(trunk_dir,
    'release/tracker_release/manifests/tracker_release.manifest')

  manifest.installFromManifest(manifestFile, install_dir, release_dir, level=0, overwrite=False, destdirExists=False, allArchitectures=False)

  # Create version file which will show up in the about box
  versionFile = os.path.join(work_dir, ".version")
  open(versionFile, "w").write(version)

  print "Done creating release"
Beispiel #4
0
def createRelease(releaseName, trunkDir, installDir, tmpDir="/tmp"):
    """Create the release for to this standalone app. 
  Copies files from installDir into a temporary dir, and returns
  the name of the temporary dir."""

    # Get a temp directory to hold the release.
    baseName = os.path.join(tmpDir, "%s-release" % releaseName)
    for i in xrange(0, 10):
        releaseDir = baseName + str(i)
        if not os.path.exists(releaseDir):
            break
    if os.path.exists(releaseDir):
        raise Exception("unable to find release directory in tmpDir %s" %
                        tmpDir)

    print "Creating release in %s" % releaseDir

    # install from the manifest
    manifestFile = os.path.join(trunkDir, "release",
                                "%s_release" % releaseName, "manifests",
                                "%s_release.manifest" % releaseName)
    manifest.installFromManifest(manifestFile,
                                 installDir,
                                 releaseDir,
                                 level=0,
                                 overwrite=False,
                                 destdirExists=False,
                                 allArchitectures=False)
    print "Finished creating release %s" % releaseName
    return releaseDir
Beispiel #5
0
def createCustomerRelease(releaseType, releaseSpecDir, destDir, fromDir, releaseName, allArchitectures=True, allArchiveTypes=False, allowSymbolicLinks=False, parentTmpDir=None):
  """Create a customer release tarball in destdir from the
  directories engReleaseDir and releaseSpecDir
  releaseType is one of biaryReleaseTypes or sourceReleaseTypes
  fromDir is engineering build for the binary release, 
             source dir for a source release
  releaseSpecDir is directory containing manifests
  Returns a path to the tarball
  Throws an exception on error"""

  if not os.path.exists(destDir):
    utils.createDir(destDir)

  if releaseType in binaryReleaseTypes:
    isSourceRelease = False
  elif releaseType in sourceReleaseTypes:
    isSourceRelease = True
  else:
    raise Exception("Unknown release type '%s'" % releaseType)
    
  if not isSourceRelease:
    allArchitectures=False

  manifestFile = os.path.join(releaseSpecDir, releaseType + "_release", 
                              "manifests", releaseType + "_release.manifest")

  log.info("Creating customer release of type %s", releaseType)
  log.info("specDir: %s", releaseSpecDir)
  log.info("fromDir: %s", fromDir)
  tempdir = utils.createTemporaryDirectory("assemble_release", parentDir=parentTmpDir)
  try:
    releaseImageDir = os.path.join(tempdir, releaseName)
    installFromManifest(manifestFile, fromDir, releaseImageDir, 
                        level=0, overwrite=False, destdirExists=False, 
                        allArchitectures=allArchitectures, allowSymbolicLinks=allowSymbolicLinks)
    if isSourceRelease:
      # run autogen equivalent on source trees
      build.prepareSourceTree(releaseImageDir, customerRelease=True)

    # Need to create both zip and tgz source releases on the master build system
    if allArchiveTypes == True:
      # sanity checks
      if not isSourceRelease:
        raise Exception("Attempt to create both zip and tar file for a binary release. Probably an error")
      if getArch() == "win32":
        raise Exception("Attempt to create .tgz source release on a windows system. Would not include autogen.sh")
      zipFile = utils.createArchive(releaseImageDir, destDir, type="zip")
      tarFile = utils.createArchive(releaseImageDir, destDir, type="tar")
      return (tarFile, zipFile)
    else:
      release = utils.createArchive(releaseImageDir, destDir)
      return release
  finally:
    utils.remove(tempdir)
def create_toolkit_release(trunk, install_dir, work_dir, version="DEV"):
    """Create the vision toolkit release in the release_dir"""

    release_dir = os.path.join(work_dir, 'install')
    print "Creating vision toolkit release in %s from installation at %s" % (
        release_dir, install_dir)

    # Clean the target dir to make sure starting from scratch
    if os.path.isfile(work_dir):
        os.remove(work_dir)
    if os.path.isdir(work_dir):
        print "Removing %s" % work_dir
        shutil.rmtree(work_dir)
    assert not os.path.exists(work_dir)

    # Use build system utilities to create the release.
    pybuild_dir = os.path.normpath(os.path.join(trunk, 'build_system/pybuild'))
    assert os.path.isdir(pybuild_dir)
    sys.path.insert(0, pybuild_dir)
    import manifest
    import utils
    utils.initlog(False)
    manifestFile = os.path.join(
        trunk, 'release/toolkit_release/manifests/toolkit_release.manifest')

    manifest.installFromManifest(manifestFile,
                                 install_dir,
                                 release_dir,
                                 level=0,
                                 overwrite=False,
                                 destdirExists=False,
                                 allArchitectures=False)

    # Create version file which will show up in the about box
    versionFile = os.path.join(work_dir, ".version")
    open(versionFile, "w").write(version)

    print "Done creating release"
def createRelease(trunkDir, installDir, tmpDir="/tmp"):

  # Get a release directory
  baseName = os.path.join(tmpDir, "demo_release.")
  for i in xrange(0, 10):
    releaseDir = baseName + str(i)
    if not os.path.exists(releaseDir):
      break
  if os.path.exists(releaseDir):
    raise Exception("unable to find release directory in tmpDir %s" % tmpDir)

  print "Creating release in %s" % releaseDir
  # install from the manifest
  pybuildDir = os.path.join(trunkDir, "build_system", "pybuild")
  sys.path.insert(0, pybuildDir)
  import manifest
  import utils
  utils.initlog(False)

  manifestFile = os.path.join(trunkDir, "release", "demo_release", "manifests", "demo_release.manifest")
  manifest.installFromManifest(manifestFile, installDir, releaseDir, level=0, overwrite=False, destdirExists=False, allArchitectures=False)
  print "Finished creating release"
  return releaseDir
Beispiel #8
0
def createRelease(releaseName, trunkDir, installDir, tmpDir="/tmp"):
  """Create the release for to this standalone app. 
  Copies files from installDir into a temporary dir, and returns
  the name of the temporary dir."""


  # Get a temp directory to hold the release. 
  baseName = os.path.join(tmpDir, "%s-release" % releaseName)
  for i in xrange(0, 10):
    releaseDir = baseName + str(i)
    if not os.path.exists(releaseDir):
      break
  if os.path.exists(releaseDir):
    raise Exception("unable to find release directory in tmpDir %s" % tmpDir)

  print "Creating release in %s" % releaseDir


  # install from the manifest
  manifestFile = os.path.join(trunkDir, "release", "%s_release" % releaseName, "manifests", "%s_release.manifest" % releaseName)
  manifest.installFromManifest(manifestFile, installDir, releaseDir, level=0, overwrite=False, destdirExists=False, allArchitectures=False)
  print "Finished creating release %s" % releaseName
  return releaseDir
def create_people_tracker_release(trunk_dir,
                                  install_dir,
                                  work_dir,
                                  version="DEV"):
    """Create the people tracker release in the release_dir"""
    # TODO: release_dir is a global

    print "Creating people tracker release in %s from installation at %s" % (
        release_dir, install_dir)

    # Clean the target dir to make sure starting from scratch
    if os.path.isfile(work_dir):
        os.remove(work_dir)
    if os.path.isdir(work_dir):
        print "Removing %s" % work_dir
        shutil.rmtree(work_dir)
    assert not os.path.exists(work_dir)

    # Use build system utilities to create the release.
    manifestFile = os.path.join(
        trunk_dir,
        'release/tracker_release/manifests/tracker_release.manifest')

    manifest.installFromManifest(manifestFile,
                                 install_dir,
                                 release_dir,
                                 level=0,
                                 overwrite=False,
                                 destdirExists=False,
                                 allArchitectures=False)

    # Create version file which will show up in the about box
    versionFile = os.path.join(work_dir, ".version")
    open(versionFile, "w").write(version)

    print "Done creating release"
Beispiel #10
0
def buildCustomerRelease(releaseType, releaseSpecDir, releaseTarball, binaryTarball, prefix=None, nprocs=1,parentTmpDir=None):
    """From the given source release tarball, compile and verify that the 
    build product is correct.
    @param releaseType -- one of the source release types
    @param releaseSpecDir -- trunk/release directory containing manifest files for this release
    @param releaseTarball -- tarball containing the release to be built. 
    @param binaryTarball -- tarball containing the binary release. This must be provided
        when building the tools source release, which requires prebuilt libraries that 
        only exist in the binary release. These libraries are copied in to the source 
        release tree prior to building the source release. 
    Throws an exception if the build fails or the build product does not 
    exactly match the manifest file.
    If prefix is not None, install the build product into the prefix directory
    No return value"""


    log.info("Building customer %s release", releaseType)
    

    origDir = os.getcwd()

    if not releaseType in sourceReleaseTypes:
        raise Exception("buildCustomerRelease: unknown release type %s" % releaseType)

    tarballBasename = os.path.basename(releaseTarball)
    (dirName, ext) = os.path.splitext(tarballBasename)

    manifest = os.path.abspath(os.path.join(releaseSpecDir, 
                                            "release",
                                            releaseType+"_release", 
                                            "manifests", 
                                            "build_output.manifest"))
    
    tempdir = utils.createTemporaryDirectory("build_"+releaseType, parentDir=parentTmpDir)

    installdir = os.path.join(tempdir, "install")
    utils.createDir(installdir)

    builddir = os.path.join(tempdir, "build")
    utils.createDir(builddir)

    srcdir = utils.extractArchive(releaseTarball, tempdir)

    # Use the precompiled runtime library for the full source build. 
    if releaseType in releasesRequiringSPNupic:
      if binaryTarball is None:
        raise Exception("No binary tarball provided when building tools release, which requires prebuilt libraries")
      binarydir = utils.extractArchive(binaryTarball, tempdir)
      log.info("Copying libruntime.a from binary release into source release")
      if getArch() != "win32":
        smartCopy(os.path.join(binarydir, "lib", "libruntime.a"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "libruntime.a"))
        smartCopy(os.path.join(binarydir, "lib", "libnode.a"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "libnode.a"))
        smartCopy(os.path.join(binarydir, "lib", "libipcserial.a"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "libipcserial.a"))
      else:
        smartCopy(os.path.join(binarydir, "lib", "release", "runtime.lib"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "runtime.lib"))
        smartCopy(os.path.join(binarydir, "lib", "release", "node.lib"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "node.lib"))
        smartCopy(os.path.join(binarydir, "lib", "release", "ipcserial.lib"), 
                  os.path.join(srcdir, "external", getArch(), "lib", "ipcserial.lib"))


    build.build(srcdir, builddir, installdir, assertions=False, customerRelease=True, nprocs=nprocs)

    # To verify the build product, we install from manifest and then 
    # confirm that the installed tree has the same number of files as the original tree. 
    # An exception in the installFromManifest phase usually means there is a file in 
    # the manifest that was not built. Then if the number of files is the same, it usually
    # means that a file was built that was not in the manifest. 
    tempInstallDir = os.path.join(tempdir, "temp_install")
    installFromManifest(manifest, installdir, tempInstallDir, 
                        level=0, overwrite=False, destdirExists=False)
    
    installedFiles = []

    for root,dirs,files in os.walk(tempInstallDir):
      installedFiles += [os.path.join(root, f) for f in files]
    # normalize the list of files
    prefixLen = len(tempInstallDir)
    installedFiles = [f[prefixLen:] for f in installedFiles]
    installedFiles = sorted(installedFiles)
      
    builtFiles = []
    for root,dirs,files in os.walk(installdir):
      builtFiles += [os.path.join(root, f) for f in files]
    # normalize the list of files
    prefixLen = len(installdir)
    builtFiles = [f[prefixLen:] for f in builtFiles]
    builtFiles = sorted(builtFiles)

    if len(installedFiles) != len(builtFiles):
      log.error("Manifest error when building %s release", releaseType)
      log.error("Built files: %d  Files in manifest: %d", len(builtFiles), len(installedFiles))
      # we know that every file in installedFiles is also in builtFiles
      # because installed dir was created from built dir
      for f in installedFiles:
        builtFiles.remove(f)
      
      for f in builtFiles:
        log.error("File '%s' installed but not in build_output.manifest" % f)
      
      raise Exception("Error building %s release -- file(s) missing from build_output.manifest" % releaseType)
    else:
      log.info("Release %s built successfully. Build produces %d files", releaseType, len(builtFiles))

    # copy all built files from directory where built into the the prefix dir, if specified
    if prefix is not None:
      log.info("Installing build products from '%s' release into binary release at '%s'", 
               releaseType, prefix)
      installFromManifest(manifest, installdir, prefix, 
                          level=0, overwrite=True, destdirExists=True)
    

    # clean up
    os.chdir(origDir)
    utils.remove(tempdir)