LEFT | RIGHT |
1 # coding: utf-8 | 1 # coding: utf-8 |
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 os, re, codecs, subprocess, tarfile, json | 7 import os, re, codecs, subprocess, tarfile, json |
8 | 8 |
9 def get_dependencies(prefix, repos): | 9 def get_dependencies(prefix, repos): |
10 from ensure_dependencies import read_deps, safe_join | 10 from ensure_dependencies import read_deps, safe_join |
11 repo = repos[prefix] | 11 repo = repos[prefix] |
12 deps = read_deps(repo) | 12 deps = read_deps(repo) |
13 if deps: | 13 if deps: |
14 for subpath in deps: | 14 for subpath in deps: |
15 if subpath.startswith('_'): | 15 if subpath.startswith('_'): |
16 continue | 16 continue |
17 depprefix = prefix + subpath + '/' | 17 depprefix = prefix + subpath + '/' |
18 deppath = safe_join(repo, subpath) | 18 deppath = safe_join(repo, subpath) |
19 repos[depprefix] = deppath | 19 repos[depprefix] = deppath |
20 get_dependencies(depprefix, repos) | 20 get_dependencies(depprefix, repos) |
21 | 21 |
22 def create_sourcearchive(repo, output): | 22 def create_sourcearchive(repo, output): |
23 with tarfile.open(output, mode='w:gz') as archive: | 23 with tarfile.open(output, mode='w:gz') as archive: |
24 repos = {'': repo} | 24 repos = {'': repo} |
25 get_dependencies('', repos) | 25 get_dependencies('', repos) |
26 for prefix, path in repos.iteritems(): | 26 for prefix, path in repos.iteritems(): |
27 process = subprocess.Popen(['hg', 'archive', '-R', path, '-t', 'tar', '-S'
, '-'], stdout=subprocess.PIPE) | 27 process = subprocess.Popen(['hg', 'archive', '-R', path, '-t', 'tar', '-S'
, '-'], stdout=subprocess.PIPE) |
28 with tarfile.open(fileobj=process.stdout, mode='r|') as repoarchive: | 28 try: |
29 for fileinfo in repoarchive: | 29 with tarfile.open(fileobj=process.stdout, mode='r|') as repoarchive: |
30 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'): | 30 for fileinfo in repoarchive: |
31 continue | 31 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'): |
32 filedata = repoarchive.extractfile(fileinfo) | 32 continue |
33 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name) | 33 filedata = repoarchive.extractfile(fileinfo) |
34 archive.addfile(fileinfo, filedata) | 34 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name) |
| 35 archive.addfile(fileinfo, filedata) |
| 36 finally: |
| 37 process.stdout.close() |
| 38 process.wait() |
35 | 39 |
36 def run(baseDir, type, version, keyFiles, downloadsRepo): | 40 def run(baseDir, type, version, keyFiles, downloadsRepo): |
37 if type == "gecko": | 41 if type == "gecko": |
38 import buildtools.packagerGecko as packager | 42 import buildtools.packagerGecko as packager |
39 elif type == "chrome": | 43 elif type == "chrome": |
40 import buildtools.packagerChrome as packager | 44 import buildtools.packagerChrome as packager |
41 | 45 |
42 # Replace version number in metadata file "manually", ConfigParser will mess | 46 # Replace version number in metadata file "manually", ConfigParser will mess |
43 # up the order of lines. | 47 # up the order of lines. |
44 metadata = packager.readMetadata(baseDir, type) | 48 metadata = packager.readMetadata(baseDir, type) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 create_sourcearchive(baseDir, archivePath) | 107 create_sourcearchive(baseDir, archivePath) |
104 downloads.append(archivePath) | 108 downloads.append(archivePath) |
105 | 109 |
106 # Now add the downloads and commit | 110 # Now add the downloads and commit |
107 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 111 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
108 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %
s %s' % (extensionName, version)]) | 112 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %
s %s' % (extensionName, version)]) |
109 | 113 |
110 # Push all changes | 114 # Push all changes |
111 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 115 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
112 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 116 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
LEFT | RIGHT |