| Left: | ||
| Right: |
| 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 from StringIO import StringIO | |
| 9 | 8 |
| 10 def get_dependencies(prefix, repos): | 9 def get_dependencies(prefix, repos): |
| 11 from ensure_dependencies import read_deps, safe_join | 10 from ensure_dependencies import read_deps, safe_join |
| 12 repo = repos[prefix] | 11 repo = repos[prefix] |
| 13 deps = read_deps(repo) | 12 deps = read_deps(repo) |
| 14 if deps: | 13 if deps: |
| 15 for subpath in deps: | 14 for subpath in deps: |
| 16 if subpath.startswith('_'): | 15 if subpath.startswith('_'): |
| 17 continue | 16 continue |
| 18 depprefix = prefix + subpath + '/' | 17 depprefix = prefix + subpath + '/' |
| 19 deppath = safe_join(repo, subpath) | 18 deppath = safe_join(repo, subpath) |
| 20 repos[depprefix] = deppath | 19 repos[depprefix] = deppath |
| 21 get_dependencies(depprefix, repos) | 20 get_dependencies(depprefix, repos) |
| 22 | 21 |
| 23 def create_sourcearchive(repo, output): | 22 def create_sourcearchive(repo, output): |
| 24 with open(output, 'wb') as handle: | 23 with tarfile.open(output, mode='w:gz') as archive: |
|
Sebastian Noack
2014/09/18 16:20:06
You can just pass the filename to tarfile.open() a
Wladimir Palant
2014/09/18 18:40:48
Done, don't remember why the original code did it
| |
| 25 with tarfile.open(fileobj=handle, name=os.path.basename(output), mode='w:gz' ) as archive: | 24 repos = {'': repo} |
| 26 repos = {'': repo} | 25 get_dependencies('', repos) |
| 27 get_dependencies('', repos) | 26 for prefix, path in repos.iteritems(): |
| 28 for prefix, path in repos.iteritems(): | 27 process = subprocess.Popen(['hg', 'archive', '-R', path, '-t', 'tar', '-S' , '-'], stdout=subprocess.PIPE) |
| 29 data = subprocess.check_output(['hg', 'archive', '-R', path, '-t', 'tar' , '-S', '-']) | 28 try: |
| 30 with tarfile.open(fileobj=StringIO(data), mode='r:') as repoarchive: | 29 with tarfile.open(fileobj=process.stdout, mode='r|') as repoarchive: |
|
Sebastian Noack
2014/09/18 16:20:06
I would prefer to directly pass stdout of the subp
Sebastian Noack
2014/09/18 16:21:24
hg = subprocess.Popen(['hg', 'archive', ...], stdo
Wladimir Palant
2014/09/18 18:40:48
Turns out that the ingredient I was missing here w
Sebastian Noack
2014/09/18 18:58:12
Killing zombies. ;)
Terminated processes stay aro
Wladimir Palant
2014/09/18 19:23:57
Done.
| |
| 31 for fileinfo in repoarchive: | 30 for fileinfo in repoarchive: |
| 32 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'): | 31 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'): |
| 33 continue | 32 continue |
| 34 filedata = repoarchive.extractfile(fileinfo) | 33 filedata = repoarchive.extractfile(fileinfo) |
| 35 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name) | 34 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name) |
| 36 archive.addfile(fileinfo, filedata) | 35 archive.addfile(fileinfo, filedata) |
| 36 finally: | |
| 37 process.stdout.close() | |
| 38 process.wait() | |
| 37 | 39 |
| 38 def run(baseDir, type, version, keyFiles, downloadsRepo): | 40 def run(baseDir, type, version, keyFiles, downloadsRepo): |
| 39 if type == "gecko": | 41 if type == "gecko": |
| 40 import buildtools.packagerGecko as packager | 42 import buildtools.packagerGecko as packager |
| 41 elif type == "chrome": | 43 elif type == "chrome": |
| 42 import buildtools.packagerChrome as packager | 44 import buildtools.packagerChrome as packager |
| 43 | 45 |
| 44 # Replace version number in metadata file "manually", ConfigParser will mess | 46 # Replace version number in metadata file "manually", ConfigParser will mess |
| 45 # up the order of lines. | 47 # up the order of lines. |
| 46 metadata = packager.readMetadata(baseDir, type) | 48 metadata = packager.readMetadata(baseDir, type) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 create_sourcearchive(baseDir, archivePath) | 107 create_sourcearchive(baseDir, archivePath) |
| 106 downloads.append(archivePath) | 108 downloads.append(archivePath) |
| 107 | 109 |
| 108 # Now add the downloads and commit | 110 # Now add the downloads and commit |
| 109 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 111 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
| 110 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)]) |
| 111 | 113 |
| 112 # Push all changes | 114 # Push all changes |
| 113 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 115 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
| 114 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 116 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
| LEFT | RIGHT |