def run(self, platform, productName, appVersion, version, build_number, locale, hashFunction, extVersion, buildID, **updateKwargs): targets = buildbot2updatePlatforms(platform) # Some platforms may have alias', but those are set-up elsewhere # for release blobs. build_target = targets[0] name = get_release_blob_name(productName, version, build_number, self.suffix) data = { 'buildID': buildID, 'appVersion': appVersion, 'displayVersion': getPrettyVersion(version) } data.update( self._get_update_data(productName, version, build_number, **updateKwargs)) api = SingleLocale(name=name, build_target=build_target, locale=locale, auth0_secrets=self.auth0_secrets, api_root=self.api_root) current_data, data_version = api.get_data() api.update_build(data_version=data_version, product=productName, hashFunction=hashFunction, buildData=json.dumps(data), schemaVersion=9)
def run(self, platform, productName, appVersion, version, build_number, locale, hashFunction, extVersion, buildID, **updateKwargs): targets = buildbot2updatePlatforms(platform) # Some platforms may have alias', but those are set-up elsewhere # for release blobs. build_target = targets[0] name = get_release_blob_name(productName, version, build_number, self.suffix) locale_data = {"buildID": buildID, "appVersion": appVersion, "displayVersion": getPrettyVersion(version)} locale_data.update(self._get_update_data(productName, version, build_number, **updateKwargs)) if self.backend_version == 2: log.info("Using backend version 2...") # XXX Check for existing data_version for this locale data = { "blob": {"platforms": {build_target: {"locales": {locale: locale_data}}}}, # XXX old_data_versions here is currently required but shouldn't be "old_data_versions": {"platforms": {build_target: {"locales": {}}}}, } url = self.api_root + "/v2/releases/" + name session = get_balrog_session(auth0_secrets=self.auth0_secrets) balrog_request(session, "post", url, json=data) else: log.info("Using legacy backend version...") api = SingleLocale(name=name, build_target=build_target, locale=locale, auth0_secrets=self.auth0_secrets, api_root=self.api_root) current_data, data_version = api.get_data() api.update_build(data_version=data_version, product=productName, hashFunction=hashFunction, buildData=json.dumps(locale_data), schemaVersion=9)
def run(self, platform, productName, appVersion, version, build_number, locale, hashFunction, extVersion, buildID, **updateKwargs): targets = buildbot2updatePlatforms(platform) # Some platforms may have alias', but those are set-up elsewhere # for release blobs. build_target = targets[0] name = get_release_blob_name(productName, version, build_number, self.suffix) data = { 'buildID': buildID, 'appVersion': appVersion, 'displayVersion': getPrettyVersion(version) } data.update(self._get_update_data(productName, version, build_number, **updateKwargs)) api = SingleLocale(name=name, build_target=build_target, locale=locale, auth0_secrets=self.auth0_secrets, api_root=self.api_root) current_data, data_version = api.get_data() api.update_build( data_version=data_version, product=productName, hashFunction=hashFunction, buildData=json.dumps(data), schemaVersion=9)
to_version = partial['toVersion'] if from_version == to_version or args.nightly: from_version = partial['fromBuildId'] to_version = partial['buildId'] mar_name = f'{PRODUCT_NAME}-{to_version}-{from_version}.{partial["locale"]}.{get_platform_for_build_target(partial["platform"])}.partial.mar' partial['name'] = mar_name if args.action == 'generate': for partial in partials: # use the mar_diff.sh script to generate a partial mar subprocess.run(['bash', 'ci/mar_diff.sh', partial['toVersion'], join(args.mar_dir, partial['name']), partial['from_mar'], partial['to_mar']]) elif args.action == 'publish': for partial in partials: build = SingleLocale( name=name, build_target=partial['platform'], locale=partial['locale'], **balrog_opts) update_url = f'{REPOSITORY_BASE_URL}/{args.to}/{partial["name"]}' mar_path = join(args.mar_dir, partial["name"]) if not exists(mar_path): print(f'WARN: Skipping {mar_path} - NOT_FOUND') continue file_hash = get_file_hash(mar_path) build_data = build.get_data()[0] if 'partials' not in build_data: build_data['partials'] = [] build_data['partials'].append({ "from": from_release.name, "filesize": getsize(join(args.mar_dir, partial["name"])), "hashValue": file_hash, "fileUrl": update_url, })
def run(self, platform, buildID, productName, branch, appVersion, locale, hashFunction, extVersion, schemaVersion, isOSUpdate=None, **updateKwargs): assert schemaVersion in ( 3, 4), 'Unhandled schema version %s' % schemaVersion targets = buildbot2updatePlatforms(platform) build_target = targets[0] alias = None if len(targets) > 1: alias = targets[1:] data = { 'buildID': buildID, 'appVersion': appVersion, 'platformVersion': extVersion, 'displayVersion': appVersion, } if isOSUpdate: data['isOSUpdate'] = isOSUpdate data.update(self._get_update_data(productName, branch, **updateKwargs)) if 'old-id' in platform: # bug 1366034: support old-id builds # Like 1055305, this is a hack to support two builds with same build target that # require differed't release blobs and rules build_type = 'old-id-%s' % self.build_type else: build_type = self.build_type name = get_nightly_blob_name(productName, branch, build_type, buildID, self.dummy) api = SingleLocale(name=name, build_target=build_target, locale=locale, auth0_secrets=self.auth0_secrets, api_root=self.api_root) # wrap operations into "atomic" functions that can be retried def update_dated(): current_data, data_version = api.get_data() # If the partials are already a subset of the blob and the # complete MAR is the same, skip the submission skip_submission = bool( current_data and current_data.get("completes") == data.get("completes") and all(p in current_data.get("partials", []) for p in data.get("partials", []))) if skip_submission: log.warn("Dated data didn't change, skipping update") return # explicitly pass data version api.update_build(product=productName, hashFunction=hashFunction, buildData=json.dumps(data), alias=json.dumps(alias), schemaVersion=schemaVersion, data_version=data_version) # Most retries are caused by losing a data race. In these cases, # there's no point in waiting a long time to retry, so we reduce # sleeptime and increase the number of attempts instead. retry(update_dated, sleeptime=2, max_sleeptime=2, attempts=10) latest = SingleLocale(api_root=self.api_root, auth0_secrets=self.auth0_secrets, name=get_nightly_blob_name( productName, branch, build_type, 'latest', self.dummy), build_target=build_target, locale=locale) def update_latest(): # copy everything over using target release's data version latest_data, latest_data_version = latest.get_data() source_data, _ = api.get_data() if source_data == latest_data: log.warn("Latest data didn't change, skipping update") return latest.update_build(product=productName, hashFunction=hashFunction, buildData=json.dumps(source_data), alias=json.dumps(alias), schemaVersion=schemaVersion, data_version=latest_data_version) retry(update_latest, sleeptime=2, max_sleeptime=2, attempts=10)
} } } print(json.dumps(release_data, indent=2)) api = Release(name=name, **balrog_opts) api.update_release(product=PRODUCT_NAME, hashFunction='sha512', releaseData=json.dumps(release_data), schemaVersion=9) elif args.action == 'build': mar_path = os.path.split(args.mar) [_, locale, platform, _, _] = mar_path[-1].rsplit('.', 4) print(f'Locale={locale}; Platform={platform}') api = SingleLocale(name=name, build_target=get_build_target_for_platform(platform), locale=locale, **balrog_opts) url = get_update_url(args.tag, PRODUCT_NAME, app_version, locale, platform) file_hash = get_file_hash(args.mar) build_data = { "buildID": args.bid, "appVersion": app_version, "displayVersion": app_version, "completes": [{ "from": "*", "filesize": os.path.getsize(args.mar), "hashValue": file_hash,