2016-01-12 22:56:14 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
"""desktop_partner_repacks.py
|
|
|
|
|
|
|
|
This script manages Desktop partner repacks for beta/release builds.
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# load modules from parent dir
|
|
|
|
sys.path.insert(1, os.path.dirname(sys.path[0]))
|
|
|
|
|
|
|
|
from mozharness.base.script import BaseScript
|
2018-05-16 19:51:37 +03:00
|
|
|
from mozharness.mozilla.automation import AutomationMixin
|
2018-04-19 19:01:17 +03:00
|
|
|
from mozharness.mozilla.secrets import SecretsMixin
|
2016-01-12 22:56:14 +03:00
|
|
|
from mozharness.base.python import VirtualenvMixin
|
2016-02-02 18:31:06 +03:00
|
|
|
from mozharness.base.log import FATAL
|
2016-01-12 22:56:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
# DesktopPartnerRepacks {{{1
|
2018-10-01 23:57:26 +03:00
|
|
|
class DesktopPartnerRepacks(AutomationMixin, BaseScript, VirtualenvMixin, SecretsMixin):
|
2016-01-12 22:56:14 +03:00
|
|
|
"""Manages desktop partner repacks"""
|
|
|
|
actions = [
|
2018-04-19 19:01:17 +03:00
|
|
|
"get-secrets",
|
2016-01-12 22:56:14 +03:00
|
|
|
"setup",
|
|
|
|
"repack",
|
|
|
|
"summary",
|
|
|
|
]
|
|
|
|
config_options = [
|
|
|
|
[["--version", "-v"], {
|
|
|
|
"dest": "version",
|
|
|
|
"help": "Version of Firefox to repack",
|
|
|
|
}],
|
|
|
|
[["--build-number", "-n"], {
|
2016-03-30 17:51:29 +03:00
|
|
|
"dest": "build_number",
|
2016-01-12 22:56:14 +03:00
|
|
|
"help": "Build number of Firefox to repack",
|
|
|
|
}],
|
|
|
|
[["--platform"], {
|
|
|
|
"dest": "platform",
|
|
|
|
"help": "Platform to repack (e.g. linux64, macosx64, ...)",
|
|
|
|
}],
|
|
|
|
[["--partner", "-p"], {
|
|
|
|
"dest": "partner",
|
|
|
|
"help": "Limit repackaging to partners matching this string",
|
|
|
|
}],
|
2018-04-19 19:01:17 +03:00
|
|
|
[["--taskid", "-t"], {
|
|
|
|
"dest": "taskIds",
|
|
|
|
"action": "extend",
|
|
|
|
"help": "taskId(s) of upstream tasks for vanilla Firefox artifacts",
|
|
|
|
}],
|
2018-05-07 14:57:53 +03:00
|
|
|
[["--limit-locale", "-l"], {
|
|
|
|
"dest": "limitLocales",
|
|
|
|
"action": "append",
|
|
|
|
}],
|
2016-01-12 22:56:14 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
# fxbuild style:
|
|
|
|
buildscript_kwargs = {
|
|
|
|
'all_actions': DesktopPartnerRepacks.actions,
|
|
|
|
'default_actions': DesktopPartnerRepacks.actions,
|
|
|
|
'config': {
|
|
|
|
"log_name": "partner-repacks",
|
|
|
|
"hashType": "sha512",
|
|
|
|
'workdir': 'partner-repacks',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
#
|
|
|
|
|
|
|
|
BaseScript.__init__(
|
|
|
|
self,
|
|
|
|
config_options=self.config_options,
|
|
|
|
**buildscript_kwargs
|
|
|
|
)
|
|
|
|
|
2016-01-25 23:20:41 +03:00
|
|
|
def _pre_config_lock(self, rw_config):
|
2018-04-19 19:01:17 +03:00
|
|
|
if os.getenv('REPACK_MANIFESTS_URL'):
|
|
|
|
self.info('Overriding repack_manifests_url to %s' % os.getenv('REPACK_MANIFESTS_URL'))
|
|
|
|
self.config['repack_manifests_url'] = os.getenv('REPACK_MANIFESTS_URL')
|
|
|
|
if os.getenv('UPSTREAM_TASKIDS'):
|
|
|
|
self.info('Overriding taskIds with %s' % os.getenv('UPSTREAM_TASKIDS'))
|
|
|
|
self.config['taskIds'] = os.getenv('UPSTREAM_TASKIDS').split()
|
2016-01-25 23:20:41 +03:00
|
|
|
|
2016-03-30 17:51:29 +03:00
|
|
|
if 'version' not in self.config:
|
|
|
|
self.fatal("Version (-v) not supplied.")
|
|
|
|
if 'build_number' not in self.config:
|
|
|
|
self.fatal("Build number (-n) not supplied.")
|
2016-05-03 19:42:29 +03:00
|
|
|
if 'repo_file' not in self.config:
|
|
|
|
self.fatal("repo_file not supplied.")
|
|
|
|
if 'repack_manifests_url' not in self.config:
|
2018-04-19 19:01:17 +03:00
|
|
|
self.fatal("repack_manifests_url not supplied in config or via REPACK_MANIFESTS_URL")
|
|
|
|
if 'taskIds' not in self.config:
|
|
|
|
self.fatal('Need upstream taskIds from command line or in UPSTREAM_TASKIDS')
|
2016-03-30 17:51:29 +03:00
|
|
|
|
2016-01-12 22:56:14 +03:00
|
|
|
def query_abs_dirs(self):
|
|
|
|
if self.abs_dirs:
|
|
|
|
return self.abs_dirs
|
|
|
|
abs_dirs = super(DesktopPartnerRepacks, self).query_abs_dirs()
|
|
|
|
for directory in abs_dirs:
|
|
|
|
value = abs_dirs[directory]
|
|
|
|
abs_dirs[directory] = value
|
|
|
|
dirs = {}
|
|
|
|
dirs['abs_repo_dir'] = os.path.join(abs_dirs['abs_work_dir'], '.repo')
|
|
|
|
dirs['abs_partners_dir'] = os.path.join(abs_dirs['abs_work_dir'], 'partners')
|
|
|
|
dirs['abs_scripts_dir'] = os.path.join(abs_dirs['abs_work_dir'], 'scripts')
|
|
|
|
for key in dirs.keys():
|
|
|
|
if key not in abs_dirs:
|
|
|
|
abs_dirs[key] = dirs[key]
|
|
|
|
self.abs_dirs = abs_dirs
|
|
|
|
return self.abs_dirs
|
|
|
|
|
|
|
|
# Actions {{{
|
|
|
|
def _repo_cleanup(self):
|
|
|
|
self.rmtree(self.query_abs_dirs()['abs_repo_dir'])
|
|
|
|
self.rmtree(self.query_abs_dirs()['abs_partners_dir'])
|
|
|
|
self.rmtree(self.query_abs_dirs()['abs_scripts_dir'])
|
|
|
|
|
|
|
|
def _repo_init(self, repo):
|
2018-04-19 19:01:17 +03:00
|
|
|
partial_env = {
|
|
|
|
'GIT_SSH_COMMAND': 'ssh -oIdentityFile={}'.format(self.config['ssh_key'])
|
|
|
|
}
|
2016-01-12 22:56:14 +03:00
|
|
|
status = self.run_command([repo, "init", "--no-repo-verify",
|
|
|
|
"-u", self.config['repack_manifests_url']],
|
2018-04-19 19:01:17 +03:00
|
|
|
cwd=self.query_abs_dirs()['abs_work_dir'],
|
|
|
|
partial_env=partial_env)
|
2016-01-12 22:56:14 +03:00
|
|
|
if status:
|
|
|
|
return status
|
2018-04-19 19:01:17 +03:00
|
|
|
return self.run_command([repo, "sync", "--current-branch", "--no-tags"],
|
|
|
|
cwd=self.query_abs_dirs()['abs_work_dir'],
|
|
|
|
partial_env=partial_env)
|
2016-01-12 22:56:14 +03:00
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
"""setup step"""
|
|
|
|
repo = self.download_file(self.config['repo_file'],
|
|
|
|
file_name='repo',
|
|
|
|
parent_dir=self.query_abs_dirs()['abs_work_dir'],
|
|
|
|
error_level=FATAL)
|
|
|
|
if not os.path.exists(repo):
|
|
|
|
self.fatal("Unable to download repo tool.")
|
2018-04-19 19:01:17 +03:00
|
|
|
self.chmod(repo, 0o755)
|
2016-01-12 22:56:14 +03:00
|
|
|
self.retry(self._repo_init,
|
|
|
|
args=(repo,),
|
|
|
|
error_level=FATAL,
|
|
|
|
cleanup=self._repo_cleanup(),
|
|
|
|
good_statuses=[0],
|
|
|
|
sleeptime=5)
|
|
|
|
|
|
|
|
def repack(self):
|
|
|
|
"""creates the repacks"""
|
2018-04-19 19:01:17 +03:00
|
|
|
repack_cmd = [sys.executable, "tc-partner-repacks.py",
|
2016-01-12 22:56:14 +03:00
|
|
|
"-v", self.config['version'],
|
2016-04-08 06:17:14 +03:00
|
|
|
"-n", str(self.config['build_number'])]
|
2016-01-12 22:56:14 +03:00
|
|
|
if self.config.get('platform'):
|
|
|
|
repack_cmd.extend(["--platform", self.config['platform']])
|
|
|
|
if self.config.get('partner'):
|
|
|
|
repack_cmd.extend(["--partner", self.config['partner']])
|
2018-04-19 19:01:17 +03:00
|
|
|
if self.config.get('taskIds'):
|
|
|
|
for taskId in self.config['taskIds']:
|
|
|
|
repack_cmd.extend(["--taskid", taskId])
|
2018-05-07 14:57:53 +03:00
|
|
|
if self.config.get("limitLocales"):
|
|
|
|
for locale in self.config["limitLocales"]:
|
|
|
|
repack_cmd.extend(["--limit-locale", locale])
|
2016-01-12 22:56:14 +03:00
|
|
|
|
2018-05-23 04:03:58 +03:00
|
|
|
self.run_command(repack_cmd,
|
|
|
|
cwd=self.query_abs_dirs()['abs_scripts_dir'],
|
|
|
|
halt_on_failure=True)
|
2016-01-12 22:56:14 +03:00
|
|
|
|
2017-10-25 03:21:41 +03:00
|
|
|
|
2016-01-12 22:56:14 +03:00
|
|
|
# main {{{
|
|
|
|
if __name__ == '__main__':
|
|
|
|
partner_repacks = DesktopPartnerRepacks()
|
|
|
|
partner_repacks.run_and_exit()
|