Beispiel #1
0
def install_git(**kwargs):
  reference = []
  if os.name == 'posix':
    reference_repository_path = os.path.join('/dls/science/groups/scisoft/DIALS/repositories/git-reference', kwargs['package'])
    if os.path.isdir(reference_repository_path):
      reference = ['--reference', reference_repository_path]
      print("using reference repository...", end="")
      sys.stdout.flush()
  try:
    result = procrunner.run_process(['git', 'clone', '--recursive', kwargs['source'], kwargs['location']] + reference,
                                    print_stdout=False)
    if result['exitcode']:
      return False
    if reference:
      oldcwd = os.getcwd()
      os.chdir(kwargs['location'])
      result = procrunner.run_process(['git', 'repack', '-a', '-d'], print_stderr=True)
      os.chdir(oldcwd)
      assert result['exitcode'] == 0, "Repack operation failed. Delete repository and try again."
      os.remove(os.path.join(kwargs['location'], '.git', 'objects', 'info', 'alternates'))
    Toolbox.set_git_repository_config_to_rebase(os.path.join(kwargs['location'], '.git', 'config'))
    return True
  except OSError:
    if os.path.isdir(kwargs['location']):
      shutil.rmtree(kwargs['location'])
    return False # git may not be installed
Beispiel #2
0
def install_zip(**kwargs):
    location = kwargs['location']
    source = kwargs['source']
    tempfile = os.path.join(location, '.tmp.zip')
    etagfile = os.path.join(location, '..tmp.zip.etag')

    def cleanup():
        try:
            os.remove(tempfile)
        except OSError:
            pass
        try:
            os.remove(etagfile)
        except OSError:
            pass
        try:
            os.rmdir(location)
        except OSError:
            pass

    if Toolbox.download_to_file(source['url'], tempfile) <= 0:
        cleanup()
        return False
    Toolbox.unzip(tempfile, location, trim_directory=source.get('trim', 0))
    cleanup()
    return True
Beispiel #3
0
def install_tgz(**kwargs):
    location = kwargs['location']
    source = kwargs['source']
    tempfile = os.path.join(location, '.tmp.tgz')
    etagfile = os.path.join(location, '..tmp.tgz.etag')

    def cleanup():
        try:
            os.remove(tempfile)
        except OSError:
            pass
        try:
            os.remove(etagfile)
        except OSError:
            pass
        try:
            os.rmdir(location)
        except OSError:
            pass

    if Toolbox.download_to_file(source['url'], tempfile) <= 0:
        cleanup()
        return False
    import tarfile
    with tarfile.open(tempfile, 'r') as fh:
        for t in range(source.get('trim', 0)):
            location = os.path.dirname(location)
        fh.extractall(location)
    cleanup()
    return True
Beispiel #4
0
def update_dials_download_links():
  dials_dir = libtbx.env.find_in_repositories("dials")
  release_file = os.path.join(dials_dir, 'doc', 'sphinx', 'installation.stable_release')
  release_json = os.path.join(dials_dir, 'doc', 'sphinx', 'installation.stable_release.json')

  release_info = None
  from libtbx.auto_build.bootstrap import Toolbox
  from datetime import datetime
  import json
  import re
  print("Checking DIALS release status: ", end="")
  if Toolbox().download_to_file('https://api.github.com/repos/dials/dials/releases/latest', release_json, cache=False):
    with open(release_json, 'r') as json_data:
      release_info = json.load(json_data)
  try: os.remove(release_json)
  except OSError: pass

  if not release_info: release_info = {}

  with open(release_file, 'w') as release:
    caption = "Stable Release"
    if 'name' in release_info:
      caption = caption + ": " + release_info['name']
      print("Most recent major DIALS release is:", release_info['name'])
    else:
      print("Could not determine most recent major DIALS release")
    release.write(caption + "\n" + '=' * len(caption) + "\n\n")

    release.write('The current stable release can be downloaded from `Github <https://github.com/dials/dials/releases/latest>`_,\n')
    release.write('where you can also find further `release notes <https://github.com/dials/dials/releases/latest>`_.\n\n')

    def download_button(text, version, link):
      print("  %s %s -> %s" % (version, text, link))
      return ".. button::\n   :text: DIALS %s %s\n   :link: %s\n\n" % (version, text, link)

    assets = {}
    for a in release_info.get('assets', []):
      tag = re.search('dials-v([^-]+)-([^-]+)-([^-]+)-(.+)', a['name'])
      if tag:
        shortname = tag.group(4)
        version = ".".join(tag.group(1,2,3))
        last_update = datetime.strptime(a['updated_at'], '%Y-%m-%dT%H:%M:%SZ') # - datetime(1970,1,1)).total_seconds()
        if shortname not in assets or assets[shortname][0] < last_update:
          assets[shortname] = (last_update, version, a.get('browser_download_url'))

    long_names = { 'macosx.pkg': 'Mac installer',
                   'macosx.tar.gz': 'Mac tar archive',
                   'macosx-10.6.pkg': 'Mac installer (OS X 10.6)',
                   'macosx-10.6.tar.gz': 'Mac tar archive (OS X 10.6)',
                   'linux-x86_64.tar.xz': 'Linux installer',
                   'source.tar.xz': 'Source installer' }

    buttons = [ download_button(long_names.get(asset, asset), version, link) \
                    for asset, (_, version, link) in assets.iteritems() ]

    release.write("".join(sorted(buttons)))
def mangle_git_repository(module, config):
  t = Toolbox()
  print("Git repository found:", module)
  t.set_git_repository_config_to_rebase(config)
  t.install_git_hooks(module, config)
Beispiel #6
0
def set_all_git_module_branches_to_rebase():
  t = Toolbox()
  for module, config in find_all_git_modules():
    print "Git repository found:", module
    t.set_git_repository_config_to_rebase(config)