2 # ***** BEGIN LICENSE BLOCK *****
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
6 # ***** END LICENSE BLOCK *****
7 """desktop_partner_repacks.py
9 This script manages Desktop partner repacks for beta/release builds.
14 # load modules from parent dir
15 sys
.path
.insert(1, os
.path
.dirname(sys
.path
[0]))
17 from mozharness
.base
.script
import BaseScript
18 from mozharness
.mozilla
.buildbot
import BuildbotMixin
19 from mozharness
.mozilla
.purge
import PurgeMixin
20 from mozharness
.mozilla
.release
import ReleaseMixin
21 from mozharness
.base
.python
import VirtualenvMixin
22 from mozharness
.base
.log
import FATAL
25 # DesktopPartnerRepacks {{{1
26 class DesktopPartnerRepacks(ReleaseMixin
, BuildbotMixin
, PurgeMixin
,
27 BaseScript
, VirtualenvMixin
):
28 """Manages desktop partner repacks"""
32 "activate-virtualenv",
38 [["--version", "-v"], {
40 "help": "Version of Firefox to repack",
42 [["--build-number", "-n"], {
43 "dest": "build_number",
44 "help": "Build number of Firefox to repack",
48 "help": "Platform to repack (e.g. linux64, macosx64, ...)",
50 [["--partner", "-p"], {
52 "help": "Limit repackaging to partners matching this string",
56 "help": "Configuration file for uploading to S3 using s3cfg",
60 "help": "Use a different hg server for retrieving files",
64 "help": "Use a different base repo for retrieving files",
66 [["--require-buildprops"], {
67 "action": "store_true",
68 "dest": "require_buildprops",
70 "help": "Read in config options (like partner) from the buildbot properties file."
76 buildscript_kwargs
= {
77 'all_actions': DesktopPartnerRepacks
.actions
,
78 'default_actions': DesktopPartnerRepacks
.actions
,
80 'buildbot_json_path': 'buildprops.json',
81 "log_name": "partner-repacks",
83 'virtualenv_modules': [
85 'PyHawk-with-a-single-extra-commit==0.1.5',
86 'taskcluster==0.0.15',
89 'virtualenv_path': 'venv',
90 'workdir': 'partner-repacks',
97 config_options
=self
.config_options
,
102 def _pre_config_lock(self
, rw_config
):
103 self
.read_buildbot_config()
104 if not self
.buildbot_config
:
105 self
.warning("Skipping buildbot properties overrides")
107 if self
.config
.get('require_buildprops', False) is True:
108 if not self
.buildbot_config
:
109 self
.fatal("Unable to load properties from file: %s" % self
.config
.get('buildbot_json_path'))
110 props
= self
.buildbot_config
["properties"]
111 for prop
in ['version', 'build_number', 'revision', 'repo_file', 'repack_manifests_url', 'partner']:
113 self
.info("Overriding %s with %s" % (prop
, props
[prop
]))
114 self
.config
[prop
] = props
.get(prop
)
116 if 'version' not in self
.config
:
117 self
.fatal("Version (-v) not supplied.")
118 if 'build_number' not in self
.config
:
119 self
.fatal("Build number (-n) not supplied.")
120 if 'repo_file' not in self
.config
:
121 self
.fatal("repo_file not supplied.")
122 if 'repack_manifests_url' not in self
.config
:
123 self
.fatal("repack_manifests_url not supplied.")
125 def query_abs_dirs(self
):
128 abs_dirs
= super(DesktopPartnerRepacks
, self
).query_abs_dirs()
129 for directory
in abs_dirs
:
130 value
= abs_dirs
[directory
]
131 abs_dirs
[directory
] = value
133 dirs
['abs_repo_dir'] = os
.path
.join(abs_dirs
['abs_work_dir'], '.repo')
134 dirs
['abs_partners_dir'] = os
.path
.join(abs_dirs
['abs_work_dir'], 'partners')
135 dirs
['abs_scripts_dir'] = os
.path
.join(abs_dirs
['abs_work_dir'], 'scripts')
136 for key
in dirs
.keys():
137 if key
not in abs_dirs
:
138 abs_dirs
[key
] = dirs
[key
]
139 self
.abs_dirs
= abs_dirs
143 def _repo_cleanup(self
):
144 self
.rmtree(self
.query_abs_dirs()['abs_repo_dir'])
145 self
.rmtree(self
.query_abs_dirs()['abs_partners_dir'])
146 self
.rmtree(self
.query_abs_dirs()['abs_scripts_dir'])
148 def _repo_init(self
, repo
):
149 status
= self
.run_command([repo
, "init", "--no-repo-verify",
150 "-u", self
.config
['repack_manifests_url']],
151 cwd
=self
.query_abs_dirs()['abs_work_dir'])
154 return self
.run_command([repo
, "sync"],
155 cwd
=self
.query_abs_dirs()['abs_work_dir'])
159 repo
= self
.download_file(self
.config
['repo_file'],
161 parent_dir
=self
.query_abs_dirs()['abs_work_dir'],
163 if not os
.path
.exists(repo
):
164 self
.fatal("Unable to download repo tool.")
165 self
.chmod(repo
, 0755)
166 self
.retry(self
._repo
_init
,
169 cleanup
=self
._repo
_cleanup
(),
174 """creates the repacks"""
175 repack_cmd
= [sys
.executable
, "partner-repacks.py",
176 "-v", self
.config
['version'],
177 "-n", str(self
.config
['build_number'])]
178 if self
.config
.get('platform'):
179 repack_cmd
.extend(["--platform", self
.config
['platform']])
180 if self
.config
.get('partner'):
181 repack_cmd
.extend(["--partner", self
.config
['partner']])
182 if self
.config
.get('s3cfg'):
183 repack_cmd
.extend(["--s3cfg", self
.config
['s3cfg']])
184 if self
.config
.get('hgroot'):
185 repack_cmd
.extend(["--hgroot", self
.config
['hgroot']])
186 if self
.config
.get('hgrepo'):
187 repack_cmd
.extend(["--repo", self
.config
['hgrepo']])
188 if self
.config
.get('revision'):
189 repack_cmd
.extend(["--tag", self
.config
["revision"]])
191 return self
.run_command(repack_cmd
,
192 cwd
=self
.query_abs_dirs()['abs_scripts_dir'])
195 if __name__
== '__main__':
196 partner_repacks
= DesktopPartnerRepacks()
197 partner_repacks
.run_and_exit()