Skip to content

Commit ceedcd8

Browse files
Merge pull request #610 from tchernobog/features/flatpak-manifest
Add a flatpak manifest
2 parents cff5e3a + 2a8c5af commit ceedcd8

File tree

3 files changed

+181
-1
lines changed

3 files changed

+181
-1
lines changed

.github/workflows/testing.yml

+39
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,42 @@ jobs:
7777
- name: Run flake8
7878
run: |
7979
flake8 --count --show-source --statistics
80+
81+
flatpak:
82+
# This job builds Hamster for flatpak, and runs its tests
83+
# inside the sandbox.
84+
name: Test the flatpak build
85+
runs-on: ubuntu-20.04
86+
steps:
87+
- name: Prepare repo
88+
uses: actions/checkout@v2
89+
- name: Install system packages
90+
# It would be good to cache the GNOME Sdk, as it
91+
# is rather big to download each time.
92+
env:
93+
DEBIAN_FRONTEND: noninteractive
94+
run: |
95+
PACKAGES="flatpak flatpak-builder dbus-x11"
96+
97+
sudo apt-get update
98+
sudo apt-get install -yq ${PACKAGES}
99+
- name: Install GNOME SDK for flatpak
100+
run: |
101+
flatpak remote-add --user --if-not-exists --from flathub https://flathub.org/repo/flathub.flatpakrepo
102+
flatpak install --user -y flathub org.gnome.Platform//3.36 org.gnome.Sdk//3.36
103+
- name: Build application
104+
run: |
105+
flatpak-builder --repo=build/flatpak/repo build/flatpak/tmp org.gnome.Hamster.json
106+
- name: Run tests inside sandbox
107+
run: |
108+
dbus-launch flatpak-builder --run build/flatpak/tmp org.gnome.Hamster.json python3 -m unittest
109+
- name: Export bundle and try to install it
110+
run: |
111+
mkdir -p dist
112+
flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo build/flatpak/repo dist/Hamster.flatpak org.gnome.Hamster
113+
flatpak --user -y install dist/Hamster.flatpak
114+
- name: Upload built artifact
115+
uses: actions/upload-artifact@v2
116+
with:
117+
name: Flatpak application
118+
path: dist/Hamster.flatpak

README.md

+74-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ Installation:
5858
Easy installation on any distribution supporting snap:
5959
https://snapcraft.io/hamster-snap
6060

