From 23376b4eee55ac13c800729404272cc8a538d803 Mon Sep 17 00:00:00 2001
From: zciendor <zciendor@mailchuck.com>
Date: Thu, 30 Apr 2020 16:37:09 +0200
Subject: [PATCH] moved all flatpak related stuff to `packages/flatpak`

---
 .gitmodules                                   |  3 +
 INSTALL.md                                    | 21 +-----
 packages/flatpak/README.md                    | 68 +++++++++++++++++++
 .../flatpak/org.bitmessage.PyBitmessage.json  |  2 +-
 packages/flatpak/shared-modules               |  1 +
 5 files changed, 74 insertions(+), 21 deletions(-)
 create mode 100644 .gitmodules
 create mode 100644 packages/flatpak/README.md
 rename org.bitmessage.PyBitmessage.json => packages/flatpak/org.bitmessage.PyBitmessage.json (98%)
 create mode 160000 packages/flatpak/shared-modules

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..501ab53e
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "packages/flatpak/shared-modules"]
+	path = packages/flatpak/shared-modules
+	url = https://github.com/flathub/shared-modules.git
diff --git a/INSTALL.md b/INSTALL.md
index 46fd66a3..f2d05d87 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -103,26 +103,7 @@ slack.sh - create a package for Slackware
 ```
 
 #### Linux flatpak
-First make sure you have `flatpak` and `flatpak-builder` installed. Follow the
-instructions for your distribution on [flathub](https://flatpak.org/setup/). The
-instructions there only cover the installation of `flatpak`, but 
-`flatpak-builder` should be the same.
-
-Once you have `flatpak` and `flatpak-builder` installed:
-```
-git clone git://github.com/Bitmessage/PyBitmessage.git
-cd PyBitmessage/
-git submodule add https://github.com/flathub/shared-modules.git
-flatpak-builder --install --user -install-deps-from=flathub --force-clean --state-dir=build/.flatpak-builder build/_flatpak org.bitmessage.PyBitmessage.json
-```
-This will install PyBitmessage to your local flatpak user repository, but it 
-takes a while to compile because QT4 and PyQt4 have to be build, among others.
-
-When done you can launch PyBitmessage via:
-`flatpak run -v org.bitmessage.PyBitmessage`
-
-If you want to free up disk space you can remove the `Sdk` runtime again:
-`flatpak uninstall org.freedesktop.Sdk//18.08`
+See [packages/flatpak/README.md](packages/flatpak/README.md)
 
 #### OS X
 Please refer to
diff --git a/packages/flatpak/README.md b/packages/flatpak/README.md
new file mode 100644
index 00000000..70ab3442
--- /dev/null
+++ b/packages/flatpak/README.md
@@ -0,0 +1,68 @@
+# PyBitmessage Linux flatpak instructions
+_Some recent Linux distributions don't support QT4 anymore, hence PyBitmessage
+won't run with a GUI. However, if you build PyBitmessage as a flatpak, it will
+run in a sandbox which provides QT4.__
+
+## Requirements
+First make sure you have `flatpak` and `flatpak-builder` installed. Follow the
+instructions for your distribution on [flathub](https://flatpak.org/setup/). The
+instructions there only cover the installation of `flatpak`, but 
+`flatpak-builder` should be the same.
+
+## Build and Install
+Once you have `flatpak` and `flatpak-builder` installed:
+```
+git clone git://github.com/Bitmessage/PyBitmessage.git
+cd PyBitmessage/
+git submodule add https://github.com/flathub/shared-modules.git
+flatpak-builder --install --user -install-deps-from=flathub --force-clean --state-dir=build/.flatpak-builder build/_flatpak org.bitmessage.PyBitmessage.json
+```
+This will install PyBitmessage to your local flatpak user repository, but it 
+takes a while to compile because QT4 and PyQt4 have to be build, among others.
+
+# Run
+When installation is done you can launch PyBitmessage via the **command line**:
+`flatpak run -v org.bitmessage.PyBitmessage`
+
+Flatpak also exports a `.desktop` file, so you should be able to find and launch
+PyBitmessage via the **application launcher** of your Desktop (Gnome, KDE, ...).
+
+# Export
+You can create a single file "bundle", which allows you to copy and install the
+PyBitmessage flatpak on other devices of the same architecture as the build machine.
+
+## Create a local flatpak repository
+```
+flatpak-builder --repo=build/_flatpak_repo --force-clean --state-dir=build/.flatpak-builder build/_flatpak packages/flatpak/org.bitmessage.PyBitmessage.json
+```
+This will create a local flatpak repository in `build/_flatpak_repo/`.
+
+## Create a bundle
+```
+flatpak build-bundle build/_flatpak_repo build/pybitmessage.flatpak org.bitmessage.PyBitmessage
+```
+This will create a `pybitmessage.flatpak` bundle file in the `build/` directory. 
+
+This bundle can be copied to other systems or installed locally:
+```
+flatpak install pybitmessage.flatpak
+```
+
+The application can be run using flatpak:
+```
+flatpak run org.bitmessage.PyBitmessage
+```
+
+It can then be uninstalled with this command:
+```
+flatpak uninstall org.bitmessage.PyBitmessage
+```
+
+This way of building an application is very convenient when preparing flatpaks
+for testing on another system of the same processor architecture.
+
+## Cleanup
+If you want to free up disk space you can remove the `Sdk` runtime again:
+`flatpak uninstall org.freedesktop.Sdk//18.08`
+
+You can also delete the `build` directory again.
diff --git a/org.bitmessage.PyBitmessage.json b/packages/flatpak/org.bitmessage.PyBitmessage.json
similarity index 98%
rename from org.bitmessage.PyBitmessage.json
rename to packages/flatpak/org.bitmessage.PyBitmessage.json
index ed55bfce..a92fc8ea 100644
--- a/org.bitmessage.PyBitmessage.json
+++ b/packages/flatpak/org.bitmessage.PyBitmessage.json
@@ -81,7 +81,7 @@
       "sources" : [
         {
           "type" : "dir",
-          "path" : "."
+          "path" : "../../"
         }
       ]
     }
diff --git a/packages/flatpak/shared-modules b/packages/flatpak/shared-modules
new file mode 160000
index 00000000..3d5959a7
--- /dev/null
+++ b/packages/flatpak/shared-modules
@@ -0,0 +1 @@
+Subproject commit 3d5959a72ec0d0be923367e08ff01d04f2b6dba8