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: Addressed comments Created Sept. 18, 2014, 6:38 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
9 def get_dependencies(prefix, repos):
10 from ensure_dependencies import read_deps, safe_join
11 repo = repos[prefix]
12 deps = read_deps(repo)
13 if deps:
14 for subpath in deps:
15 if subpath.startswith('_'):
16 continue
17 depprefix = prefix + subpath + '/'
18 deppath = safe_join(repo, subpath)
19 repos[depprefix] = deppath
20 get_dependencies(depprefix, repos)
21
22 def create_sourcearchive(repo, output):
23 with tarfile.open(output, mode='w:gz') as archive:
24 repos = {'': repo}
25 get_dependencies('', repos)
26 for prefix, path in repos.iteritems():
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:
29 for fileinfo in repoarchive:
30 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'):
31 continue
32 filedata = repoarchive.extractfile(fileinfo)
33 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name)
34 archive.addfile(fileinfo, filedata)
9 35
10 def run(baseDir, type, version, keyFiles, downloadsRepo): 36 def run(baseDir, type, version, keyFiles, downloadsRepo):
11 if type == "gecko": 37 if type == "gecko":
12 import buildtools.packagerGecko as packager 38 import buildtools.packagerGecko as packager
13 elif type == "chrome": 39 elif type == "chrome":
14 import buildtools.packagerChrome as packager 40 import buildtools.packagerChrome as packager
15 41
16 # Replace version number in metadata file "manually", ConfigParser will mess 42 # Replace version number in metadata file "manually", ConfigParser will mess
17 # up the order of lines. 43 # up the order of lines.
18 metadata = packager.readMetadata(baseDir, type) 44 metadata = packager.readMetadata(baseDir, type)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 downloads.append(buildPathOpera) 93 downloads.append(buildPathOpera)
68 94
69 import buildtools.packagerSafari as packagerSafari 95 import buildtools.packagerSafari as packagerSafari
70 metadataSafari = packagerSafari.readMetadata(baseDir, "safari") 96 metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
71 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileN ame(baseDir, metadataSafari, version, 'safariextz')) 97 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]) 98 packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
73 downloads.append(buildPathSafari) 99 downloads.append(buildPathSafari)
74 100
75 # Create source archive 101 # Create source archive
76 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 102 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
77 103 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) 104 downloads.append(archivePath)
92 105
93 # Now add the downloads and commit 106 # Now add the downloads and commit
94 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 107 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
95 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)]) 108 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing % s %s' % (extensionName, version)])
96 109
97 # Push all changes 110 # Push all changes
98 subprocess.check_call(['hg', 'push', '-R', baseDir]) 111 subprocess.check_call(['hg', 'push', '-R', baseDir])
99 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 112 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