| 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 operator | 8 import operator |
| 9 import re | 9 import re |
| 10 import codecs | 10 import codecs |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 def update_metadata(metadata, version): | 179 def update_metadata(metadata, version): |
| 180 """Replace version number in metadata file "manually". | 180 """Replace version number in metadata file "manually". |
| 181 | 181 |
| 182 The ConfigParser would mess up the order of lines. | 182 The ConfigParser would mess up the order of lines. |
| 183 """ | 183 """ |
| 184 with open(metadata.option_source('general', 'version'), 'r+b') as fp: | 184 with open(metadata.option_source('general', 'version'), 'r+b') as fp: |
| 185 rawMetadata = fp.read() | 185 rawMetadata = fp.read() |
| 186 rawMetadata = re.sub( | 186 rawMetadata = re.sub( |
| 187 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 187 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
| 188 rawMetadata, flags=re.I | re.M | 188 rawMetadata, flags=re.I | re.M, |
| 189 ) | 189 ) |
| 190 | 190 |
| 191 fp.seek(0) | 191 fp.seek(0) |
| 192 fp.write(rawMetadata) | 192 fp.write(rawMetadata) |
| 193 fp.truncate() | 193 fp.truncate() |
| 194 | 194 |
| 195 | 195 |
| 196 def create_build(platform, base_dir, target_path, version, key_file=None): | 196 def create_build(platform, base_dir, target_path, version, key_file=None): |
| 197 """Create a build for the target platform and version.""" | 197 """Create a build for the target platform and version.""" |
| 198 if platform == 'edge': | 198 if platform == 'edge': |
| 199 import buildtools.packagerEdge as packager | 199 import buildtools.packagerEdge as packager |
| 200 else: | 200 else: |
| 201 import buildtools.packagerChrome as packager | 201 import buildtools.packagerChrome as packager |
| 202 | 202 |
| 203 metadata = readMetadata(base_dir, platform) | 203 metadata = readMetadata(base_dir, platform) |
| 204 update_metadata(metadata, version) | 204 update_metadata(metadata, version) |
| 205 | 205 |
| 206 build_path = os.path.join( | 206 build_path = os.path.join( |
| 207 target_path, | 207 target_path, |
| 208 getDefaultFileName(metadata, version, | 208 getDefaultFileName(metadata, version, |
| 209 get_extension(platform, key_file is not None)) | 209 get_extension(platform, key_file is not None)), |
| 210 ) | 210 ) |
| 211 | 211 |
| 212 packager.createBuild(base_dir, type=platform, outFile=build_path, | 212 packager.createBuild(base_dir, type=platform, outFile=build_path, |
| 213 releaseBuild=True, keyFile=key_file) | 213 releaseBuild=True, keyFile=key_file) |
| 214 | 214 |
| 215 return build_path | 215 return build_path |
| 216 | 216 |
| 217 | 217 |
| 218 def release_commit(base_dir, extension_name, version, platforms): | 218 def release_commit(base_dir, extension_name, version, platforms): |
| 219 """Create a release commit with a representative message.""" | 219 """Create a release commit with a representative message.""" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 used_key_file = None | 263 used_key_file = None |
| 264 if platform == 'chrome': | 264 if platform == 'chrome': |
| 265 # Currently, only chrome builds are provided by us as signed | 265 # Currently, only chrome builds are provided by us as signed |
| 266 # packages. Create an unsigned package in base_dir which should be | 266 # packages. Create an unsigned package in base_dir which should be |
| 267 # uploaded to the Chrome Web Store | 267 # uploaded to the Chrome Web Store |
| 268 create_build(platform, baseDir, baseDir, version) | 268 create_build(platform, baseDir, baseDir, version) |
| 269 used_key_file = keyFile | 269 used_key_file = keyFile |
| 270 | 270 |
| 271 downloads.append( | 271 downloads.append( |
| 272 create_build(platform, baseDir, downloads_repo, version, | 272 create_build(platform, baseDir, downloads_repo, version, |
| 273 used_key_file) | 273 used_key_file), |
| 274 ) | 274 ) |
| 275 | 275 |
| 276 # Only create one commit, one tag and one source archive for all | 276 # Only create one commit, one tag and one source archive for all |
| 277 # platforms | 277 # platforms |
| 278 archive_path = os.path.join( | 278 archive_path = os.path.join( |
| 279 downloads_repo, | 279 downloads_repo, |
| 280 'adblockplus-{}-source.tgz'.format(release_identifier), | 280 'adblockplus-{}-source.tgz'.format(release_identifier), |
| 281 ) | 281 ) |
| 282 create_sourcearchive(baseDir, archive_path) | 282 create_sourcearchive(baseDir, archive_path) |
| 283 downloads.append(archive_path) | 283 downloads.append(archive_path) |
| 284 try: | 284 try: |
| 285 release_commit(baseDir, extension_name, version, target_platforms) | 285 release_commit(baseDir, extension_name, version, target_platforms) |
| 286 except subprocess.CalledProcessError as e: | 286 except subprocess.CalledProcessError as e: |
| 287 if not (re_release and 'nothing changed' in e.output): | 287 if not (re_release and 'nothing changed' in e.output): |
| 288 raise | 288 raise |
| 289 | 289 |
| 290 release_tag(baseDir, release_identifier, extension_name) | 290 release_tag(baseDir, release_identifier, extension_name) |
| 291 | 291 |
| 292 # Now add the downloads and commit | 292 # Now add the downloads and commit |
| 293 subprocess.check_call(['hg', 'add', '-R', downloads_repo] + downloads) | 293 subprocess.check_call(['hg', 'add', '-R', downloads_repo] + downloads) |
| 294 release_commit(downloads_repo, extension_name, version, target_platforms) | 294 release_commit(downloads_repo, extension_name, version, target_platforms) |
| 295 | 295 |
| 296 # Push all changes | 296 # Push all changes |
| 297 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 297 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
| 298 subprocess.check_call(['hg', 'push', '-R', downloads_repo]) | 298 subprocess.check_call(['hg', 'push', '-R', downloads_repo]) |
| OLD | NEW |