def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--manifest", required=True)
    parser.add_argument("-a",
                        "--api-root",
                        required=True,
                        help="Balrog API root")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_const",
                        dest="loglevel",
                        const=logging.DEBUG,
                        default=logging.INFO)
    parser.add_argument("--product",
                        help="Override product name from application.ini")
    args = parser.parse_args()
    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s",
                        level=args.loglevel)
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("boto").setLevel(logging.WARNING)

    balrog_username = os.environ.get("BALROG_USERNAME")
    balrog_password = os.environ.get("BALROG_PASSWORD")
    suffix = os.environ.get("BALROG_BLOB_SUFFIX")
    if not balrog_username and not balrog_password:
        raise RuntimeError("BALROG_USERNAME and BALROG_PASSWORD environment "
                           "variables should be set")
    if not suffix:
        raise RuntimeError(
            "BALROG_BLOB_SUFFIX environment variable should be set")

    manifest = json.load(open(args.manifest))
    auth = (balrog_username, balrog_password)

    for e in manifest:
        complete_info = [{
            "hash": e["hash"],
            "size": e["size"],
        }]

        submitter = ReleaseSubmitterV4(api_root=args.api_root,
                                       auth=auth,
                                       suffix=suffix)
        productName = args.product or e["appName"]
        retry(
            lambda: submitter.run(platform=e["platform"],
                                  productName=productName,
                                  version=e["toVersion"],
                                  build_number=e["toBuildNumber"],
                                  appVersion=e["version"],
                                  extVersion=e["version"],
                                  buildID=e["to_buildid"],
                                  locale=e["locale"],
                                  hashFunction='sha512',
                                  completeInfo=complete_info),
            attempts=30,
            sleeptime=10,
            max_sleeptime=60,
            jitter=3,
        )
Beispiel #2
0
def create_submitter(e, balrog_auth, config):
    from balrog.submitter.cli import NightlySubmitterV4, ReleaseSubmitterV4  # noqa: E402
    auth = balrog_auth

    if "previousVersion" in e and "previousBuildNumber" in e:
        # TODO: to rewrite this only for CMAR. partials are handled externally
        # by funsize
        log.info("Release style balrog submission")

        complete_info = [{
            "hash": e["to_hash"],
            "size": e["to_size"],
        }]
        partial_info = [{
            "hash": e["hash"],
            "size": e["size"],
        }]
        partial_info[0]["previousVersion"] = e["previousVersion"]
        partial_info[0]["previousBuildNumber"] = e["previousBuildNumber"]
        submitter = ReleaseSubmitterV4(api_root=config['api_root'],
                                       auth=auth,
                                       dummy=config['dummy'])

        return submitter, {'platform': e["platform"],
                           'productName': e["appName"],
                           'version': e["toVersion"],
                           'build_number': e["toBuildNumber"],
                           'appVersion': e["version"],
                           'extVersion': e["version"],
                           'buildID': e["to_buildid"],
                           'locale': e["locale"],
                           'hashFunction': 'sha512',
                           'partialInfo': partial_info,
                           'completeInfo': complete_info}

    elif "tc_nightly" in e:
        log.info("Taskcluster Nightly Fennec style Balrog submission")

        complete_info = e['completeInfo']
        submitter = NightlySubmitterV4(api_root=config['api_root'], auth=auth,
                                       dummy=config['dummy'],
                                       url_replacements=e.get('url_replacements', []))

        return submitter, {'platform': e["platform"],
                           'buildID': e["buildid"],
                           'productName': e["appName"],
                           'branch': e["branch"],
                           'appVersion': e["appVersion"],
                           'locale': e["locale"],
                           'hashFunction': e['hashType'],
                           'extVersion': e["extVersion"],
                           'completeInfo': complete_info}
    else:
        raise RuntimeError("Unknown Balrog submission style. Check manifest.json")
