Left: | ||
Right: |
OLD | NEW |
---|---|
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 from __future__ import print_function | 5 from __future__ import print_function |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 import codecs | 9 import codecs |
10 import subprocess | 10 import subprocess |
11 import tarfile | 11 import tarfile |
12 import json | 12 import json |
13 | 13 |
14 from packager import readMetadata, getDefaultFileName | 14 from packager import readMetadata, getDefaultFileName |
15 from localeTools import readFile | |
Sebastian Noack
2017/10/03 02:22:39
Why did you add this import?
tlucas
2017/10/04 11:48:38
This was not intentional, removed it.
| |
15 | 16 |
16 | 17 |
17 def get_dependencies(prefix, repos): | 18 def get_dependencies(prefix, repos): |
18 from ensure_dependencies import read_deps, safe_join | 19 from ensure_dependencies import read_deps, safe_join |
19 repo = repos[prefix] | 20 repo = repos[prefix] |
20 deps = read_deps(repo) | 21 deps = read_deps(repo) |
21 if deps: | 22 if deps: |
22 for subpath in deps: | 23 for subpath in deps: |
23 if subpath.startswith('_'): | 24 if subpath.startswith('_'): |
24 continue | 25 continue |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 if repo_has_outgoing(): | 112 if repo_has_outgoing(): |
112 return continue_with_outgoing() | 113 return continue_with_outgoing() |
113 return True | 114 return True |
114 | 115 |
115 | 116 |
116 def run(baseDir, type, version, keyFile, downloadsRepo): | 117 def run(baseDir, type, version, keyFile, downloadsRepo): |
117 if not can_safely_release(baseDir, downloadsRepo): | 118 if not can_safely_release(baseDir, downloadsRepo): |
118 print('Aborting release.') | 119 print('Aborting release.') |
119 return 1 | 120 return 1 |
120 | 121 |
121 if type == 'gecko': | 122 if type == 'safari': |
122 import buildtools.packagerGecko as packager | |
123 elif type == 'safari': | |
124 import buildtools.packagerSafari as packager | 123 import buildtools.packagerSafari as packager |
125 elif type == 'edge': | 124 elif type == 'edge': |
126 import buildtools.packagerEdge as packager | 125 import buildtools.packagerEdge as packager |
127 elif type == 'chrome': | 126 elif type == 'chrome': |
128 import buildtools.packagerChrome as packager | 127 import buildtools.packagerChrome as packager |
129 | 128 |
130 # Replace version number in metadata file "manually", ConfigParser will mess | 129 # Replace version number in metadata file "manually", ConfigParser will mess |
131 # up the order of lines. | 130 # up the order of lines. |
132 metadata = readMetadata(baseDir, type) | 131 metadata = readMetadata(baseDir, type) |
133 with open(metadata.option_source('general', 'version'), 'r+b') as file: | 132 with open(metadata.option_source('general', 'version'), 'r+b') as file: |
134 rawMetadata = file.read() | 133 rawMetadata = file.read() |
135 rawMetadata = re.sub( | 134 rawMetadata = re.sub( |
136 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 135 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
137 rawMetadata, flags=re.I | re.M | 136 rawMetadata, flags=re.I | re.M |
138 ) | 137 ) |
139 | 138 |
140 file.seek(0) | 139 file.seek(0) |
141 file.write(rawMetadata) | 140 file.write(rawMetadata) |
142 file.truncate() | 141 file.truncate() |
143 | 142 |
144 # Read extension name from locale data | 143 # Read extension name from locale data |
145 import buildtools.packagerGecko as packagerGecko | 144 locales_base = os.path.join(baseDir, 'adblockplus') |
146 if type == 'gecko': | |
147 locales_base = baseDir | |
148 else: | |
149 # This is somewhat of a hack but reading out locale import config here w ould be too much | |
150 locales_base = os.path.join(baseDir, 'adblockplus') | |
151 | 145 |
152 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) | 146 with open(os.path.join(locales_base, 'chrome', 'locale', |
153 extensionName = locales[packagerGecko.defaultLocale]['name'] | 147 packager.defaultLocale.replace('_', '-'), |
148 'meta.json'), | |
149 'r') as fp: | |
150 extensionName = json.load(fp)['name'] | |
154 | 151 |
155 # Now commit the change and tag it | 152 # Now commit the change and tag it |
156 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) | 153 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s ' % (extensionName, version)]) |
157 tag_name = version | 154 tag_name = version |
158 if type in {'safari', 'edge'}: | 155 if type in {'safari', 'edge'}: |
159 tag_name = '{}-{}'.format(tag_name, type) | 156 tag_name = '{}-{}'.format(tag_name, type) |
160 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 157 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
161 | 158 |
162 # Create a release build | 159 # Create a release build |
163 downloads = [] | 160 downloads = [] |
164 if type == 'gecko': | 161 if type == 'chrome': |
165 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'xpi')) | |
166 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | |
167 downloads.append(buildPath) | |
168 elif type == 'chrome': | |
169 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). | 162 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). |
170 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) | 163 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) |
171 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) | 164 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) |
172 downloads.append(buildPath) | 165 downloads.append(buildPath) |
173 | 166 |
174 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip')) | 167 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip')) |
175 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) | 168 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) |
176 elif type == 'safari': | 169 elif type == 'safari': |
177 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) | 170 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) |
178 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) | 171 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) |
179 downloads.append(buildPath) | 172 downloads.append(buildPath) |
180 elif type == 'edge': | 173 elif type == 'edge': |
181 # We only offer the Edge extension for use through the Windows Store | 174 # We only offer the Edge extension for use through the Windows Store |
182 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) | 175 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) |
183 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | 176 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
184 downloads.append(buildPath) | 177 downloads.append(buildPath) |
185 | 178 |
186 # Create source archive | 179 # Create source archive |
187 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 180 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
188 create_sourcearchive(baseDir, archivePath) | 181 create_sourcearchive(baseDir, archivePath) |
189 downloads.append(archivePath) | 182 downloads.append(archivePath) |
190 | 183 |
191 # Now add the downloads and commit | 184 # Now add the downloads and commit |
192 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 185 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
193 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) | 186 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]) |
194 | 187 |
195 # Push all changes | 188 # Push all changes |
196 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 189 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
197 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 190 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
OLD | NEW |