Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ensure_dependencies.py

Issue 29716693: Issue 6371 - Update buildtools dep. to c830dfa08e2f, use AMO-signing API (Closed) Base URL: https://hg.adblockplus.org/abpssembly/file/1e38c3375fa3
Patch Set: Created March 9, 2018, 8:12 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 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 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import sys 7 import sys
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 29 matching lines...) Expand all
40 adblockpluschrome = git:git@github.com:user/adblockpluschrome.git@1fad3a7 40 adblockpluschrome = git:git@github.com:user/adblockpluschrome.git@1fad3a7
41 ''' 41 '''
42 42
43 SKIP_DEPENDENCY_UPDATES = os.environ.get( 43 SKIP_DEPENDENCY_UPDATES = os.environ.get(
44 'SKIP_DEPENDENCY_UPDATES', '' 44 'SKIP_DEPENDENCY_UPDATES', ''
45 ).lower() not in ('', '0', 'false') 45 ).lower() not in ('', '0', 'false')
46 46
47 NPM_LOCKFILE = '.npm_install_lock' 47 NPM_LOCKFILE = '.npm_install_lock'
48 48
49 49
50 class Mercurial(): 50 class Mercurial:
51 def istype(self, repodir): 51 def istype(self, repodir):
52 return os.path.exists(os.path.join(repodir, '.hg')) 52 return os.path.exists(os.path.join(repodir, '.hg'))
53 53
54 def clone(self, source, target): 54 def clone(self, source, target):
55 if not source.endswith('/'): 55 if not source.endswith('/'):
56 source += '/' 56 source += '/'
57 subprocess.check_call(['hg', 'clone', '--quiet', '--noupdate', source, t arget]) 57 subprocess.check_call(['hg', 'clone', '--quiet', '--noupdate', source, t arget])
58 58
59 def get_revision_id(self, repo, rev=None): 59 def get_revision_id(self, repo, rev=None):
60 command = ['hg', 'id', '--repository', repo, '--id'] 60 command = ['hg', 'id', '--repository', repo, '--id']
(...skipping 26 matching lines...) Expand all
87 with open(config_path, 'w') as stream: 87 with open(config_path, 'w') as stream:
88 config.write(stream) 88 config.write(stream)
89 89
90 module = os.path.relpath(target, repo) 90 module = os.path.relpath(target, repo)
91 _ensure_line_exists(ignore_path, module) 91 _ensure_line_exists(ignore_path, module)
92 92
93 def postprocess_url(self, url): 93 def postprocess_url(self, url):
94 return url 94 return url
95 95
96 96
97 class Git(): 97 class Git:
98 def istype(self, repodir): 98 def istype(self, repodir):
99 return os.path.exists(os.path.join(repodir, '.git')) 99 return os.path.exists(os.path.join(repodir, '.git'))
100 100
101 def clone(self, source, target): 101 def clone(self, source, target):
102 source = source.rstrip('/') 102 source = source.rstrip('/')
103 if not source.endswith('.git'): 103 if not source.endswith('.git'):
104 source += '.git' 104 source += '.git'
105 subprocess.check_call(['git', 'clone', '--quiet', source, target]) 105 subprocess.check_call(['git', 'clone', '--quiet', source, target])
106 106
107 def get_revision_id(self, repo, rev='HEAD'): 107 def get_revision_id(self, repo, rev='HEAD'):
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return 271 return
272 except IOError: 272 except IOError:
273 return 273 return
274 274
275 try: 275 try:
276 # Create an empty file, which gets deleted after successfully 276 # Create an empty file, which gets deleted after successfully
277 # installing Node.js dependencies. 277 # installing Node.js dependencies.
278 lockfile_path = os.path.join(target, NPM_LOCKFILE) 278 lockfile_path = os.path.join(target, NPM_LOCKFILE)
279 open(lockfile_path, 'a').close() 279 open(lockfile_path, 'a').close()
280 280
281 cmd = ['npm', 'install', '--only=production', '--loglevel=warn', 281 if os.name == 'nt':
282 # Windows' CreateProcess() (called by subprocess.Popen()) only
283 # resolves executables ending in .exe. The windows installation of
284 # Node.js only provides a npm.cmd, which is executable but won't
285 # be recognized as such by CreateProcess().
286 npm_exec = 'npm.cmd'
287 else:
288 npm_exec = 'npm'
289
290 cmd = [npm_exec, 'install', '--only=production', '--loglevel=warn',
282 '--no-package-lock', '--no-optional'] 291 '--no-package-lock', '--no-optional']
283 subprocess.check_output(cmd, cwd=target) 292 subprocess.check_output(cmd, cwd=target)
284 293
285 repo_types[vcs].ignore(os.path.join(target, NPM_LOCKFILE), target) 294 repo_types[vcs].ignore(os.path.join(target, NPM_LOCKFILE), target)
286 repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target) 295 repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target)
287 296
288 os.remove(lockfile_path) 297 os.remove(lockfile_path)
289 except OSError as e: 298 except OSError as e:
290 import errno 299 import errno
291 if e.errno == errno.ENOENT: 300 if e.errno == errno.ENOENT:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 args = parser.parse_args() 438 args = parser.parse_args()
430 439
431 if args.quiet: 440 if args.quiet:
432 logging.disable(logging.INFO) 441 logging.disable(logging.INFO)
433 442
434 repos = args.repos 443 repos = args.repos
435 if not len(repos): 444 if not len(repos):
436 repos = [os.path.dirname(__file__)] 445 repos = [os.path.dirname(__file__)]
437 for repo in repos: 446 for repo in repos:
438 resolve_deps(repo) 447 resolve_deps(repo)
OLDNEW

Powered by Google App Engine
This is Rietveld