-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-flatpak.sh
More file actions
executable file
·34 lines (25 loc) · 1.19 KB
/
Copy pathbuild-flatpak.sh
File metadata and controls
executable file
·34 lines (25 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -e
# Get metadata from Cargo.toml
NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
APPID=com.github.nwxnw.cosmic-ext-whether
# .cargo/config.toml is a transient build input: while it exists, every cargo command in this
# repo resolves from vendor/ instead of crates.io (so `cargo update` fails). Drop it on exit --
# registered before it's created so `set -e` can't leave it behind. vendor/ is inert without it.
cleanup() { rm -f .cargo/config.toml; }
trap cleanup EXIT
# Build release binary (also needed for cargo vendor to resolve all deps)
cargo build --release
# Generate vendored crates and a matching cargo config
mkdir -p .cargo
cargo vendor > .cargo/config.toml
# Verify offline metadata works
cargo metadata --offline --format-version 1 >/dev/null
# Uninstall old version if present
flatpak uninstall $APPID -y 2>/dev/null || true
# Build with flatpak-builder
flatpak-builder --force-clean --repo=repo build-dir $APPID.json
# Bundle into a single .flatpak file
flatpak build-bundle repo ${NAME}_${VERSION}.flatpak $APPID
echo "Created ${NAME}_${VERSION}.flatpak"