This commit is contained in:
Jonas Heinrich 2026-03-10 23:58:45 +01:00
parent 5e4560e89e
commit 9961a31936
7 changed files with 1587 additions and 16 deletions

1472
build-aux/cargo-sources.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "/run/build/next-companion/cargo-vendor"

View file

@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Generate Flatpak source entries for Cargo dependencies from Cargo.lock.
Usage:
python3 build-aux/flatpak-cargo-generator.py [Cargo.lock] \
> build-aux/cargo-sources.json
"""
import json
import sys
try:
import tomllib
except ImportError:
try:
import tomli as tomllib # pip install tomli
except ImportError:
print("Error: requires Python 3.11+ or the 'tomli' package", file=sys.stderr)
sys.exit(1)
CRATES_IO_DL = "https://static.crates.io/crates"
REGISTRY_SOURCE = "registry+https://github.com/rust-lang/crates.io-index"
def main() -> None:
lockfile = sys.argv[1] if len(sys.argv) > 1 else "Cargo.lock"
with open(lockfile, "rb") as f:
lock = tomllib.load(f)
sources = []
for pkg in lock.get("package", []):
name = pkg["name"]
version = pkg["version"]
source = pkg.get("source", "")
checksum = pkg.get("checksum")
# Only vendor packages from crates.io (they have a checksum)
if source == REGISTRY_SOURCE and checksum:
sources.append(
{
"type": "archive",
"archive-type": "tar-gz",
"url": f"{CRATES_IO_DL}/{name}/{version}/download",
"sha256": checksum,
"dest": f"cargo-vendor/{name}-{version}",
}
)
print(json.dumps(sources, indent=2))
if __name__ == "__main__":
main()