mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-20 07:41:22 +02:00
Flatpak: build from source instead of repackaging debs (#389)
This commit is contained in:
43
flatpak/generate-sources.sh
Executable file
43
flatpak/generate-sources.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate offline dependency source files for Flatpak builds.
|
||||
#
|
||||
# Prerequisites:
|
||||
# pip install flatpak-node-generator tomlkit aiohttp
|
||||
# Clone https://github.com/flatpak/flatpak-builder-tools (for cargo generator)
|
||||
#
|
||||
# Usage:
|
||||
# ./flatpak/generate-sources.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# Generate cargo-sources.json
|
||||
python3 "$SCRIPT_DIR/flatpak-builder-tools/cargo/flatpak-cargo-generator.py" \
|
||||
-o "$SCRIPT_DIR/cargo-sources.json" "$REPO_ROOT/Cargo.lock"
|
||||
|
||||
# Generate node-sources.json from a patched copy of the lockfile.
|
||||
# npm omits resolved/integrity for some workspace deps, and
|
||||
# flatpak-node-generator can't handle workspace link entries.
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
cp "$REPO_ROOT/package-lock.json" "$TMPDIR/package-lock.json"
|
||||
cp "$REPO_ROOT/package.json" "$TMPDIR/package.json"
|
||||
|
||||
node "$SCRIPT_DIR/fix-lockfile.mjs" "$TMPDIR/package-lock.json"
|
||||
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const p = process.argv[1];
|
||||
const d = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
||||
for (const [name, info] of Object.entries(d.packages || {})) {
|
||||
if (name && (info.link || !info.resolved)) delete d.packages[name];
|
||||
}
|
||||
fs.writeFileSync(p, JSON.stringify(d, null, 2));
|
||||
" "$TMPDIR/package-lock.json"
|
||||
|
||||
flatpak-node-generator --no-requests-cache \
|
||||
-o "$SCRIPT_DIR/node-sources.json" npm "$TMPDIR/package-lock.json"
|
||||
Reference in New Issue
Block a user