Index: releaseAutomation.py |
=================================================================== |
--- a/releaseAutomation.py |
+++ b/releaseAutomation.py |
@@ -1,16 +1,46 @@ |
# coding: utf-8 |
# This Source Code Form is subject to the terms of the Mozilla Public |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
import os, re, codecs, subprocess, tarfile, json |
-from StringIO import StringIO |
+ |
+def get_dependencies(prefix, repos): |
+ from ensure_dependencies import read_deps, safe_join |
+ repo = repos[prefix] |
+ deps = read_deps(repo) |
+ if deps: |
+ for subpath in deps: |
+ if subpath.startswith('_'): |
+ continue |
+ depprefix = prefix + subpath + '/' |
+ deppath = safe_join(repo, subpath) |
+ repos[depprefix] = deppath |
+ get_dependencies(depprefix, repos) |
+ |
+def create_sourcearchive(repo, output): |
+ with tarfile.open(output, mode='w:gz') as archive: |
+ repos = {'': repo} |
+ get_dependencies('', repos) |
+ for prefix, path in repos.iteritems(): |
+ process = subprocess.Popen(['hg', 'archive', '-R', path, '-t', 'tar', '-S', '-'], stdout=subprocess.PIPE) |
+ try: |
+ with tarfile.open(fileobj=process.stdout, mode='r|') as repoarchive: |
+ for fileinfo in repoarchive: |
+ if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'): |
+ continue |
+ filedata = repoarchive.extractfile(fileinfo) |
+ fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name) |
+ archive.addfile(fileinfo, filedata) |
+ finally: |
+ process.stdout.close() |
+ process.wait() |
def run(baseDir, type, version, keyFiles, downloadsRepo): |
if type == "gecko": |
import buildtools.packagerGecko as packager |
elif type == "chrome": |
import buildtools.packagerChrome as packager |
# Replace version number in metadata file "manually", ConfigParser will mess |
@@ -69,30 +99,17 @@ def run(baseDir, type, version, keyFiles |
import buildtools.packagerSafari as packagerSafari |
metadataSafari = packagerSafari.readMetadata(baseDir, "safari") |
buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileName(baseDir, metadataSafari, version, 'safariextz')) |
packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1]) |
downloads.append(buildPathSafari) |
# Create source archive |
archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
- |
- archiveHandle = open(archivePath, 'wb') |
- archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePath), mode='w:gz') |
- data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', '-S', '-']) |
- repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:') |
- for fileInfo in repoArchive: |
- if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'): |
- continue |
- fileData = repoArchive.extractfile(fileInfo) |
- fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name) |
- archive.addfile(fileInfo, fileData) |
- repoArchive.close() |
- archive.close() |
- archiveHandle.close() |
+ create_sourcearchive(baseDir, archivePath) |
downloads.append(archivePath) |
# Now add the downloads and commit |
subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) |
# Push all changes |
subprocess.check_call(['hg', 'push', '-R', baseDir]) |