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

Side by Side Diff: packager.py

Issue 29611593: Issue 5996 - Release consistent versions across WebExtensions (Closed) Base URL: https://codereview.adblockplus.org/29609559/
Patch Set: Addressing comments Created Nov. 28, 2017, 1:27 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
OLDNEW
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 # Note: These are the base functions common to all packagers, the actual 5 # Note: These are the base functions common to all packagers, the actual
6 # packagers are implemented in packagerChrome and packagerEdge. 6 # packagers are implemented in packagerChrome and packagerEdge.
7 7
8 import sys 8 import sys
9 import os 9 import os
10 import re 10 import re
11 import subprocess 11 import subprocess
12 import json 12 import json
13 import zipfile 13 import zipfile
14 from StringIO import StringIO 14 from StringIO import StringIO
15 from chainedconfigparser import ChainedConfigParser 15 from chainedconfigparser import ChainedConfigParser
16 16
17 import buildtools 17 import buildtools
18 18
19 EXTENSIONS = {
20 'edge': 'appx',
21 'gecko': 'xpi',
22 'chrome': {'unsigned': 'zip', 'signed': 'crx'},
23 }
24
19 25
20 def getDefaultFileName(metadata, version, ext): 26 def getDefaultFileName(metadata, version, ext):
21 return '%s-%s.%s' % (metadata.get('general', 'basename'), version, ext) 27 return '%s-%s.%s' % (metadata.get('general', 'basename'), version, ext)
22 28
23 29
30 def get_extension(platform, has_key_file=False):
31 extension = EXTENSIONS[platform]
32
33 try:
34 if has_key_file:
35 key = 'signed'
36 else:
37 key = 'unsigned'
38 extension = extension[key]
39 except (KeyError, TypeError):
40 pass
41
42 return extension
43
44
24 def getMetadataPath(baseDir, type): 45 def getMetadataPath(baseDir, type):
25 return os.path.join(baseDir, 'metadata.%s' % type) 46 return os.path.join(baseDir, 'metadata.%s' % type)
26 47
27 48
28 def getDevEnvPath(baseDir, type): 49 def getDevEnvPath(baseDir, type):
29 return os.path.join(baseDir, 'devenv.' + type) 50 return os.path.join(baseDir, 'devenv.' + type)
30 51
31 52
32 def readMetadata(baseDir, type): 53 def readMetadata(baseDir, type):
33 parser = ChainedConfigParser() 54 parser = ChainedConfigParser()
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 156
136 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED): 157 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
137 with zipfile.ZipFile(outFile, 'w', compression) as zf: 158 with zipfile.ZipFile(outFile, 'w', compression) as zf:
138 for name in sorted(self, key=sortKey): 159 for name in sorted(self, key=sortKey):
139 zf.writestr(name, self[name]) 160 zf.writestr(name, self[name])
140 161
141 def zipToString(self, sortKey=None): 162 def zipToString(self, sortKey=None):
142 buffer = StringIO() 163 buffer = StringIO()
143 self.zip(buffer, sortKey=sortKey) 164 self.zip(buffer, sortKey=sortKey)
144 return buffer.getvalue() 165 return buffer.getvalue()
OLDNEW
« no previous file with comments | « localeTools.py ('k') | packagerChrome.py » ('j') | releaseAutomation.py » ('J')

Powered by Google App Engine
This is Rietveld