mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
Remove LooseVersion dependency in Py script
This commit is contained in:
parent
f9fb5bcc5d
commit
8f5fbcf400
2 changed files with 11 additions and 4 deletions
13
dist/firefox/publish-signed-beta.py
vendored
13
dist/firefox/publish-signed-beta.py
vendored
|
@ -13,7 +13,6 @@ import tempfile
|
|||
import time
|
||||
import zipfile
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
from string import Template
|
||||
|
||||
# - Download target (raw) uBlock0.firefox.xpi from GitHub
|
||||
|
@ -153,6 +152,7 @@ print('Downloaded raw package saved as {0}'.format(raw_xpi_filepath))
|
|||
#
|
||||
# Convert the package to a self-hosted one: add `update_url` to the manifest
|
||||
#
|
||||
min_browser_version = '68';
|
||||
|
||||
print('Converting raw xpi package into self-hosted xpi package...')
|
||||
with zipfile.ZipFile(raw_xpi_filepath, 'r') as zipin:
|
||||
|
@ -161,6 +161,7 @@ with zipfile.ZipFile(raw_xpi_filepath, 'r') as zipin:
|
|||
data = zipin.read(item.filename)
|
||||
if item.filename == 'manifest.json':
|
||||
manifest = json.loads(bytes.decode(data))
|
||||
min_browser_version = manifest['browser_specific_settings']['gecko']['strict_min_version']
|
||||
manifest['browser_specific_settings']['gecko']['update_url'] = 'https://raw.githubusercontent.com/{0}/{1}/master/dist/firefox/updates.json'.format(github_owner, github_repo)
|
||||
data = json.dumps(manifest, indent=2, separators=(',', ': '), sort_keys=True).encode()
|
||||
zipout.writestr(item, data)
|
||||
|
@ -295,17 +296,23 @@ if response.status_code != 204:
|
|||
r = subprocess.run(['git', 'pull', 'origin', 'master'], stdout=subprocess.PIPE)
|
||||
rout = bytes.decode(r.stdout).strip()
|
||||
|
||||
def int_from_version(version):
|
||||
parts = version.split('.')
|
||||
if len(parts) == 3:
|
||||
parts.append('0')
|
||||
return int(parts[0])*10e9 + int(parts[1])*10e6 + int(parts[2])*10e3 + int(parts[3])
|
||||
|
||||
print('Update GitHub to point to newly signed self-hosted xpi package...')
|
||||
updates_json_filepath = os.path.join(projdir, 'dist', 'firefox', 'updates.json')
|
||||
with open(updates_json_filepath) as f:
|
||||
updates_json = json.load(f)
|
||||
f.close()
|
||||
previous_version = updates_json['addons'][extension_id]['updates'][0]['version']
|
||||
if LooseVersion(ext_version) > LooseVersion(previous_version):
|
||||
if int_from_version(ext_version) > int_from_version(previous_version):
|
||||
with open(os.path.join(projdir, 'dist', 'firefox', 'updates.template.json')) as f:
|
||||
template_json = Template(f.read())
|
||||
f.close()
|
||||
updates_json = template_json.substitute(ext_version=ext_version, tag_version=tag_version)
|
||||
updates_json = template_json.substitute(ext_version=ext_version, tag_version=tag_version, min_browser_version=min_browser_version)
|
||||
with open(updates_json_filepath, 'w') as f:
|
||||
f.write(updates_json)
|
||||
f.close()
|
||||
|
|
2
dist/firefox/updates.template.json
vendored
2
dist/firefox/updates.template.json
vendored
|
@ -4,7 +4,7 @@
|
|||
"updates": [
|
||||
{
|
||||
"version": "$ext_version",
|
||||
"browser_specific_settings": { "gecko": { "strict_min_version": "60" } },
|
||||
"browser_specific_settings": { "gecko": { "strict_min_version": "$min_browser_version" } },
|
||||
"update_link": "https://github.com/gorhill/uBlock/releases/download/$tag_version/uBlock0_$tag_version.firefox.signed.xpi"
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue