From efd098270d469734f05596a21c0bfcd54bae7820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 8 Oct 2021 18:34:04 +0200 Subject: [PATCH 1/3] Fix extensions links --- conf/ldap_authentication2.src | 4 ++-- conf/ldap_authorization.src | 4 ++-- conf/ldap_groups.src | 4 ++-- conf/ldap_provider.src | 4 ++-- conf/ldap_userinfo.src | 4 ++-- conf/pluggable_auth.src | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/conf/ldap_authentication2.src b/conf/ldap_authentication2.src index 191d644..38ac5fa 100644 --- a/conf/ldap_authentication2.src +++ b/conf/ldap_authentication2.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPAuthentication2-REL1_35-dec2765.tar.gz -SOURCE_SUM=85415f420647c3b586c6a9fb4a5326fc6dfa47f66f5ccb0842108a7588db810f +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPAuthentication2-REL1_36-8fce73c.tar.gz +SOURCE_SUM=238ed3dd414798d28c762cf0bff003ff2de1b0be50644864f3ea2b9bffd77440 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/ldap_authorization.src b/conf/ldap_authorization.src index 87f68da..15557ab 100644 --- a/conf/ldap_authorization.src +++ b/conf/ldap_authorization.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPProvider-REL1_35-04ae604.tar.gz -SOURCE_SUM=5cf7b0f52d7cf1732f4fd22599c0d9c9612cd5fa80325c96740e72f89fa5c9c8 +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPAuthorization-REL1_36-bc6b46e.tar.gz +SOURCE_SUM=eadd43bfefc0aa7d00794beff11736224e794b27e03160d17d35863d2fe56d5c SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/ldap_groups.src b/conf/ldap_groups.src index 80a2601..17d703f 100644 --- a/conf/ldap_groups.src +++ b/conf/ldap_groups.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPGroups-REL1_35-118aecb.tar.gz -SOURCE_SUM=89c1d48f20864526c558c5ccfc44f8e8dab46f82a1a9ca3120833cf46b57050b +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPGroups-REL1_36-14d3b1a.tar.gz +SOURCE_SUM=c8f9d2546117430f1360029d81e6a11d28a15553d7e823e00654c3ebd09be465 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/ldap_provider.src b/conf/ldap_provider.src index 87f68da..c48f17c 100644 --- a/conf/ldap_provider.src +++ b/conf/ldap_provider.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPProvider-REL1_35-04ae604.tar.gz -SOURCE_SUM=5cf7b0f52d7cf1732f4fd22599c0d9c9612cd5fa80325c96740e72f89fa5c9c8 +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPProvider-REL1_36-15aa175.tar.gz +SOURCE_SUM=214d40665c78c4193ef39ae78875af2090a16a5ad6420dfd2d25fe9e3929f9f3 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/ldap_userinfo.src b/conf/ldap_userinfo.src index f00fb6e..15fbd32 100644 --- a/conf/ldap_userinfo.src +++ b/conf/ldap_userinfo.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPUserInfo-REL1_35-d04327e.tar.gz -SOURCE_SUM=1a42c5a6e47db05533d302cdcc61691a534126597ab36038d877178df018083d +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/LDAPUserInfo-REL1_36-e8a8823.tar.gz +SOURCE_SUM=450dfd47e1da297eace5d76aeba1b7820023d210209633a3434e043a69f40798 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/pluggable_auth.src b/conf/pluggable_auth.src index ec324ad..30be9b0 100644 --- a/conf/pluggable_auth.src +++ b/conf/pluggable_auth.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_35-e5976c0.tar.gz -SOURCE_SUM=40d21142612a20356c72d6b1a61d7b206255154455983ab4ed7c43fb851039cf +SOURCE_URL=https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_36-087cb4c.tar.gz +SOURCE_SUM=868a7884c38b132e84017f85066d2f870f78d62a21bb9bb9172cc0c4aaaf024d SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false From 634c468840cde9345375b45f0e5ae5ecc02b7420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 8 Oct 2021 18:49:20 +0200 Subject: [PATCH 2/3] Update update_extensions.py --- update_extensions.py | 96 ++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/update_extensions.py b/update_extensions.py index 0b80d11..2f0bb52 100755 --- a/update_extensions.py +++ b/update_extensions.py @@ -1,20 +1,29 @@ #!/usr/bin/env python3 +""" +This tool updates conf/*.src according to the available extension version at wmflabs.org +""" +import sys import json -from os import replace import urllib.request from html.parser import HTMLParser import subprocess import hashlib -import sys, fileinput +import fileinput +from typing import List -extensions_host_url = 'https://extdist.wmflabs.org/dist/extensions/' +EXTENSIONS_HOST_URL = 'https://extdist.wmflabs.org/dist/extensions/' -def get_all_extensions(): - webpage = urllib.request.urlopen(extensions_host_url).read().decode('utf-8') + +def get_all_extensions() -> List[str]: + """Get all available extensions.""" + with urllib.request.urlopen(EXTENSIONS_HOST_URL) as page: + webpage = page.read().decode('utf-8') class MyHTMLParser(HTMLParser): + """Custom HTMLParser""" links = [] + def handle_starttag(self, tag, attrs): # Only parse the 'anchor' tag. if tag == 'a': @@ -28,89 +37,96 @@ def get_all_extensions(): parser.feed(webpage) return parser.links -def get_mediawiki_ext_version(): - with open('manifest.json') as manifest_json: + +def get_mediawiki_ext_version() -> str: + """Returns the mediawiki version for extensions.""" + with open('manifest.json', encoding='utf-8') as manifest_json: manifest = json.load(manifest_json) mediawiki_version = manifest['version'].split('~')[0] mediawiki_ext_version = '_'.join(mediawiki_version.split('.')[0:2]) return mediawiki_ext_version -def get_extensions_for_version(extensions, version): - exts = [ ext for ext in extensions if version in ext ] +def get_extensions_for_version(extensions: List[str], version: str) -> List[str]: + """Returns available extensions compatible with mediawiki version.""" + exts = [ext for ext in extensions if version in ext] return exts - ############################################################################### -def sha256sum(filename): +def sha256sum(filename: str) -> str: + """Calculate the sha256 of a file.""" sha256_hash = hashlib.sha256() - with open(filename,"rb") as f: + with open(filename, "rb") as file: # Read and update hash string value in blocks of 4K - for byte_block in iter(lambda: f.read(4096),b""): + for byte_block in iter(lambda: file.read(4096), b""): sha256_hash.update(byte_block) return sha256_hash.hexdigest() -def replace_line_startingwith(file, startingwith, new_line): +def replace_line_startingwith(file: str, startingwith: str, new_line: str): + """""" for line in fileinput.input(file, inplace=1): if line.startswith(startingwith): line = new_line + '\n' sys.stdout.write(line) - pass -def update_source_file(srcfile, url, shasum): + +def update_source_file(srcfile: str, url: str): filename = url.rsplit('/', 1)[1] urllib.request.urlretrieve(url, filename) - hash = sha256sum(filename) + hashsum = sha256sum(filename) - replace_line_startingwith(srcfile, 'SOURCE_URL=', 'SOURCE_URL={}'.format(url)) - replace_line_startingwith(srcfile, 'SOURCE_SUM=', 'SOURCE_SUM={}'.format(hash)) + replace_line_startingwith(srcfile, 'SOURCE_URL=', f'SOURCE_URL={url}') + replace_line_startingwith(srcfile, 'SOURCE_SUM=', f'SOURCE_SUM={hashsum}') replace_line_startingwith(srcfile, 'SOURCE_SUM_PRG=', 'SOURCE_SUM_PRG=sha256sum') - - - -def get_required_extensions(extensions): +def get_required_extensions(extensions: List[str]): ext_files = [ - { 'name': 'LDAPAuthentication2', 'file': 'conf/ldap_authentication2.src', }, - { 'name': 'LDAPAuthorization', 'file': 'conf/ldap_authorization.src', }, - # { 'name': 'Auth_remoteuser', 'file': 'conf/ldap_auth_remoteuser.src', }, - { 'name': 'LDAPGroups', 'file': 'conf/ldap_groups.src', }, - { 'name': 'LDAPProvider', 'file': 'conf/ldap_provider.src', }, - { 'name': 'LDAPUserInfo', 'file': 'conf/ldap_userinfo.src', }, - { 'name': 'PluggableAuth', 'file': 'conf/pluggable_auth.src', }, + {'name': 'LDAPAuthentication2', 'file': 'conf/ldap_authentication2.src', }, + {'name': 'LDAPAuthorization', 'file': 'conf/ldap_authorization.src', }, + # {'name': 'Auth_remoteuser', 'file': 'conf/ldap_auth_remoteuser.src', }, + {'name': 'LDAPGroups', 'file': 'conf/ldap_groups.src', }, + {'name': 'LDAPProvider', 'file': 'conf/ldap_provider.src', }, + {'name': 'LDAPUserInfo', 'file': 'conf/ldap_userinfo.src', }, + {'name': 'PluggableAuth', 'file': 'conf/pluggable_auth.src', }, ] for ext in ext_files: file = ext['file'] name = ext['name'] - echo_var = 'source {} ; echo ${}'.format(file, '{}') - current_url = subprocess.check_output(echo_var.format('SOURCE_URL'), shell=True).decode('utf-8').strip() + echo_var = f'source {file} ; echo ${{}}' + current_url = subprocess.check_output( + echo_var.format('SOURCE_URL'), shell=True + ).decode('utf-8').strip() # Search for corresponding in extensions - matching_extension_urls = [ url for url in extensions if name in url ] + matching_extension_urls = [url for url in extensions if name in url] if len(matching_extension_urls) != 1: - print('ERROR: Could not find an upstream link for extension {}'.format(name)) + print(f'ERROR: Could not find an upstream link for extension {name}') continue - new_url = extensions_host_url + matching_extension_urls[0] + new_url = EXTENSIONS_HOST_URL + matching_extension_urls[0] if current_url == new_url: - print('OK: url is up to date for {}'.format(name)) + print(f'OK: url is up to date for {name}') continue - print('Updating source file for {}'.format(name)) - update_source_file(file, new_url, '000') + print(f'Updating source file for {name}') + update_source_file(file, new_url) - -if __name__ == '__main__': +def main(): + """Main function.""" mediawiki_ext_version = get_mediawiki_ext_version() extensions = get_all_extensions() extensions = get_extensions_for_version(extensions, mediawiki_ext_version) get_required_extensions(extensions) + + +if __name__ == '__main__': + main() From 70158f8de0e8cd1685f35c49aa094b57c84d2e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 8 Oct 2021 18:52:15 +0200 Subject: [PATCH 3/3] Update to 1.36.2 --- README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9fb28de..ea82f87 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Wiki package originally for use on Wikipedia -**Shipped version:** 1.36.0 +**Shipped version:** 1.36.2 **Demo:** https://www.wikipedia.org/, https://www.mediawiki.org/wiki/Project:Sandbox diff --git a/README_fr.md b/README_fr.md index 9d9f7f0..1e6ff50 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Wiki développé à l’origine pour Wikipédia -**Version incluse :** 1.36.0 +**Version incluse :** 1.36.2 **Démo :** https://www.wikipedia.org/, https://www.mediawiki.org/wiki/Project:Sandbox diff --git a/conf/app.src b/conf/app.src index 6fbfb97..3b4febe 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://releases.wikimedia.org/mediawiki/1.36/mediawiki-1.36.0.tar.gz -SOURCE_SUM=35cfbdcdcadaf9ee60b097532c5711121adce226d3f1c3b7bd1db1e2903cdd4a +SOURCE_URL=https://releases.wikimedia.org/mediawiki/1.36/mediawiki-1.36.2.tar.gz +SOURCE_SUM=c7357dde98449c8635134dbd82790660d732592cb02cbff3574361df39fee2d4 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 49327f0..3fd2344 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Wiki package originally for use on Wikipedia", "fr": "Wiki développé à l’origine pour Wikipédia" }, - "version": "1.36.0~ynh2", + "version": "1.36.2~ynh1", "url": "https://www.mediawiki.org", "license": "GPL-2.0-or-later", "upstream": { @@ -16,7 +16,7 @@ "admindoc": "https://www.mediawiki.org/wiki/Documentation", "userdoc": "https://www.mediawiki.org/wiki/Project:Help", "code": "https://github.com/wikimedia/mediawiki", - "version": "1.36.0" + "version": "1.36.2" }, "maintainer": { "name": "Salamandar",