From f7f5457d469d8138f95af5fb0572a366781138cf Mon Sep 17 00:00:00 2001 From: cis-kuldeep Date: Tue, 27 Apr 2021 23:08:18 +0530 Subject: [PATCH] Added flatpak build manifests with split dependencies Removed extra lines from build sequence Added Dockerfile for Flatpak repo-server & Build instructions under docs/ dir Modified Dockerfile & Flatpak build doc updated docs fixed code quality issues fixed code quality, added doc string fixed branch & added build commands run setuptools fixed code quality refactor pip install updated flatpak build doc & added link to index.rst Removed extra lines from build sequence Added Dockerfile for Flatpak repo-server & Build instructions under docs/ dir Modified Dockerfile & Flatpak build doc updated docs fixed code quality issues fixed code quality, added doc string fixed branch & added build commands run setuptools fixed code quality refactor pip install updated flatpak build doc & added link to index.rst fixed docs rebased removed unnecessary files removed .gitmodules: should be part of build process --- docs/Flatpak_Build.md | 97 +++++++++++++++++++ docs/index.rst | 8 ++ packages/flatpak/org.bitmessage.BaseApp.json | 57 +++++++++++ .../flatpak/org.bitmessage.PyBitmessage.json | 42 ++++++++ 4 files changed, 204 insertions(+) create mode 100644 docs/Flatpak_Build.md create mode 100644 packages/flatpak/org.bitmessage.BaseApp.json create mode 100644 packages/flatpak/org.bitmessage.PyBitmessage.json diff --git a/docs/Flatpak_Build.md b/docs/Flatpak_Build.md new file mode 100644 index 00000000..9da756ab --- /dev/null +++ b/docs/Flatpak_Build.md @@ -0,0 +1,97 @@ +# PyBitmessage Linux flatpak instructions + +## Requirements +First make sure you have `flatpak` and `flatpak-builder` installed along with these dependencies (Ubuntu 20.4) `git xz-utils elfutils librsvg2-common` needs to be 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: + +Build and Install the Base App + +``` +git clone git://github.com/Bitmessage/PyBitmessage.git +cd PyBitmessage/ +git submodule update --init --recursive +flatpak-builder --install --install-deps-from=flathub --force-clean --state-dir=build/.flatpak-builder build/_baseApp packages/flatpak/org.bitmessage.BaseApp.json +``` +This will install the base app to your local flatpak user repository, it +takes a while to compile because Qt4 and PyQt4 have to be build, among others. But this is only required once. + +Now Build and Install PyBitmessage App + +``` +flatpak-builder --install --install-deps-from=flathub --force-clean --state-dir=build/.flatpak-builder build/_PyBit packages/flatpak/org.bitmessage.PyBitmessage.json +``` + +# Run +When installation is done you can launch PyBitmessage via the **command line**: +`flatpak run 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/_PyBit packages/flatpak/org.bitmessage.PyBitmessage.json +``` +This will create a local flatpak repository in `build/_flatpak_repo/`. + +## Hosting the repository + +Place the `_flatpak_repo/` repo directory in the same directory as the dockerfile i.e `packages/flatpak/dockerfile` + +Build and run the docker image + +``` +sudo docker build -t repo-server:latest . +sudo docker run -d -p 5000:5000 repo-server +``` + +## Installing PyBitmessage from repo-server + +Add the repository +``` +sudo flatpak remote-add --no-gpg-verify pybitmessage http://localhost:5000/repo +``` + +Install and Run the app +``` +sudo flatpak install test org.bitmessage.PyBitmessage +flatpak run org.bitmessage.PyBitmessage +``` + +## 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//19.08` + +You can also delete the `build` directory again. \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 5e8a1c1a..68af0aa1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,12 @@ .. mdinclude:: ../README.md + :end-line: 20 + +Build Instructions +------------------ +.. toctree:: + :maxdepth: 1 + + Flatpak_Build Documentation ------------- diff --git a/packages/flatpak/org.bitmessage.BaseApp.json b/packages/flatpak/org.bitmessage.BaseApp.json new file mode 100644 index 00000000..e07031cf --- /dev/null +++ b/packages/flatpak/org.bitmessage.BaseApp.json @@ -0,0 +1,57 @@ +{ + "id": "org.bitmessage.BaseApp", + "branch": "stable", + "runtime": "org.freedesktop.Platform", + "sdk": "org.freedesktop.Sdk", + "runtime-version": "19.08", + "separate-locales": false, + "modules": [ + "shared-modules/python2.7/python-2.7.json", + "shared-modules/qt4/qt4-4.8.7-minimal.json", + { + "name": "python-sip", + "sources": [ + { + "type": "archive", + "url": "https://www.riverbankcomputing.com/static/Downloads/sip/4.19.25/sip-4.19.25.tar.gz", + "sha256": "b39d93e937647807bac23579edbff25fe46d16213f708370072574ab1f1b4211" + } + ], + "buildsystem": "simple", + "build-commands": [ + "python configure.py --sip-module PyQt4.sip --no-dist-info", + "make", + "make install" + ] + }, + { + "name": "python-qt4", + "sources": [ + { + "type": "archive", + "url": "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz", + "sha256": "a00f5abef240a7b5852b7924fa5fdf5174569525dc076cd368a566619e56d472" + } + ], + "buildsystem": "simple", + "build-commands": [ + "python configure.py -w --confirm-license", + "make", + "make install" + ] + }, + { + "name" : "PyBitmessage-dependencies", + "buildsystem" : "simple", + "build-options": { + "build-args": [ + "--share=network" + ] + }, + "build-commands": [ + "pip --version", + "pip install setuptools msgpack six" + ] + } + ] +} \ No newline at end of file diff --git a/packages/flatpak/org.bitmessage.PyBitmessage.json b/packages/flatpak/org.bitmessage.PyBitmessage.json new file mode 100644 index 00000000..c05af60e --- /dev/null +++ b/packages/flatpak/org.bitmessage.PyBitmessage.json @@ -0,0 +1,42 @@ +{ + "app-id": "org.bitmessage.PyBitmessage", + "runtime": "org.freedesktop.Platform", + "runtime-version": "19.08", + "branch": "stable", + "sdk": "org.freedesktop.Sdk", + "base": "org.bitmessage.BaseApp", + "command": "pybitmessage", + "base-version":"stable", + "finish-args" : [ + "--share=network", + "--socket=x11", + "--share=ipc", + "--filesystem=xdg-config/PyBitmessage:create" + ], + "modules": [ + { + "name" : "PyBitmessage", + "buildsystem" : "simple", + "build-options": { + "build-args": [ + "--share=network" + ] + }, + "build-commands": [ + "python setup.py install --prefix=/app --exec-prefix=/app", + "mv /app/share/applications/pybitmessage.desktop /app/share/applications/org.bitmessage.PyBitmessage.desktop", + "sed -i 's~Icon=pybitmessage~Icon=org.bitmessage.PyBitmessage~' /app/share/applications/org.bitmessage.PyBitmessage.desktop", + "mv /app/share/icons/hicolor/scalable/apps/pybitmessage.svg /app/share/icons/hicolor/scalable/apps/org.bitmessage.PyBitmessage.svg", + "mv /app/share/icons/hicolor/24x24/apps/pybitmessage.png /app/share/icons/hicolor/24x24/apps/org.bitmessage.PyBitmessage.png", + "which pybitmessage" + ], + "sources" : [ + { + "type" : "dir", + "path" : "../../" + } + ] + } + ] + } + \ No newline at end of file -- 2.45.1