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.
pull/8941/head
Xavier Claessens 4 years ago
parent e945f35cd7
commit 6776bfad3c
  1. 20
      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

Loading…
Cancel
Save