aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Wick <sebastian.wick@redhat.com>2024-06-17 01:16:37 +0200
committerXavier Claessens <xclaesse@gmail.com>2024-06-17 11:00:22 -0400
commitc199faf9807fb898e1c6744c43728dc87c93a0bc (patch)
tree989bc775d99bbfb23e303862c507fdb3b8fa3457
parent2058f63b4e2d67cbe835499a43d8415f3c1d940d (diff)
downloadmeson-c199faf9807fb898e1c6744c43728dc87c93a0bc.zip
meson-c199faf9807fb898e1c6744c43728dc87c93a0bc.tar.gz
meson-c199faf9807fb898e1c6744c43728dc87c93a0bc.tar.bz2
cargo: Fall back to the checksum in Cargo.lock metadata table
In ansi_term-0.12.1 the packages do not have a checksum entry but it can be found in the global metadata table.
-rw-r--r--mesonbuild/cargo/interpreter.py5
-rw-r--r--mesonbuild/cargo/manifest.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/cargo/interpreter.py b/mesonbuild/cargo/interpreter.py
index 13568cd..33b9d60 100644
--- a/mesonbuild/cargo/interpreter.py
+++ b/mesonbuild/cargo/interpreter.py
@@ -751,13 +751,16 @@ def load_wraps(source_dir: str, subproject_dir: str) -> T.List[PackageDefinition
# This is project's package, or one of its workspace members.
pass
elif source == 'registry+https://github.com/rust-lang/crates.io-index':
+ checksum = package.get('checksum')
+ if checksum is None:
+ checksum = cargolock['metadata'][f'checksum {name} {version} ({source})']
url = f'https://crates.io/api/v1/crates/{name}/{version}/download'
directory = f'{name}-{version}'
wraps.append(PackageDefinition.from_values(subp_name, subproject_dir, 'file', {
'directory': directory,
'source_url': url,
'source_filename': f'{directory}.tar.gz',
- 'source_hash': package['checksum'],
+ 'source_hash': checksum,
'method': 'cargo',
}))
elif source.startswith('git+'):
diff --git a/mesonbuild/cargo/manifest.py b/mesonbuild/cargo/manifest.py
index 183d91e..50c0489 100644
--- a/mesonbuild/cargo/manifest.py
+++ b/mesonbuild/cargo/manifest.py
@@ -242,3 +242,4 @@ class CargoLock(TypedDict, total=False):
version: str
package: T.List[CargoLockPackage]
+ metadata: T.Dict[str, str]