[devhelp/repo-cleanup: 12/14] Consolidate Flatpak utility scripts
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/repo-cleanup: 12/14] Consolidate Flatpak utility scripts
- Date: Mon, 12 Apr 2021 22:41:09 +0000 (UTC)
commit 2b8cf2e8fc606a766412ae8d5afbe9f0648fe436
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Apr 12 19:07:39 2021 +0100
Consolidate Flatpak utility scripts
Use a single, parametrised script, instead of three separate, hard coded
ones.
build-aux/flatpak/1-build-and-install.sh | 3 -
build-aux/flatpak/2-run-app.sh | 3 -
build-aux/flatpak/3-teardown.sh | 3 -
build-aux/flatpak/README | 7 ---
build-aux/flatpak/README.md | 13 ++++
build-aux/flatpak/run-flatpak.sh | 102 +++++++++++++++++++++++++++++++
6 files changed, 115 insertions(+), 16 deletions(-)
---
diff --git a/build-aux/flatpak/README.md b/build-aux/flatpak/README.md
new file mode 100644
index 00000000..d453bcce
--- /dev/null
+++ b/build-aux/flatpak/README.md
@@ -0,0 +1,13 @@
+Flatpak for Devhelp
+===================
+
+ - `org.gnome.Devhelp.json`: the Flatpak-builder manifest for Devhelp
+ - `run-flatpak.sh`: a utility script for building, running, and uninstalling
+ the Devhelp Flatpak
+
+If you want to build a Flatpak version of Devhelp:
+
+ 1. make sure to have `flatpak` and `flatpak-builder` installed
+ 2. `./run-flatpak build --app-id=org.gnome.Devhelp` to build and install
+ 3. `./run-flatpak run --app-id=org.gnome.Devhelp` to run
+ 4. `./run-flatpak clean --app-id=org.gnome.Devhelp` to uninstall
diff --git a/build-aux/flatpak/run-flatpak.sh b/build-aux/flatpak/run-flatpak.sh
new file mode 100755
index 00000000..4050d72b
--- /dev/null
+++ b/build-aux/flatpak/run-flatpak.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+read_arg() {
+ # $1 = arg name
+ # $2 = arg value
+ # $3 = arg parameter
+ local rematch='^[^=]*=(.*)$'
+ if [[ $2 =~ $rematch ]]; then
+ read "$1" <<< "${BASH_REMATCH[1]}"
+ else
+ read "$1" <<< "$3"
+ # There is no way to shift our callers args, so
+ # return 1 to indicate they should do it instead.
+ return 1
+ fi
+}
+
+set -e
+
+build=0
+run=0
+clean=0
+print_help=0
+
+while (($# > 0)); do
+ case "${1%%=*}" in
+ build) build=1;;
+ run) run=1;;
+ clean) clean=1;;
+ help) print_help=1;;
+ --app-id) read_arg app_id "$@" || shift;;
+ --manifest) read_arg manifest "$@" || shift;;
+ *) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
+ esac
+ shift
+done
+
+if [ $print_help == 1 ]; then
+ echo "$0 - Build and run Flatpak"
+ echo ""
+ echo "Usage: $0 <command> [options]"
+ echo ""
+ echo "Available commands"
+ echo ""
+ echo " build --manifest=<FILE> - Build Flatpak <MANIFEST>"
+ echo " run --app-id=<APP> - Run Flatpak app <APP>"
+ echo " clean --app-id=<APP> - Uninstall Flatpak app <APP>"
+ echo " help - This help message"
+ echo ""
+ exit 0
+fi
+
+FLATPAK_BUILDER=$( which flatpak-builder )
+FLATPAK=$( which flatpak )
+
+if [ $build == 1 ]; then
+ if [ ! -z $app_id ]; then
+ manifest="$app_id.json"
+ fi
+
+ if [ -z $manifest ]; then
+ echo "Usage: $0 build --manifest=<FILE>"
+ exit 1
+ fi
+
+ if [ ! -f "$manifest" ]; then
+ echo -e "\e[1;31mERROR\e[0m: Manifest not found"
+ exit 1
+ fi
+
+ echo -e "\e[1;32mBUILDING\e[0m: ${manifest}"
+
+ ${FLATPAK_BUILDER} --force-clean --user --install build "${manifest}"
+
+ exit $?
+fi
+
+if [ $run == 1 ]; then
+ if [ -z $app_id ]; then
+ echo "Usage: $0 run --app-id=<APP>"
+ exit 1
+ fi
+
+ ${FLATPAK} run ${app_id}
+
+ exit $?
+fi
+
+if [ $clean == 1 ]; then
+ if [ -z $app_id ]; then
+ echo "Usage: $0 clean --app-id=<APP>"
+ exit 1
+ fi
+
+ ${FLATPAK} uninstall --user $app_id
+
+ exit $?
+fi
+
+echo "Usage: $0 <command>"
+echo "See: $0 help"
+exit 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]