fix flatpak build: add checksums and update to GNOME 49
- Generate cargo checksum files for vendored sources - Add checksums.json for build-time checksum creation - Update runtime to GNOME 49 for Rust 1.93+ support - Fix archive-type to tar-gzip for flatpak-builder Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
256da4b440
commit
09b737b901
4 changed files with 428 additions and 331 deletions
1
build-aux/cargo-sources-checksums.json
Normal file
1
build-aux/cargo-sources-checksums.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python3 build-aux/flatpak-cargo-generator.py [Cargo.lock] \
|
python3 build-aux/flatpak-cargo-generator.py [Cargo.lock] \
|
||||||
> build-aux/cargo-sources.json
|
-o build-aux/cargo-sources.json
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
@ -23,12 +23,25 @@ REGISTRY_SOURCE = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
lockfile = sys.argv[1] if len(sys.argv) > 1 else "Cargo.lock"
|
# Parse arguments
|
||||||
|
lockfile = "Cargo.lock"
|
||||||
|
output_file = None
|
||||||
|
|
||||||
|
args = sys.argv[1:]
|
||||||
|
i = 0
|
||||||
|
while i < len(args):
|
||||||
|
if args[i] == "-o" and i + 1 < len(args):
|
||||||
|
output_file = args[i + 1]
|
||||||
|
i += 2
|
||||||
|
else:
|
||||||
|
lockfile = args[i]
|
||||||
|
i += 1
|
||||||
|
|
||||||
with open(lockfile, "rb") as f:
|
with open(lockfile, "rb") as f:
|
||||||
lock = tomllib.load(f)
|
lock = tomllib.load(f)
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
|
checksums = {}
|
||||||
|
|
||||||
for pkg in lock.get("package", []):
|
for pkg in lock.get("package", []):
|
||||||
name = pkg["name"]
|
name = pkg["name"]
|
||||||
|
|
@ -38,17 +51,30 @@ def main() -> None:
|
||||||
|
|
||||||
# Only vendor packages from crates.io (they have a checksum)
|
# Only vendor packages from crates.io (they have a checksum)
|
||||||
if source == REGISTRY_SOURCE and checksum:
|
if source == REGISTRY_SOURCE and checksum:
|
||||||
|
dest = f"cargo-vendor/{name}-{version}"
|
||||||
sources.append(
|
sources.append(
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gz",
|
"archive-type": "tar-gzip",
|
||||||
"url": f"{CRATES_IO_DL}/{name}/{version}/download",
|
"url": f"{CRATES_IO_DL}/{name}/{version}/download",
|
||||||
"sha256": checksum,
|
"sha256": checksum,
|
||||||
"dest": f"cargo-vendor/{name}-{version}",
|
"dest": dest,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
checksums[f"{name}-{version}"] = checksum
|
||||||
|
|
||||||
print(json.dumps(sources, indent=2))
|
output = json.dumps(sources, indent=2)
|
||||||
|
|
||||||
|
if output_file:
|
||||||
|
with open(output_file, "w") as f:
|
||||||
|
f.write(output)
|
||||||
|
# Also write checksums file
|
||||||
|
checksums_file = output_file.replace(".json", "-checksums.json")
|
||||||
|
with open(checksums_file, "w") as f:
|
||||||
|
json.dump(checksums, f)
|
||||||
|
print(f"Generated {output_file} and {checksums_file}")
|
||||||
|
else:
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
app-id: org.nextbike.NextCompanion
|
app-id: org.nextbike.NextCompanion
|
||||||
runtime: org.gnome.Platform
|
runtime: org.gnome.Platform
|
||||||
runtime-version: '47'
|
runtime-version: '49'
|
||||||
sdk: org.gnome.Sdk
|
sdk: org.gnome.Sdk
|
||||||
sdk-extensions:
|
sdk-extensions:
|
||||||
- org.freedesktop.Sdk.Extension.rust-stable
|
- org.freedesktop.Sdk.Extension.rust-stable
|
||||||
|
|
@ -30,6 +30,16 @@ modules:
|
||||||
build-commands:
|
build-commands:
|
||||||
- mkdir -p .cargo
|
- mkdir -p .cargo
|
||||||
- cp cargo-vendor-config/cargo-vendor-config.toml .cargo/config.toml
|
- cp cargo-vendor-config/cargo-vendor-config.toml .cargo/config.toml
|
||||||
|
- |
|
||||||
|
python3 -c "
|
||||||
|
import json
|
||||||
|
with open('cargo-checksums/checksums.json') as f:
|
||||||
|
checksums = json.load(f)
|
||||||
|
for name, checksum in checksums.items():
|
||||||
|
path = f'cargo-vendor/{name}/.cargo-checksum.json'
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
json.dump({'files': {}, 'package': checksum}, f)
|
||||||
|
"
|
||||||
- cargo --offline build --release
|
- cargo --offline build --release
|
||||||
- |
|
- |
|
||||||
install -Dm755 \
|
install -Dm755 \
|
||||||
|
|
@ -46,4 +56,8 @@ modules:
|
||||||
path: build-aux/cargo-vendor-config.toml
|
path: build-aux/cargo-vendor-config.toml
|
||||||
dest: cargo-vendor-config
|
dest: cargo-vendor-config
|
||||||
dest-filename: cargo-vendor-config.toml
|
dest-filename: cargo-vendor-config.toml
|
||||||
|
- type: file
|
||||||
|
path: build-aux/cargo-sources-checksums.json
|
||||||
|
dest: cargo-checksums
|
||||||
|
dest-filename: checksums.json
|
||||||
- build-aux/cargo-sources.json
|
- build-aux/cargo-sources.json
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue