78 lines
2.1 KiB
Bash
Executable File
78 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -gt 2 ]]; then
|
|
echo "Usage: $0 [OUTPUT_DIRECTORY] [OUTPUT_FILENAME]" >&2
|
|
exit 2
|
|
fi
|
|
|
|
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo_root="$(cd -- "$script_dir/../.." && pwd)"
|
|
output_directory="${1:-$repo_root/flatpak-dist}"
|
|
output_name="${2:-KompAC-embedded-x86_64.flatpak}"
|
|
|
|
if [[ "$output_name" == */* || "$output_name" != *.flatpak ]]; then
|
|
echo "OUTPUT_FILENAME must be a portable filename ending in .flatpak" >&2
|
|
exit 2
|
|
fi
|
|
if [[ "$(uname -m)" != x86_64 ]]; then
|
|
echo "The Flatpak production build currently supports x86_64 only" >&2
|
|
exit 1
|
|
fi
|
|
for command in flatpak flatpak-builder; do
|
|
if ! command -v "$command" >/dev/null 2>&1; then
|
|
echo "$command is required to build the Flatpak" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
mkdir -p "$output_directory"
|
|
output_directory="$(cd -- "$output_directory" && pwd)"
|
|
|
|
cache_home="${XDG_CACHE_HOME:-${HOME:?HOME is not set}/.cache}"
|
|
state_dir="$cache_home/komp-ac-flatpak-builder"
|
|
mkdir -p "$state_dir"
|
|
|
|
work_dir="$(mktemp -d /tmp/komp-ac-flatpak-build.XXXXXX)"
|
|
cleanup() {
|
|
case "$work_dir" in
|
|
/tmp/komp-ac-flatpak-build.*)
|
|
rm -rf -- "$work_dir"
|
|
;;
|
|
*)
|
|
echo "Refusing to remove unexpected Flatpak workspace: $work_dir" >&2
|
|
;;
|
|
esac
|
|
}
|
|
trap cleanup EXIT INT TERM HUP
|
|
|
|
flathub_repository=https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
flatpak remote-add --user --if-not-exists flathub "$flathub_repository"
|
|
|
|
echo "Building Komp AC against the GNOME 50 Flatpak runtime"
|
|
echo " output: $output_directory/$output_name"
|
|
echo " cache: $state_dir"
|
|
echo
|
|
|
|
cd "$script_dir"
|
|
flatpak-builder \
|
|
--user \
|
|
--install-deps-from=flathub \
|
|
--force-clean \
|
|
--state-dir="$state_dir" \
|
|
--repo="$work_dir/repository" \
|
|
"$work_dir/build" \
|
|
com.kompac.client.yml
|
|
|
|
flatpak build-bundle \
|
|
--runtime-repo="$flathub_repository" \
|
|
"$work_dir/repository" \
|
|
"$work_dir/$output_name" \
|
|
com.kompac.client \
|
|
stable
|
|
|
|
cp -- "$work_dir/$output_name" "$output_directory/$output_name"
|
|
|
|
echo "Created $output_directory/$output_name"
|