61+
##### Flatpak
62+
63+
[Flatpak](https://flatpak.org/) enables you to install Hamster in a versioned
64+
environment and then run it inside a sandbox. It is a method independent from
65+
your distribution-specific packaging system, ensuring that the application can
66+
always be reproducibly built, even without hunting down all of the dependencies
67+
yourself. Debugging is made easier as every user has the exact same environment
68+
at runtime. Permissions are limited to what the application really needs to
69+
function properly.
70+
71+
If you downloaded the file with the Hamster bundle (ending in ``.flatpak``), you
72+
can directly install it with:
73+
74+
```bash
75+
flatpak install --reinstall Hamster.flatpak
76+
```
77+
78+
If you would like to install Hamster only for your user, please pass the
79+
``--user`` option to the above command.
80+
81+
After installation, if you need to invoke Hamster from the command line,
82+
you can do so with:
83+
84+
```bash
85+
flatpak run org.gnome.Hamster [args...]
86+
```
87+
6188
### Install from sources
6289

6390
#### Dependencies
@@ -125,6 +152,20 @@ as discussed [here](https://github.com/projecthamster/hamster/pull/421#issuecomm
125152

126153
Now restart your panels/docks and you should be able to add Hamster!
127154

155+
##### Flatpak
156+
157+
Alternatively, you can also build a sandboxed
158+
[flatpak](https://www.flatpak.org/) yourself. You might need to install the
159+
GNOME SDK beforehand (an error will notify you about it, if needed). Execute:
160+
161+
```bash
162+
flatpak-builder --force-clean --user --install \
163+
build/flatpak org.gnome.Hamster.json
164+
```
165+
166+
This creates a temporary flatpack build folder in the ``build/flatpak``
167+
directory. Once the app is installed, the whole ``build/flatpack/`` directory
168+
can be removed.
128169

129170
#### Uninstall
130171

@@ -135,6 +176,14 @@ sudo ./waf uninstall
135176
Afterwards `find /usr -iname hamster` should only list unrelated files (if any).
136177
Otherwise, please see the [wiki section](https://github.com/projecthamster/hamster/wiki/Tips-and-Tricks#uninstall)
137178

179+
##### Flatpak
180+
181+
To remove the installed flatpak, just run:
182+
183+
```bash
184+
flatpak uninstall org.gnome.Hamster
185+
```
186+
138187
#### Troubleshooting
139188

140189
[wiki section](https://github.com/projecthamster/hamster/wiki/Tips-and-Tricks#troubleshooting)
@@ -178,7 +227,31 @@ run:
178227
python3 -m unittest tests.test_stuff.TestFactParsing
179228
python3 -m unittest tests.test_stuff.TestFactParsing.test_plain_name
180229

181-
#### Migrating from hamster-applet
230+
##### Flatpak
231+
232+
To run the tests inside the flatpak, use:
233+
234+
```bash
235+
flatpak-builder --run build/flatpak org.gnome.Hamster.json \
236+
python3 -m unittest
237+
```
238+
239+
#### Migrating
240+
241+
##### Migrating data to flatpak
242+
243+
If you would like to retain your data from a non-flatpak installation,
244+
you can do so by running:
245+
246+
```bash
247+
gio copy -b \
248+
~/.local/share/hamster/hamster.db \
249+
~/.var/app/org.gnome.Hamster/data/hamster/
250+
```
251+
252+
After checking everything works, you can remove the original database.
253+
254+
##### Migrating from hamster-applet
182255

183256
Previously Hamster was installed everywhere under `hamster-applet`. As
184257
the applet is long gone, the paths and file names have changed to

org.gnome.Hamster.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"app-id": "org.gnome.Hamster",
3+
"runtime": "org.gnome.Platform",
4+
"runtime-version": "3.36",
5+
"sdk": "org.gnome.Sdk",
6+
"command": "hamster",
7+
"modules": [
8+
{
9+
"name": "intltool",
10+
"sources": [
11+
{
12+
"type": "archive",
13+
"url": "https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz",
14+
"md5": "12e517cac2b57a0121cda351570f1e63"
15+
}
16+
],
17+
"cleanup": [ "*" ]
18+
},
19+
{
20+
"name": "python3-hamster-dependencies",
21+
"buildsystem": "simple",
22+
"ensure-writable": [
23+
"easy-install.pth",
24+
"setuptools.pth"
25+
],
26+
"build-commands": [
27+
"pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} dbus-python pyxdg"
28+
],
29+
"sources": [
30+
{
31+
"type": "file",
32+
"url": "https://files.pythonhosted.org/packages/62/7e/d4fb56a1695fa65da0c8d3071855fa5408447b913c58c01933c2f81a269a/dbus-python-1.2.16.tar.gz",
33+
"sha256": "11238f1d86c995d8aed2e22f04a1e3779f0d70e587caffeab4857f3c662ed5a4"
34+
},
35+
{
36+
"type": "file",
37+
"url": "https://files.pythonhosted.org/packages/39/03/12eb9062f43adb94e30f366743cb5c83fd15fef026500cd4de42c7c12280/pyxdg-0.26-py2.py3-none-any.whl",
38+
"sha256": "1948ff8e2db02156c0cccd2529b43c0cff56ebaa71f5f021bbd755bc1419190e"
39+
}
40+
]
41+
},
42+
{
43+
"name": "hamster",
44+
"buildsystem": "simple",
45+
"builddir": true,
46+
"prefix": "/app",
47+
"build-commands": [
48+
"./waf configure --prefix=${FLATPAK_DEST}",
49+
"./waf build",
50+
"./waf install"
51+
],
52+
"sources": [
53+
{
54+
"type": "dir",
55+
"path": "."
56+
}
57+
]
58+
}
59+
],
60+
"finish-args": [
61+
"--socket=wayland",
62+
"--socket=fallback-x11",
63+
"--filesystem=xdg-documents",
64+
"--own-name=org.gnome.Hamster",
65+
"--own-name=org.gnome.Hamster.GUI",
66+
"--own-name=org.gnome.Hamster.WindowServer"
67+
]
68+
}

0 commit comments

Comments
 (0)