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

Side by Side Diff: releaseAutomation.py

Issue 5193970430771200: Issue 1363 - Make sure source code archives created by release automation consider the new dependen… (Closed)
Patch Set: Created Sept. 11, 2014, 7:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8 from StringIO import StringIO
9 9
10 def get_dependencies(prefix, repos):
11 from ensure_dependencies import read_deps, safe_join
12 repo = repos[prefix]
13 deps = read_deps(repo)
14 if deps:
15 for subpath in deps:
16 if subpath.startswith('_'):
17 continue
18 depprefix = prefix + subpath + '/'
19 deppath = safe_join(repo, subpath)
20 repos[depprefix] = deppath
21 get_dependencies(depprefix, repos)
22
23 def create_sourcearchive(repo, output):
24 with open(output, 'wb') as handle:
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:
26 repos = {'': repo}
27 get_dependencies('', repos)
28 for prefix, path in repos.iteritems():
29 data = subprocess.check_output(['hg', 'archive', '-R', path, '-t', 'tar' , '-S', '-'])
30 with tarfile.open(fileobj=StringIO(data), 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:
32 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'):
33 continue
34 filedata = repoarchive.extractfile(fileinfo)
35 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name)
36 archive.addfile(fileinfo, filedata)
37
10 def run(baseDir, type, version, keyFiles, downloadsRepo): 38 def run(baseDir, type, version, keyFiles, downloadsRepo):
11 if type == "gecko": 39 if type == "gecko":
12 import buildtools.packagerGecko as packager 40 import buildtools.packagerGecko as packager
13 elif type == "chrome": 41 elif type == "chrome":
14 import buildtools.packagerChrome as packager 42 import buildtools.packagerChrome as packager
15 43
16 # Replace version number in metadata file "manually", ConfigParser will mess 44 # Replace version number in metadata file "manually", ConfigParser will mess
17 # up the order of lines. 45 # up the order of lines.
18 metadata = packager.readMetadata(baseDir, type) 46 metadata = packager.readMetadata(baseDir, type)
19 with open(metadata.option_source("general", "version"), 'r+b') as file: 47 with open(metadata.option_source("general", "version"), 'r+b') as file:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 downloads.append(buildPathOpera) 95 downloads.append(buildPathOpera)
68 96
69 import buildtools.packagerSafari as packagerSafari 97 import buildtools.packagerSafari as packagerSafari
70 metadataSafari = packagerSafari.readMetadata(baseDir, "safari") 98 metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
71 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileN ame(baseDir, metadataSafari, version, 'safariextz')) 99 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileN ame(baseDir, metadataSafari, version, 'safariextz'))
72 packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1]) 100 packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
73 downloads.append(buildPathSafari) 101 downloads.append(buildPathSafari)
74 102
75 # Create source archive 103 # Create source archive
76 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 104 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
77 105 create_sourcearchive(baseDir, archivePath)
78 archiveHandle = open(archivePath, 'wb')
79 archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePat h), mode='w:gz')
80 data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', ' -S', '-'])
81 repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
82 for fileInfo in repoArchive:
83 if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
84 continue
85 fileData = repoArchive.extractfile(fileInfo)
86 fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
87 archive.addfile(fileInfo, fileData)
88 repoArchive.close()
89 archive.close()
90 archiveHandle.close()
91 downloads.append(archivePath) 106 downloads.append(archivePath)
92 107
93 # Now add the downloads and commit 108 # Now add the downloads and commit
94 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 109 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
95 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)]) 110 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)])
96 111
97 # Push all changes 112 # Push all changes
98 subprocess.check_call(['hg', 'push', '-R', baseDir]) 113 subprocess.check_call(['hg', 'push', '-R', baseDir])
99 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 114 subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld