diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-06-28 11:47:16 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2022-10-09 12:58:59 -0400 |
commit | 6776bfad3ce0601b9ee0c604b5d51031726824b3 (patch) | |
tree | 9b9c6d498ecd2c07e1c222c0c2fc643f95319b96 | |
parent | e945f35cd72402d0d204ff10870e2a95c59b6192 (diff) | |
download | meson-6776bfad3ce0601b9ee0c604b5d51031726824b3.zip meson-6776bfad3ce0601b9ee0c604b5d51031726824b3.tar.gz meson-6776bfad3ce0601b9ee0c604b5d51031726824b3.tar.bz2 |
Add "meson wrap update-db" command
It downloads releases.json from wrapdb and store it in
subprojects/wrapdb.json. That file will be used by Meson to find
dependency fallbacks offline.
-rw-r--r-- | mesonbuild/wrap/wraptool.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py index ec2ac3e..80a58ab 100644 --- a/mesonbuild/wrap/wraptool.py +++ b/mesonbuild/wrap/wraptool.py @@ -21,6 +21,7 @@ import typing as T from glob import glob from urllib.parse import urlparse from .wrap import open_wrapdburl, WrapException +from pathlib import Path from .. import mesonlib @@ -69,9 +70,18 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None: p.add_argument('project_path') p.set_defaults(wrap_func=promote) -def get_releases(allow_insecure: bool) -> T.Dict[str, T.Any]: + p = subparsers.add_parser('update-db', help='Update list of projects available in WrapDB (Since 0.61.0)') + p.add_argument('--allow-insecure', default=False, action='store_true', + help='Allow insecure server connections.') + p.set_defaults(wrap_func=update_db) + +def get_releases_data(allow_insecure: bool) -> bytes: url = open_wrapdburl('https://wrapdb.mesonbuild.com/v2/releases.json', allow_insecure, True) - return T.cast('T.Dict[str, T.Any]', json.loads(url.read().decode())) + return url.read() + +def get_releases(allow_insecure: bool) -> T.Dict[str, T.Any]: + data = get_releases_data(allow_insecure) + return T.cast('T.Dict[str, T.Any]', json.loads(data.decode())) def list_projects(options: 'argparse.Namespace') -> None: releases = get_releases(options.allow_insecure) @@ -244,6 +254,12 @@ def status(options: 'argparse.Namespace') -> None: else: print('', name, f'not up to date. Have {current_branch} {current_revision}, but {latest_branch} {latest_revision} is available.') +def update_db(options: 'argparse.Namespace') -> None: + data = get_releases_data(options.allow_insecure) + Path('subprojects').mkdir(exist_ok=True) + with Path('subprojects/wrapdb.json').open('wb') as f: + f.write(data) + def run(options: 'argparse.Namespace') -> int: options.wrap_func(options) return 0 |