示例#1
0
def _BuildOutput(config, tmp_paths, out_dir):
    generation_date = datetime.utcnow()
    version_xml_path = os.path.join(tmp_paths['imported_clients'],
                                    config.version_xml_path)
    play_services_full_version = utils.GetVersionNumberFromLibraryResources(
        version_xml_path)

    out_paths = _SetupOutputDir(out_dir)

    # Copy the resources to the output dir
    for client in config.clients:
        res_in_tmp_dir = os.path.join(tmp_paths['imported_clients'], client,
                                      'res')
        if os.path.isdir(res_in_tmp_dir) and os.listdir(res_in_tmp_dir):
            res_in_final_dir = os.path.join(out_paths['res'], client)
            shutil.copytree(res_in_tmp_dir, res_in_final_dir)

    # Copy the jar
    shutil.copyfile(tmp_paths['combined_jar'], out_paths['jar'])

    # Write the java dummy stub. Needed for gyp to create the resource jar
    stub_location = os.path.join(out_paths['stub'], 'src', 'android')
    os.makedirs(stub_location)
    with open(os.path.join(stub_location, 'UnusedStub.java'), 'w') as stub:
        stub.write('package android;'
                   'public final class UnusedStub {'
                   '    private UnusedStub() {}'
                   '}')

    # Create the main res directory. It is needed by gyp
    stub_res_location = os.path.join(out_paths['stub'], 'res')
    os.makedirs(stub_res_location)
    with open(os.path.join(stub_res_location, '.res-stamp'), 'w') as stamp:
        content_str = 'google_play_services_version: %s\nutc_date: %s\n'
        stamp.write(content_str %
                    (play_services_full_version, generation_date))

    config.UpdateVersionNumber(play_services_full_version)
示例#2
0
def _UpdateVersionInConfig(config, tmp_paths):
    version_xml_path = os.path.join(tmp_paths['imported_clients'],
                                    config.version_xml_path)
    play_services_full_version = utils.GetVersionNumberFromLibraryResources(
        version_xml_path)
    config.UpdateVersionNumber(play_services_full_version)
示例#3
0
def Upload(args):
    '''
  Uploads the library from the local Google Play services SDK to a Google Cloud
  storage bucket.

  By default, a local commit will be made at the end of the operation.
  '''

    # This should function should not run on bots and could fail for many user
    # and setup related reasons. Also, exceptions here are not caught, so we
    # disable breakpad to avoid spamming the logs.
    breakpad.IS_ENABLED = False

    config = utils.ConfigParser(args.config)
    paths = PlayServicesPaths(args.sdk_root, config.version_xml_path)

    if not args.skip_git and utils.IsRepoDirty(host_paths.DIR_SOURCE_ROOT):
        logging.error(
            'The repo is dirty. Please commit or stash your changes.')
        return -1

    new_version_number = utils.GetVersionNumberFromLibraryResources(
        paths.version_xml)
    logging.debug('comparing versions: new=%d, old=%s', new_version_number,
                  config.version_number)
    if new_version_number <= config.version_number and not args.force:
        logging.info(
            'The checked in version of the library is already the latest '
            'one. No update is needed. Please rerun with --force to skip '
            'this check.')
        return 0

    tmp_root = tempfile.mkdtemp()
    try:
        new_lib_zip = os.path.join(tmp_root, ZIP_FILE_NAME)
        new_license = os.path.join(tmp_root, LICENSE_FILE_NAME)

        # need to strip '.zip' from the file name here
        shutil.make_archive(new_lib_zip[:-4], 'zip', paths.lib)
        _ExtractLicenseFile(new_license, paths.source_prop)

        bucket_path = _VerifyBucketPathFormat(args.bucket, new_version_number,
                                              args.dry_run)
        files_to_upload = [new_lib_zip, new_license]
        logging.debug('Uploading %s to %s', files_to_upload, bucket_path)
        _UploadToBucket(bucket_path, files_to_upload, args.dry_run)

        new_lib_zip_sha1 = os.path.join(SHA1_DIRECTORY,
                                        ZIP_FILE_NAME + '.sha1')
        new_license_sha1 = os.path.join(SHA1_DIRECTORY,
                                        LICENSE_FILE_NAME + '.sha1')
        shutil.copy(new_lib_zip + '.sha1', new_lib_zip_sha1)
        shutil.copy(new_license + '.sha1', new_license_sha1)
    finally:
        shutil.rmtree(tmp_root)

    config.UpdateVersionNumber(new_version_number)

    if not args.skip_git:
        commit_message = ('Update the Google Play services dependency to %s\n'
                          '\n') % new_version_number
        utils.MakeLocalCommit(
            host_paths.DIR_SOURCE_ROOT,
            [new_lib_zip_sha1, new_license_sha1, config.path], commit_message)

    return 0