OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 # This Source Code Form is subject to the terms of the Mozilla Public | 4 # This Source Code Form is subject to the terms of the Mozilla Public |
5 # License, v. 2.0. If a copy of the MPL was not distributed with this | 5 # License, v. 2.0. If a copy of the MPL was not distributed with this |
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
7 | 7 |
8 import sys | 8 import sys |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
(...skipping 16 matching lines...) Expand all Loading... |
27 # File to update this script from (optional) | 27 # File to update this script from (optional) |
28 _self = buildtools/ensure_dependencies.py | 28 _self = buildtools/ensure_dependencies.py |
29 # Check out elemhidehelper repository into extensions/elemhidehelper directory | 29 # Check out elemhidehelper repository into extensions/elemhidehelper directory |
30 # at tag "1.2". | 30 # at tag "1.2". |
31 extensions/elemhidehelper = elemhidehelper 1.2 | 31 extensions/elemhidehelper = elemhidehelper 1.2 |
32 # Check out buildtools repository into buildtools directory at VCS-specific | 32 # Check out buildtools repository into buildtools directory at VCS-specific |
33 # revision IDs. | 33 # revision IDs. |
34 buildtools = buildtools hg:016d16f7137b git:f3f8692f82e5 | 34 buildtools = buildtools hg:016d16f7137b git:f3f8692f82e5 |
35 """ | 35 """ |
36 | 36 |
| 37 SKIP_DEPENDENCY_UPDATES = os.environ.get( |
| 38 "SKIP_DEPENDENCY_UPDATES", "" |
| 39 ).lower() not in ("", "0", "false") |
| 40 |
37 class Mercurial(): | 41 class Mercurial(): |
38 def istype(self, repodir): | 42 def istype(self, repodir): |
39 return os.path.exists(os.path.join(repodir, ".hg")) | 43 return os.path.exists(os.path.join(repodir, ".hg")) |
40 | 44 |
41 def clone(self, source, target): | 45 def clone(self, source, target): |
42 if not source.endswith("/"): | 46 if not source.endswith("/"): |
43 source += "/" | 47 source += "/" |
44 subprocess.check_call(["hg", "clone", "--quiet", "--noupdate", source, targe
t]) | 48 subprocess.check_call(["hg", "clone", "--quiet", "--noupdate", source, targe
t]) |
45 | 49 |
46 def get_revision_id(self, repo, rev=None): | 50 def get_revision_id(self, repo, rev=None): |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 def get_repo_type(repo): | 198 def get_repo_type(repo): |
195 for name, repotype in repo_types.iteritems(): | 199 for name, repotype in repo_types.iteritems(): |
196 if repotype.istype(repo): | 200 if repotype.istype(repo): |
197 return name | 201 return name |
198 return None | 202 return None |
199 | 203 |
200 def ensure_repo(parentrepo, target, roots, sourcename): | 204 def ensure_repo(parentrepo, target, roots, sourcename): |
201 if os.path.exists(target): | 205 if os.path.exists(target): |
202 return | 206 return |
203 | 207 |
| 208 if SKIP_DEPENDENCY_UPDATES: |
| 209 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " |
| 210 "%s not cloned", target) |
| 211 return |
| 212 |
204 parenttype = get_repo_type(parentrepo) | 213 parenttype = get_repo_type(parentrepo) |
205 type = None | 214 type = None |
206 for key in roots: | 215 for key in roots: |
207 if key == parenttype or (key in repo_types and type is None): | 216 if key == parenttype or (key in repo_types and type is None): |
208 type = key | 217 type = key |
209 if type is None: | 218 if type is None: |
210 raise Exception("No valid source found to create %s" % target) | 219 raise Exception("No valid source found to create %s" % target) |
211 | 220 |
212 postprocess_url = repo_types[type].postprocess_url | 221 postprocess_url = repo_types[type].postprocess_url |
213 root = postprocess_url(roots[type]) | 222 root = postprocess_url(roots[type]) |
(...skipping 19 matching lines...) Expand all Loading... |
233 | 242 |
234 if type in revisions: | 243 if type in revisions: |
235 revision = revisions[type] | 244 revision = revisions[type] |
236 elif "*" in revisions: | 245 elif "*" in revisions: |
237 revision = revisions["*"] | 246 revision = revisions["*"] |
238 else: | 247 else: |
239 logging.warning("No revision specified for repository %s (type %s), skipping
update" % (target, type)) | 248 logging.warning("No revision specified for repository %s (type %s), skipping
update" % (target, type)) |
240 return | 249 return |
241 | 250 |
242 resolved_revision = repo_types[type].get_revision_id(target, revision) | 251 resolved_revision = repo_types[type].get_revision_id(target, revision) |
243 if not resolved_revision: | 252 current_revision = repo_types[type].get_revision_id(target) |
244 logging.info("Revision %s is unknown, downloading remote changes" % revision
) | 253 |
245 repo_types[type].pull(target) | 254 if resolved_revision != current_revision: |
246 resolved_revision = repo_types[type].get_revision_id(target, revision) | 255 if SKIP_DEPENDENCY_UPDATES: |
| 256 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " |
| 257 "%s not checked out to %s", target, revision) |
| 258 return |
| 259 |
247 if not resolved_revision: | 260 if not resolved_revision: |
248 raise Exception("Failed to resolve revision %s" % revision) | 261 logging.info("Revision %s is unknown, downloading remote changes" % revisi
on) |
| 262 repo_types[type].pull(target) |
| 263 resolved_revision = repo_types[type].get_revision_id(target, revision) |
| 264 if not resolved_revision: |
| 265 raise Exception("Failed to resolve revision %s" % revision) |
249 | 266 |
250 current_revision = repo_types[type].get_revision_id(target) | |
251 if resolved_revision != current_revision: | |
252 logging.info("Updating repository %s to revision %s" % (target, resolved_rev
ision)) | 267 logging.info("Updating repository %s to revision %s" % (target, resolved_rev
ision)) |
253 repo_types[type].update(target, resolved_revision) | 268 repo_types[type].update(target, resolved_revision) |
254 | 269 |
255 def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep
endencies=set()): | 270 def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep
endencies=set()): |
256 config = read_deps(repodir) | 271 config = read_deps(repodir) |
257 if config is None: | 272 if config is None: |
258 if level == 0: | 273 if level == 0: |
259 logging.warning("No dependencies file in directory %s, nothing to do...\n%
s" % (repodir, USAGE)) | 274 logging.warning("No dependencies file in directory %s, nothing to do...\n%
s" % (repodir, USAGE)) |
260 return | 275 return |
261 if level >= 10: | 276 if level >= 10: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 args = parser.parse_args() | 332 args = parser.parse_args() |
318 | 333 |
319 if args.quiet: | 334 if args.quiet: |
320 logging.disable(logging.INFO) | 335 logging.disable(logging.INFO) |
321 | 336 |
322 repos = args.repos | 337 repos = args.repos |
323 if not len(repos): | 338 if not len(repos): |
324 repos = [os.path.dirname(__file__)] | 339 repos = [os.path.dirname(__file__)] |
325 for repo in repos: | 340 for repo in repos: |
326 resolve_deps(repo) | 341 resolve_deps(repo) |
OLD | NEW |