Esempio n. 1
0
def copy_jdk_into_archive(output_zip, archive_file, input_file):
    def _replace_dirname(filename):
        # Rename the first folder to 'jdk', because Bazel looks for a
        # bundled JDK in the embedded tools using that folder name.
        return 'jdk/' + '/'.join(filename.split('/')[1:])

    # The JDK is special - it's extracted instead of copied.
    if archive_file.endswith('.tar.gz'):
        copy_tar_to_zip(output_zip, input_file, _replace_dirname)
    elif archive_file.endswith('.zip'):
        copy_zip_to_zip(output_zip, input_file, _replace_dirname)
Esempio n. 2
0
def copy_jdk_into_archive(output_zip, archive_file, input_file):

  def _replace_dirname(filename):
    # Rename the first folder to 'jdk', because Bazel looks for a
    # bundled JDK in the embedded tools using that folder name.
    return 'jdk/' + '/'.join(filename.split('/')[1:])

  # The JDK is special - it's extracted instead of copied.
  if archive_file.endswith('.tar.gz'):
    copy_tar_to_zip(output_zip, input_file, _replace_dirname)
  elif archive_file.endswith('.zip'):
    copy_zip_to_zip(output_zip, input_file, _replace_dirname)
Esempio n. 3
0
def main():
  output_zip = os.path.join(os.getcwd(), sys.argv[1])
  input_files = sorted(sys.argv[2:])

  # Copy all the input_files into output_zip.
  # Adding contextlib.closing to be python 2.6 (for centos 6.7) compatible
  with contextlib.closing(
      zipfile.ZipFile(output_zip, "w", zipfile.ZIP_DEFLATED)) as output_zip:

    def _normalize(path):
      return path[2:] if path.startswith("./") else path

    for input_file in input_files:
      if input_file.endswith(".tar"):
        copy_tar_to_zip(output_zip, input_file, _normalize)
      elif input_file.endswith(".zip"):
        copy_zip_to_zip(output_zip, input_file, _normalize)
      else:
        raise Exception("unknown archive type \"%s\"" % input_file)
Esempio n. 4
0
def main():
    output_zip = os.path.join(os.getcwd(), sys.argv[1])
    input_files = sorted(sys.argv[2:])

    # Copy all the input_files into output_zip.
    # Adding contextlib.closing to be python 2.6 (for centos 6.7) compatible
    with contextlib.closing(
            zipfile.ZipFile(output_zip, "w",
                            zipfile.ZIP_DEFLATED)) as output_zip:

        def _normalize(path):
            return path[2:] if path.startswith("./") else path

        for input_file in input_files:
            if input_file.endswith(".tar"):
                copy_tar_to_zip(output_zip, input_file, _normalize)
            elif input_file.endswith(".zip"):
                copy_zip_to_zip(output_zip, input_file, _normalize)
            else:
                raise Exception("unknown archive type \"%s\"" % input_file)