aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-02-08 23:42:23 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-02-27 18:37:15 -0500
commit769680f848701eb738e18fd9266b876d88f4fcf8 (patch)
tree4db55f17e810eca2085279dee8d4d422fbe20f39 /mesonbuild/wrap
parent880d5000b218ace3bd8844050d183c78da1caf78 (diff)
downloadmeson-769680f848701eb738e18fd9266b876d88f4fcf8.zip
meson-769680f848701eb738e18fd9266b876d88f4fcf8.tar.gz
meson-769680f848701eb738e18fd9266b876d88f4fcf8.tar.bz2
wraptool: be forgiving of local wrap files
Do not traceback when trying to update a wrap that isn't a [wrap-file], just report the problem. Do not traceback on perfectly valid WrapDB wraps that don't have a patch_url because they have upstream meson.build, instead try to parse the version from the source tarball filename.
Diffstat (limited to 'mesonbuild/wrap')
-rw-r--r--mesonbuild/wrap/wraptool.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py
index 9462867..de1c43f 100644
--- a/mesonbuild/wrap/wraptool.py
+++ b/mesonbuild/wrap/wraptool.py
@@ -119,13 +119,25 @@ def parse_patch_url(patch_url: str) -> T.Tuple[str, str]:
else:
raise WrapException(f'Invalid wrapdb URL {patch_url}')
-def get_current_version(wrapfile: str) -> T.Tuple[str, str, str, str, str]:
+def get_current_version(wrapfile: str) -> T.Tuple[str, str, str, str, T.Optional[str]]:
cp = configparser.ConfigParser(interpolation=None)
cp.read(wrapfile)
- wrap_data = cp['wrap-file']
- patch_url = wrap_data['patch_url']
- branch, revision = parse_patch_url(patch_url)
- return branch, revision, wrap_data['directory'], wrap_data['source_filename'], wrap_data['patch_filename']
+ try:
+ wrap_data = cp['wrap-file']
+ except KeyError:
+ raise WrapException(f'Not a wrap-file, cannot have come from the wrapdb')
+ try:
+ patch_url = wrap_data['patch_url']
+ except KeyError:
+ # We assume a wrap without a patch_url is probably just an pointer to upstream's
+ # build files. The version should be in the tarball filename, even if it isn't
+ # purely guaranteed. The wrapdb revision should be 1 because it just needs uploading once.
+ branch = mesonlib.search_version(wrap_data['source_filename'])
+ revision, patch_filename = '1', None
+ else:
+ branch, revision = parse_patch_url(patch_url)
+ patch_filename = wrap_data['patch_filename']
+ return branch, revision, wrap_data['directory'], wrap_data['source_filename'], patch_filename
def update_wrap_file(wrapfile: str, name: str, new_version: str, new_revision: str) -> None:
url = urlopen(f'https://wrapdb.mesonbuild.com/v2/{name}_{new_version}-{new_revision}/{name}.wrap')
@@ -150,10 +162,11 @@ def update(options: 'argparse.Namespace') -> None:
os.unlink(os.path.join('subprojects/packagecache', src_file))
except FileNotFoundError:
pass
- try:
- os.unlink(os.path.join('subprojects/packagecache', patch_file))
- except FileNotFoundError:
- pass
+ if patch_file is not None:
+ try:
+ os.unlink(os.path.join('subprojects/packagecache', patch_file))
+ except FileNotFoundError:
+ pass
print(f'Updated {name} version {new_branch} revision {new_revision}')
def info(options: 'argparse.Namespace') -> None: