Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 26 matching lines...) Expand all Loading... | |
48 import buildtools.packagerGecko as packager | 49 import buildtools.packagerGecko as packager |
49 elif type == 'safari': | 50 elif type == 'safari': |
50 import buildtools.packagerSafari as packager | 51 import buildtools.packagerSafari as packager |
51 elif type == 'edge': | 52 elif type == 'edge': |
52 import buildtools.packagerEdge as packager | 53 import buildtools.packagerEdge as packager |
53 elif type == 'chrome': | 54 elif type == 'chrome': |
54 import buildtools.packagerChrome as packager | 55 import buildtools.packagerChrome as packager |
55 | 56 |
56 # Replace version number in metadata file "manually", ConfigParser will mess | 57 # Replace version number in metadata file "manually", ConfigParser will mess |
57 # up the order of lines. | 58 # up the order of lines. |
58 metadata = packager.readMetadata(baseDir, type) | 59 metadata = readMetadata(baseDir, type) |
59 with open(metadata.option_source('general', 'version'), 'r+b') as file: | 60 with open(metadata.option_source('general', 'version'), 'r+b') as file: |
60 rawMetadata = file.read() | 61 rawMetadata = file.read() |
61 rawMetadata = re.sub( | 62 rawMetadata = re.sub( |
62 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, | 63 r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version, |
63 rawMetadata, flags=re.I | re.M | 64 rawMetadata, flags=re.I | re.M |
64 ) | 65 ) |
65 | 66 |
66 file.seek(0) | 67 file.seek(0) |
67 file.write(rawMetadata) | 68 file.write(rawMetadata) |
68 file.truncate() | 69 file.truncate() |
69 | 70 |
70 # Read extension name from locale data | 71 # Read extension name from locale data |
71 import buildtools.packagerGecko as packagerGecko | 72 import buildtools.packagerGecko as packagerGecko |
72 if type == 'gecko': | 73 if type == 'gecko': |
73 locales_base = baseDir | 74 locales_base = baseDir |
74 else: | 75 else: |
75 # 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 |
76 locales_base = os.path.join(baseDir, 'adblockplus') | 77 locales_base = os.path.join(baseDir, 'adblockplus') |
77 | 78 |
78 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) | 79 locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defa ultLocale]) |
79 extensionName = locales[packagerGecko.defaultLocale]['name'] | 80 extensionName = locales[packagerGecko.defaultLocale]['name'] |
80 | 81 |
81 # Now commit the change and tag it | 82 # Now commit the change and tag it |
82 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)]) |
83 tag_name = version | 84 tag_name = version |
84 if type in {'safari', 'edge'}: | 85 if type in {'safari', 'edge'}: |
85 tag_name += '-' + type | 86 tag_name = '{}-{}'.format(tag_name, type) |
Sebastian Noack
2016/10/27 10:57:32
Nit: As per our coding style, we use the format()
kzar
2016/10/27 15:25:58
Do you insist? IMO `tag_name += '-' + type` is nic
Sebastian Noack
2016/10/27 15:41:59
This might be a matter of taste. I think the strin
kzar
2016/10/27 15:54:25
Done.
| |
86 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) | 87 subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', tag_name]) |
87 | 88 |
88 # Create a release build | 89 # Create a release build |
89 downloads = [] | 90 downloads = [] |
90 if type == 'gecko': | 91 if type == 'gecko': |
91 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'xpi')) | 92 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'xpi')) |
92 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | 93 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
93 downloads.append(buildPath) | 94 downloads.append(buildPath) |
94 elif type == 'chrome': | 95 elif type == 'chrome': |
95 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). | 96 # Create both signed and unsigned Chrome builds (the latter for Chrome W eb Store). |
96 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'crx')) | 97 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) |
97 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) | 98 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) |
98 downloads.append(buildPath) | 99 downloads.append(buildPath) |
99 | 100 |
100 buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(me tadata, version, 'zip')) | 101 buildPathUnsigned = os.path.join(baseDir, getDefaultFileName(metadata, v ersion, 'zip')) |
101 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) | 102 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) |
102 elif type == 'safari': | 103 elif type == 'safari': |
103 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'safariextz')) | 104 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) |
104 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) | 105 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) |
105 downloads.append(buildPath) | 106 downloads.append(buildPath) |
106 elif type == 'edge': | 107 elif type == 'edge': |
107 # We only offer the Edge extension for use through the Windows Store | 108 # We only offer the Edge extension for use through the Windows Store |
108 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'appx')) | 109 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) |
109 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) | 110 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
110 downloads.append(buildPath) | 111 downloads.append(buildPath) |
111 | 112 |
112 # Create source archive | 113 # Create source archive |
113 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 114 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
114 create_sourcearchive(baseDir, archivePath) | 115 create_sourcearchive(baseDir, archivePath) |
115 downloads.append(archivePath) | 116 downloads.append(archivePath) |
116 | 117 |
117 # Now add the downloads and commit | 118 # Now add the downloads and commit |
118 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 119 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
119 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)]) |
120 | 121 |
121 # Push all changes | 122 # Push all changes |
122 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 123 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
123 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 124 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
LEFT | RIGHT |