Beispiel #3
0
def create_locale_submitter(e, balrog_auth, config):
    from balrog.submitter.cli import NightlySubmitterV4, ReleaseSubmitterV4  # noqa: E402
    auth = balrog_auth

    if "tc_release" in e:
        log.info("Taskcluster Release style Balrog submission")

        complete_info = e['completeInfo']
        partial_info = e.get('partialInfo')
        submitter = ReleaseSubmitterV4(api_root=config['api_root'], auth=auth,
                                       dummy=config['dummy'])

        data = {
            'platform': e['platform'],
            'productName': e['appName'],
            'appVersion': e['appVersion'],
            'version': e['version'],
            'build_number': e['build_number'],
            'locale': e['locale'],
            'hashFunction': e['hashType'],
            'extVersion': e['extVersion'],
            'buildID': e['buildid'],
            'completeInfo': complete_info
        }
        if partial_info:
            data['partialInfo'] = partial_info
        return submitter, data

    elif "tc_nightly" in e:
        log.info("Taskcluster Nightly style Balrog submission")

        complete_info = e['completeInfo']
        partial_info = e.get('partialInfo')
        submitter = NightlySubmitterV4(api_root=config['api_root'], auth=auth,
                                       dummy=config['dummy'],
                                       url_replacements=e.get('url_replacements', []))

        data = {
            'platform': e["platform"],
            'buildID': e["buildid"],
            'productName': e["appName"],
            'branch': e["branch"],
            'appVersion': e["appVersion"],
            'locale': e["locale"],
            'hashFunction': e['hashType'],
            'extVersion': e["extVersion"],
            'completeInfo': complete_info
        }
        if partial_info:
            data['partialInfo'] = partial_info
        return submitter, data
    else:
        raise RuntimeError("Unknown Balrog submission style. Check manifest.json")
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--artifacts-url-prefix", required=True,
                        help="URL prefix for MAR")
    parser.add_argument("--manifest", required=True)
    parser.add_argument("-a", "--api-root", required=True,
                        help="Balrog API root")
    parser.add_argument("-d", "--dummy", action="store_true",
                        help="Add '-dummy' suffix to branch name")
    parser.add_argument("--sha1-signing-cert", required=True)
    parser.add_argument("--sha384-signing-cert", required=True)
    parser.add_argument("-v", "--verbose", action="store_const",
                        dest="loglevel", const=logging.DEBUG,
                        default=logging.INFO)
    parser.add_argument("--product", help="Override product name from application.ini")
    args = parser.parse_args()
    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s",
                        level=args.loglevel)
    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("boto").setLevel(logging.WARNING)

    balrog_username = os.environ.get("BALROG_USERNAME")
    balrog_password = os.environ.get("BALROG_PASSWORD")
    if not balrog_username and not balrog_password:
        raise RuntimeError("BALROG_USERNAME and BALROG_PASSWORD environment "
                           "variables should be set")

    s3_bucket = os.environ.get("S3_BUCKET")
    aws_access_key_id = os.environ.get("AWS_ACCESS_KEY_ID")
    aws_secret_access_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
    if not (s3_bucket and aws_access_key_id and aws_secret_access_key):
        log.warn("Skipping S3 uploads...")
        uploads_enabled = False
    else:
        uploads_enabled = True

    manifest = json.load(open(args.manifest))
    auth = (balrog_username, balrog_password)

    signing_certs = {
        'sha1': open(args.sha1_signing_cert, 'rb').read(),
        'sha384': open(args.sha384_signing_cert, 'rb').read(),
    }

    assert(get_keysize(signing_certs['sha1']) == 2048)
    assert(get_keysize(signing_certs['sha384']) == 4096)

    for e in manifest:
        complete_info = [{
            "hash": e["to_hash"],
            "size": e["to_size"],
        }]
        partial_info = [{
            "hash": e["hash"],
            "size": e["size"],
        }]

        if "previousVersion" in e and "previousBuildNumber" in e:
            log.info("Release style balrog submission")
            partial_info[0]["previousVersion"] = e["previousVersion"]
            partial_info[0]["previousBuildNumber"] = e["previousBuildNumber"]
            submitter = ReleaseSubmitterV4(api_root=args.api_root, auth=auth,
                                           dummy=args.dummy)
            productName = args.product or e["appName"]
            retry(lambda: submitter.run(
                platform=e["platform"], productName=productName,
                version=e["toVersion"],
                build_number=e["toBuildNumber"],
                appVersion=e["version"], extVersion=e["version"],
                buildID=e["to_buildid"], locale=e["locale"],
                hashFunction='sha512',
                partialInfo=partial_info, completeInfo=complete_info,
            ))
        elif "from_buildid" in e and uploads_enabled:
            log.info("Nightly style balrog submission")
            partial_mar_url = "{}/{}".format(args.artifacts_url_prefix,
                                             e["mar"])
            complete_mar_url = e["to_mar"]
            dest_prefix = "{branch}/{buildid}".format(
                branch=e["branch"], buildid=e["to_buildid"])
            partial_mar_dest = "{}/{}".format(dest_prefix, e["mar"])
            complete_mar_filename = "{appName}-{branch}-{version}-" \
                                    "{platform}-{locale}.complete.mar"
            complete_mar_filename = complete_mar_filename.format(
                appName=e["appName"], branch=e["branch"],
                version=e["version"], platform=e["platform"],
                locale=e["locale"]
            )
            complete_mar_dest = "{}/{}".format(dest_prefix,
                                               complete_mar_filename)
            partial_info[0]["url"] = verify_copy_to_s3(
                s3_bucket, aws_access_key_id, aws_secret_access_key,
                partial_mar_url, partial_mar_dest, signing_certs)
            complete_info[0]["url"] = verify_copy_to_s3(
                s3_bucket, aws_access_key_id, aws_secret_access_key,
                complete_mar_url, complete_mar_dest, signing_certs)
            partial_info[0]["from_buildid"] = e["from_buildid"]
            submitter = NightlySubmitterV4(api_root=args.api_root, auth=auth,
                                           dummy=args.dummy)
            productName = args.product or e["appName"]
            retry(lambda: submitter.run(
                platform=e["platform"], buildID=e["to_buildid"],
                productName=productName, branch=e["branch"],
                appVersion=e["version"], locale=e["locale"],
                hashFunction='sha512', extVersion=e["version"],
                partialInfo=partial_info, completeInfo=complete_info),
                attempts=30, sleeptime=10, max_sleeptime=60,
            )
        else:
            raise RuntimeError("Cannot determine Balrog submission style")
Beispiel #5
0
                      props['buildid'],
                      props['appName'],
                      props['branch'],
                      props['appVersion'],
                      locale,
                      props['hashType'],
                      extVersion,
                      isOSUpdate=isOSUpdate,
                      **updateKwargs)
    elif options.type_ == "release":
        updateKwargs = {}
        if options.schema_version == 3:
            submitter = ReleaseSubmitterV3(options.api_root, auth,
                                           options.dummy)
        else:
            submitter = ReleaseSubmitterV4(options.api_root, auth,
                                           options.dummy)

        updateKwargs["completeInfo"] = [{
            'size': props['completeMarSize'],
            'hash': props['completeMarHash'],
        }]
        if "partialInfo" in props:
            updateKwargs["partialInfo"] = props["partialInfo"]

        submitter.run(props['platform'], props['appName'], props['appVersion'],
                      props['version'], props['build_number'], locale,
                      props['hashType'], extVersion, props['buildid'],
                      **updateKwargs)
    else:
        parser.error("Invalid value for --type")