| 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 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import codecs | 7 import codecs |
| 8 import subprocess | 8 import subprocess |
| 9 import tarfile | 9 import tarfile |
| 10 import json | 10 import json |
| 11 | 11 |
| 12 from packager import readMetadata, getDefaultFileName |
| 12 | 13 |
| 13 def get_dependencies(prefix, repos): | 14 def get_dependencies(prefix, repos): |
| 14 from ensure_dependencies import read_deps, safe_join | 15 from ensure_dependencies import read_deps, safe_join |
| 15 repo = repos[prefix] | 16 repo = repos[prefix] |
| 16 deps = read_deps(repo) | 17 deps = read_deps(repo) |
| 17 if deps: | 18 if deps: |
| 18 for subpath in deps: | 19 for subpath in deps: |
| 19 if subpath.startswith('_'): | 20 if subpath.startswith('_'): |
| 20 continue | 21 continue |
| 21 depprefix = prefix + subpath + '/' | 22 depprefix = prefix + subpath + '/' |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig
nore'): | 37 if os.path.basename(fileinfo.name) in ('.hgtags', '.hgig
nore'): |
| 37 continue | 38 continue |
| 38 filedata = repoarchive.extractfile(fileinfo) | 39 filedata = repoarchive.extractfile(fileinfo) |
| 39 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name
) | 40 fileinfo.name = re.sub(r'^[^/]+/', prefix, fileinfo.name
) |
| 40 archive.addfile(fileinfo, filedata) | 41 archive.addfile(fileinfo, filedata) |
| 41 finally: | 42 finally: |
| 42 process.stdout.close() | 43 process.stdout.close() |
| 43 process.wait() | 44 process.wait() |
| 44 | 45 |
| 45 | 46 |
| 46 def run(baseDir, type, version, keyFiles, downloadsRepo): | 47 def run(baseDir, type, version, keyFile, downloadsRepo): |
| 47 if type == 'gecko': | 48 if type == 'gecko': |
| 48 import buildtools.packagerGecko as packager | 49 import buildtools.packagerGecko as packager |
| 50 elif type == 'safari': |
| 51 import buildtools.packagerSafari as packager |
| 52 elif type == 'edge': |
| 53 import buildtools.packagerEdge as packager |
| 49 elif type == 'chrome': | 54 elif type == 'chrome': |
| 50 import buildtools.packagerChrome as packager | 55 import buildtools.packagerChrome as packager |
| 51 | 56 |
| 52 # Replace version number in metadata file "manually", ConfigParser will mess | 57 # Replace version number in metadata file "manually", ConfigParser will mess |
| 53 # up the order of lines. | 58 # up the order of lines. |
| 54 metadata = packager.readMetadata(baseDir, type) | 59 metadata = readMetadata(baseDir, type) |
| 55 with open(metadata.option_source('general', 'version'), 'r+b') as file: | 60 with open(metadata.option_source('general', 'version'), 'r+b') as file: |
| 56 rawMetadata = file.read() | 61 rawMetadata = file.read() |
| 57 rawMetadata = re.sub( | 62 rawMetadata = re.sub( |
| 58 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 63 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
| 59 rawMetadata, flags=re.I | re.M | 64 rawMetadata, flags=re.I | re.M |
| 60 ) | 65 ) |
| 61 | 66 |
| 62 file.seek(0) | 67 file.seek(0) |
| 63 file.write(rawMetadata) | 68 file.write(rawMetadata) |
| 64 file.truncate() | 69 file.truncate() |
| 65 | 70 |
| 66 # Read extension name from locale data | 71 # Read extension name from locale data |
| 67 import buildtools.packagerGecko as packagerGecko | 72 import buildtools.packagerGecko as packagerGecko |
| 68 if type == 'gecko': | 73 if type == 'gecko': |
| 69 locales_base = baseDir | 74 locales_base = baseDir |
| 70 else: | 75 else: |
| 71 # This is somewhat of a hack but reading out locale import config here w
ould be too much | 76 # This is somewhat of a hack but reading out locale import config here w
ould be too much |
| 72 locales_base = os.path.join(baseDir, 'adblockplus') | 77 locales_base = os.path.join(baseDir, 'adblockplus') |
| 73 | 78 |
| 74 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa
ultLocale]) | 79 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa
ultLocale]) |
| 75 extensionName = locales[packagerGecko.defaultLocale]['name'] | 80 extensionName = locales[packagerGecko.defaultLocale]['name'] |
| 76 | 81 |
| 77 # Now commit the change and tag it | 82 # Now commit the change and tag it |
| 78 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) | 83 subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s
' % (extensionName, version)]) |
| 79 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version]) | 84 tag_name = version |
| 85 if type in {'safari', 'edge'}: |
| 86 tag_name = '{}-{}'.format(tag_name, type) |
| 87 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
| 80 | 88 |
| 81 # Create a release build | 89 # Create a release build |
| 82 downloads = [] | 90 downloads = [] |
| 83 if type == 'gecko': | 91 if type == 'gecko': |
| 84 keyFile = keyFiles[0] if keyFiles else None | 92 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'xpi')) |
| 85 metadata = packager.readMetadata(baseDir, type) | 93 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) |
| 86 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta
data, version, 'xpi')) | 94 downloads.append(buildPath) |
| 95 elif type == 'chrome': |
| 96 # Create both signed and unsigned Chrome builds (the latter for Chrome W
eb Store). |
| 97 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'crx')) |
| 87 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) | 98 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFile) |
| 88 downloads.append(buildPath) | 99 downloads.append(buildPath) |
| 89 elif type == 'chrome': | 100 |
| 90 # We actually have to create three different builds: signed and unsigned | 101 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v
ersion, 'zip')) |
| 91 # Chrome builds (the latter for Chrome Web Store), and a signed Safari b
uild. | 102 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) |
| 92 metadata = packager.readMetadata(baseDir, type) | 103 elif type == 'safari': |
| 93 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta
data, version, 'crx')) | 104 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'safariextz')) |
| 94 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True, keyFile=keyFiles[0]) | 105 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB
uild=True, keyFile=keyFile) |
| 95 downloads.append(buildPath) | 106 downloads.append(buildPath) |
| 96 | 107 elif type == 'edge': |
| 97 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(me
tadata, version, 'zip')) | 108 # We only offer the Edge extension for use through the Windows Store |
| 98 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele
aseBuild=True, keyFile=None) | 109 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver
sion, 'appx')) |
| 99 | 110 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild
=True) |
| 100 import buildtools.packagerSafari as packagerSafari | 111 downloads.append(buildPath) |
| 101 metadataSafari = packagerSafari.readMetadata(baseDir, 'safari') | |
| 102 buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultF
ileName(metadataSafari, version, 'safariextz')) | |
| 103 packagerSafari.createBuild(baseDir, type='safari', outFile=buildPathSafa
ri, releaseBuild=True, keyFile=keyFiles[1]) | |
| 104 downloads.append(buildPathSafari) | |
| 105 | 112 |
| 106 # Create source archive | 113 # Create source archive |
| 107 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 114 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
| 108 create_sourcearchive(baseDir, archivePath) | 115 create_sourcearchive(baseDir, archivePath) |
| 109 downloads.append(archivePath) | 116 downloads.append(archivePath) |
| 110 | 117 |
| 111 # Now add the downloads and commit | 118 # Now add the downloads and commit |
| 112 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 119 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
| 113 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) | 120 subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing
%s %s' % (extensionName, version)]) |
| 114 | 121 |
| 115 # Push all changes | 122 # Push all changes |
| 116 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 123 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
| 117 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 124 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
| OLD | NEW |