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 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 |
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 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]) | |
84 | 88 |
85 # Create a release build | 89 # Create a release build |
86 downloads = [] | 90 downloads = [] |
87 if type == 'gecko': | 91 if type == 'gecko': |
88 keyFile = keyFiles[0] if keyFiles else None | 92 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'xpi')) |
89 metadata = packager.readMetadata(baseDir, type) | 93 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
Wladimir Palant
2016/10/20 10:03:08
This statement is unnecessary - here and in all th
kzar
2016/10/20 12:09:36
Done.
| |
90 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'xpi')) | |
91 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) | |
Wladimir Palant
2016/10/20 10:03:08
While at it, could you remove the keyFile paramete
kzar
2016/10/20 12:09:36
Done.
| |
92 downloads.append(buildPath) | 94 downloads.append(buildPath) |
93 elif type == 'chrome': | 95 elif type == 'chrome': |
94 # 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). |
95 metadata = packager.readMetadata(baseDir, type) | 97 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'crx')) |
96 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'crx')) | 98 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFile) |
97 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True, keyFile=keyFiles[0]) | |
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 metadata = packager.readMetadata(baseDir, type) | 104 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'safariextz')) |
104 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'safariextz')) | 105 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFile) |
105 packager.createBuild(baseDir, type='safari', outFile=buildPath, releaseB uild=True, keyFile=keyFiles[0]) | |
106 downloads.append(buildPath) | 106 downloads.append(buildPath) |
107 elif type == 'edge': | 107 elif type == 'edge': |
108 # 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 |
109 metadata = packager.readMetadata(baseDir, type) | 109 buildPath = os.path.join(downloadsRepo, getDefaultFileName(metadata, ver sion, 'appx')) |
110 buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(meta data, version, 'appx')) | 110 packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild =True) |
111 packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, rele aseBuild=True, keyFile=None) | 111 downloads.append(buildPath) |
Sebastian Noack
2016/10/19 14:26:14
I suppose the absence of downloads.append(...) mea
kzar
2016/10/19 14:31:03
That's the idea. I followed the example of the uns
Sebastian Noack
2016/10/19 15:08:24
Sure, I just thought that it might be useful to ar
Wladimir Palant
2016/10/20 10:03:08
This file should definitely be added to the downlo
kzar
2016/10/20 12:09:36
Done.
| |
112 | |
113 | 112 |
114 # Create source archive | 113 # Create source archive |
115 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' | 114 archivePath = os.path.splitext(buildPath)[0] + '-source.tgz' |
116 create_sourcearchive(baseDir, archivePath) | 115 create_sourcearchive(baseDir, archivePath) |
117 downloads.append(archivePath) | 116 downloads.append(archivePath) |
118 | 117 |
119 # Now add the downloads and commit | 118 # Now add the downloads and commit |
120 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) | 119 subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads) |
121 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)]) |
122 | 121 |
123 # Push all changes | 122 # Push all changes |
124 subprocess.check_call(['hg', 'push', '-R', baseDir]) | 123 subprocess.check_call(['hg', 'push', '-R', baseDir]) |
125 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) | 124 subprocess.check_call(['hg', 'push', '-R', downloadsRepo]) |
LEFT | RIGHT |