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 remaining comment Created Sept. 18, 2014, 7:23 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 try:
29 with tarfile.open(fileobj=process.stdout, mode='r|') as repoarchive:
30 for fileinfo in repoarchive:
31 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgignore'):
32 continue
33 filedata = repoarchive.extractfile(fileinfo)
34 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name)
35 archive.addfile(fileinfo, filedata)
36 finally:
37 process.stdout.close()
38 process.wait()
9 39
10 def run(baseDir, type, version, keyFiles, downloadsRepo): 40 def run(baseDir, type, version, keyFiles, downloadsRepo):
11 if type == "gecko": 41 if type == "gecko":
12 import buildtools.packagerGecko as packager 42 import buildtools.packagerGecko as packager
13 elif type == "chrome": 43 elif type == "chrome":
14 import buildtools.packagerChrome as packager 44 import buildtools.packagerChrome as packager
15 45
16 # Replace version number in metadata file "manually", ConfigParser will mess 46 # Replace version number in metadata file "manually", ConfigParser will mess
17 # up the order of lines. 47 # up the order of lines.
18 metadata = packager.readMetadata(baseDir, type) 48 metadata = packager.readMetadata(baseDir, type)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 downloads.append(buildPathOpera) 97 downloads.append(buildPathOpera)
68 98
69 import buildtools.packagerSafari as packagerSafari 99 import buildtools.packagerSafari as packagerSafari
70 metadataSafari = packagerSafari.readMetadata(baseDir, "safari") 100 metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
71 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileN ame(baseDir, metadataSafari, version, 'safariextz')) 101 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]) 102 packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
73 downloads.append(buildPathSafari) 103 downloads.append(buildPathSafari)
74 104
75 # Create source archive 105 # Create source archive
76 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' 106 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
77 107 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) 108 downloads.append(archivePath)
92 109
93 # Now add the downloads and commit 110 # Now add the downloads and commit
94 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) 111 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
95 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)])
96 113
97 # Push all changes 114 # Push all changes
98 subprocess.check_call(['hg', 'push', '-R', baseDir]) 115 subprocess.check_call(['hg', 'push', '-R', baseDir])
99 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) 116 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