From c01d922be185228dc24a763743f678543a942a79 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 21 Nov 2023 09:36:16 +0100 Subject: [PATCH 01/10] waf: Replace subprocess text argument to fix python3.6 compatibility The python docs say: > New in version 3.7: text was added as a more readable alias for universal_newlines. So the code introduced in commit 99cef056 (Remove duplicated version detection code from waf/wscript) broke installs on python 3.6. This is fixed by passing an explicit encoding, which also has the effect of opening the pipe in text mode. This could have changed to universal_newlines instead, but that name seems a bit confusing and does not indicate that the result will be decoded into a string instead of returning bytes, so using encoding seems better. --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index cf89a7889..086aaac70 100644 --- a/wscript +++ b/wscript @@ -6,7 +6,7 @@ import subprocess from waflib import Utils # Reuse code from hamster to figure out the version number to use -process = subprocess.run(["python3", "src/hamster/version.py"], check=True, stdout=subprocess.PIPE, text=True) +process = subprocess.run(["python3", "src/hamster/version.py"], check=True, stdout=subprocess.PIPE, encoding='UTF-8') VERSION = process.stdout APPNAME = 'hamster' From 5676f396e882afeae91a2152071e93c7b9c78661 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 21 Nov 2023 09:52:14 +0100 Subject: [PATCH 02/10] Strip whitespace from autodetected versions This is mostly needed for the `VERSION` file, which could contain a trailing newline (e.g. vim always adds one unless you take effort to prevent that). For good measure, the git describe output also has whitespace stripped. --- src/hamster/version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hamster/version.py b/src/hamster/version.py index 1a3d8189b..5a064d887 100644 --- a/src/hamster/version.py +++ b/src/hamster/version.py @@ -19,11 +19,11 @@ def get_uninstalled_version(): if rc == 0: import re # Strip "v" prefix that is used in git tags - return re.sub(r'^v', '', output) + return re.sub(r'^v', '', output.strip()) else: from pathlib import Path with open(Path(__file__).parent / 'VERSION', 'r') as f: - return f.read() + return f.read().strip() def get_version(): """ From bcbfaee65d84960f533b3ab04537cd51542fba1a Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 21 Nov 2023 10:01:32 +0100 Subject: [PATCH 03/10] waf: Remove unused variables from defs.py Only DATA_DIR and VERSION are actually used. Removing LIB_DIR helps to make reproducible packages (presumably because then there is no reference to the build machine architecture in the resulting installed files, producing the same package regardless of build machine), see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1028310 For consistency, just remove the other unused variables too. --- src/hamster/defs.py.in | 3 --- wscript | 1 - 2 files changed, 4 deletions(-) diff --git a/src/hamster/defs.py.in b/src/hamster/defs.py.in index b87ff3695..c74866049 100644 --- a/src/hamster/defs.py.in +++ b/src/hamster/defs.py.in @@ -1,5 +1,2 @@ DATA_DIR = "@DATADIR@" -LIB_DIR = "@LIBDIR@" VERSION = "@VERSION@" -PACKAGE = "@PACKAGE@" -PYTHONDIR = "@PYTHONDIR@" diff --git a/wscript b/wscript index 086aaac70..17dc579d3 100644 --- a/wscript +++ b/wscript @@ -49,7 +49,6 @@ def configure(ctx): ctx.env.VERSION = VERSION ctx.env.GETTEXT_PACKAGE = "hamster" - ctx.env.PACKAGE = "hamster" ctx.recurse("help") From f14e4276d11c5d69fb6da844735cffc7a718f1f1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 21 Nov 2023 18:01:03 +0100 Subject: [PATCH 04/10] Drop check for ancient dbus versions This check warned against using a very old dbus version that caused breakage. However, the check used the `distutils` package for version comparison, but that package is deprecated and will be removed in an upcoming python version. Since there does not seem to be a direct alternative for version comparisons in the core Python libraries and this check is about a 4-year old dbus version anyway, just remove the check rather than adding an extra dependency just for this. --- src/hamster/client.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/hamster/client.py b/src/hamster/client.py index 8a0c297c3..ab3d3ba04 100644 --- a/src/hamster/client.py +++ b/src/hamster/client.py @@ -25,7 +25,6 @@ import sys from calendar import timegm -from distutils.version import LooseVersion from gi.repository import GObject as gobject from textwrap import dedent @@ -42,16 +41,6 @@ from hamster.lib import datetime as dt -# bug fixed in dbus-python 1.2.14 (released on 2019-11-25) -assert not ( - sys.version_info >= (3, 8) - and LooseVersion(dbus.__version__) < LooseVersion("1.2.14") - ), """python3.8 changed str(). - That broke hamster (https://github.com/projecthamster/hamster/issues/477). - Please upgrade to dbus-python >= 1.2.14. - """ - - class Storage(gobject.GObject): """Hamster client class, communicating to hamster storage daemon via d-bus. Subscribe to the `tags-changed`, `facts-changed` and `activities-changed` From 22ddc687e1d9caff4d20196b895acc39a96d934b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 27 Nov 2023 09:09:07 +0100 Subject: [PATCH 05/10] waf: Strip trailing whitespace from wscript files --- data/wscript | 8 ++++---- wscript | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data/wscript b/data/wscript index e5a54fa5b..84a1939cd 100644 --- a/data/wscript +++ b/data/wscript @@ -1,7 +1,7 @@ # This file is meant to be included in the root wscript, # through the recurse("data") command. # An advantage of keeping it there -# instead of blending it in the root wscript build() +# instead of blending it in the root wscript build() # is that the files are looked for in the same folder # (no need to prepend data/ everywhere) @@ -30,15 +30,15 @@ def build(ctx): dict = ctx.env, install_path = "${DATADIR}/applications" ) - + start_dir = ctx.path.find_dir('.') - + # glade builder files ctx.install_files('${DATADIR}/hamster', start_dir.ant_glob('*.ui')) # default files ctx.install_files('${DATADIR}/hamster', 'hamster.db') ctx.install_files('${DATADIR}/hamster', 'report_template.html') - + # icons ctx.install_files('${DATADIR}/hamster/art', start_dir.ant_glob('art/*.png')) ctx.install_files('${DATADIR}/icons/hicolor/16x16/apps', 'art/16x16/org.gnome.Hamster.GUI.png') diff --git a/wscript b/wscript index 17dc579d3..91169150b 100644 --- a/wscript +++ b/wscript @@ -22,23 +22,23 @@ def options(ctx): # hence need to replace the whole option ctx.parser.remove_option('--prefix') default_prefix = '/usr' - + ctx.add_option('--prefix', dest='prefix', default=default_prefix, help='installation prefix [default: {}]'.format(default_prefix)) - + ctx.add_option('--skip-gsettings', dest='skip_gsettings', action='store_true', help='skip gsettings schemas build and installation (for packagers)') - + ctx.add_option('--skip-icon-cache-update', dest='skip_icon_cache_update', action='store_true', help='skip icon cache update (for packagers)') def configure(ctx): ctx.load('gnu_dirs') # for DATADIR - + if not ctx.options.skip_gsettings: ctx.load('glib2') # for GSettings support - + ctx.load('python') ctx.check_python_version(minver=(3,4,0)) @@ -49,9 +49,9 @@ def configure(ctx): ctx.env.VERSION = VERSION ctx.env.GETTEXT_PACKAGE = "hamster" - + ctx.recurse("help") - + # options are tied to a specific ./waf invocation (one terminal line), # and woud have to be given again at any other ./waf invocation # that is trouble when one wants to ./waf uninstall much later; @@ -61,7 +61,7 @@ def configure(ctx): for name in ('prefix', 'skip_gsettings', 'skip_icon_cache_update'): value = getattr(ctx.options, name) setattr(ctx.env, name, value) - + def build(ctx): ctx.install_as('${LIBEXECDIR}/hamster/hamster-service', "src/hamster-service.py", chmod=Utils.O755) From 34787d900b41950629b64bd4525596f52b3852f9 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 27 Nov 2023 09:14:43 +0100 Subject: [PATCH 06/10] Move dbus service files into data subdirectory --- .../org.gnome.Hamster.GUI.service.in | 0 .../org.gnome.Hamster.WindowServer.service.in | 0 .../org.gnome.Hamster.service.in | 0 data/wscript | 19 +++++++++++++++++++ wscript | 18 ------------------ 5 files changed, 19 insertions(+), 18 deletions(-) rename org.gnome.Hamster.GUI.service.in => data/org.gnome.Hamster.GUI.service.in (100%) rename org.gnome.Hamster.WindowServer.service.in => data/org.gnome.Hamster.WindowServer.service.in (100%) rename org.gnome.Hamster.service.in => data/org.gnome.Hamster.service.in (100%) diff --git a/org.gnome.Hamster.GUI.service.in b/data/org.gnome.Hamster.GUI.service.in similarity index 100% rename from org.gnome.Hamster.GUI.service.in rename to data/org.gnome.Hamster.GUI.service.in diff --git a/org.gnome.Hamster.WindowServer.service.in b/data/org.gnome.Hamster.WindowServer.service.in similarity index 100% rename from org.gnome.Hamster.WindowServer.service.in rename to data/org.gnome.Hamster.WindowServer.service.in diff --git a/org.gnome.Hamster.service.in b/data/org.gnome.Hamster.service.in similarity index 100% rename from org.gnome.Hamster.service.in rename to data/org.gnome.Hamster.service.in diff --git a/data/wscript b/data/wscript index 84a1939cd..0db85cba1 100644 --- a/data/wscript +++ b/data/wscript @@ -51,6 +51,25 @@ def build(ctx): if not ctx.env.skip_icon_cache_update: ctx.add_post_fun(update_icon_cache) + # dbus service files + ctx(features="subst", + source= "org.gnome.Hamster.service.in", + target= "org.gnome.Hamster.service", + install_path="${DATADIR}/dbus-1/services", + ) + + ctx(features="subst", + source= "org.gnome.Hamster.GUI.service.in", + target= "org.gnome.Hamster.GUI.service", + install_path="${DATADIR}/dbus-1/services", + ) + + ctx(features="subst", + source= "org.gnome.Hamster.WindowServer.service.in", + target= "org.gnome.Hamster.WindowServer.service", + install_path="${DATADIR}/dbus-1/services", + ) + # icon cache update def update_icon_cache(ctx): diff --git a/wscript b/wscript index 91169150b..f5a7ac153 100644 --- a/wscript +++ b/wscript @@ -84,23 +84,5 @@ def build(ctx): install_path="${PYTHONDIR}/hamster" ) - ctx(features="subst", - source= "org.gnome.Hamster.service.in", - target= "org.gnome.Hamster.service", - install_path="${DATADIR}/dbus-1/services", - ) - - ctx(features="subst", - source= "org.gnome.Hamster.GUI.service.in", - target= "org.gnome.Hamster.GUI.service", - install_path="${DATADIR}/dbus-1/services", - ) - - ctx(features="subst", - source= "org.gnome.Hamster.WindowServer.service.in", - target= "org.gnome.Hamster.WindowServer.service", - install_path="${DATADIR}/dbus-1/services", - ) - # look for wscript into further directories ctx.recurse("po data help") From c72e094b7cb44cb0ba2c82082fdfad89ebe1a38c Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 27 Nov 2023 09:16:30 +0100 Subject: [PATCH 07/10] Move default screenshot into data subdirectory --- data/org.gnome.Hamster.metainfo.xml.in | 2 +- screenshot.png => data/screenshots/overview.png | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename screenshot.png => data/screenshots/overview.png (100%) diff --git a/data/org.gnome.Hamster.metainfo.xml.in b/data/org.gnome.Hamster.metainfo.xml.in index 81e3000c9..c0a12cec3 100644 --- a/data/org.gnome.Hamster.metainfo.xml.in +++ b/data/org.gnome.Hamster.metainfo.xml.in @@ -35,7 +35,7 @@ The overview window - https://raw.githubusercontent.com/projecthamster/hamster/master/screenshot.png + https://raw.githubusercontent.com/projecthamster/hamster/master/data/screenshots/overview.png The overview window with statistics diff --git a/screenshot.png b/data/screenshots/overview.png similarity index 100% rename from screenshot.png rename to data/screenshots/overview.png From 0819b45317582da4edeccbf98b293f644321eae7 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 27 Nov 2023 09:17:17 +0100 Subject: [PATCH 08/10] Add third screenshot to metainfo.xml file --- data/org.gnome.Hamster.metainfo.xml.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/org.gnome.Hamster.metainfo.xml.in b/data/org.gnome.Hamster.metainfo.xml.in index c0a12cec3..f7e790278 100644 --- a/data/org.gnome.Hamster.metainfo.xml.in +++ b/data/org.gnome.Hamster.metainfo.xml.in @@ -41,6 +41,10 @@ The overview window with statistics https://raw.githubusercontent.com/projecthamster/hamster/master/data/screenshots/overview2.png + + The editor window + https://raw.githubusercontent.com/projecthamster/hamster/master/data/screenshots/editor.png + hamster https://github.com/projecthamster/hamster/wiki From e766df493b1f2fc45f3275effc5361d203aa553f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sat, 2 Dec 2023 18:09:50 +0100 Subject: [PATCH 09/10] flatpak: Move manifest file into data subdirectory --- .github/workflows/testing.yml | 4 ++-- README.md | 4 ++-- org.gnome.Hamster.yml => data/org.gnome.Hamster.flatpak.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename org.gnome.Hamster.yml => data/org.gnome.Hamster.flatpak.yml (98%) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 7eac188e6..e41475317 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -102,10 +102,10 @@ jobs: flatpak install --user -y flathub org.gnome.Platform//45 org.gnome.Sdk//45 - name: Build application run: | - flatpak-builder --repo=build/flatpak/repo build/flatpak/tmp org.gnome.Hamster.yml + flatpak-builder --repo=build/flatpak/repo build/flatpak/tmp data/org.gnome.Hamster.flatpak.yml - name: Run tests inside sandbox run: | - dbus-launch flatpak-builder --run build/flatpak/tmp org.gnome.Hamster.yml python3 -m unittest + dbus-launch flatpak-builder --run build/flatpak/tmp data/org.gnome.Hamster.flatpak.yml python3 -m unittest - name: Export bundle and try to install it run: | mkdir -p dist diff --git a/README.md b/README.md index 91b671007..b3c116d37 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ GNOME SDK beforehand (an error will notify you about it, if needed). Execute: ```bash flatpak-builder --force-clean --user --install \ - build/flatpak org.gnome.Hamster.yml + build/flatpak data/org.gnome.Hamster.flatpak.yml ``` This creates a temporary flatpack build folder in the ``build/flatpak`` @@ -247,7 +247,7 @@ run: To run the tests inside the flatpak, use: ```bash -flatpak-builder --run build/flatpak org.gnome.Hamster.yml \ +flatpak-builder --run build/flatpak data/org.gnome.Hamster.flatpak.yml \ python3 -m unittest ``` diff --git a/org.gnome.Hamster.yml b/data/org.gnome.Hamster.flatpak.yml similarity index 98% rename from org.gnome.Hamster.yml rename to data/org.gnome.Hamster.flatpak.yml index 47c285eda..7539591fc 100644 --- a/org.gnome.Hamster.yml +++ b/data/org.gnome.Hamster.flatpak.yml @@ -34,7 +34,7 @@ modules: - "./waf install" sources: - type: dir - path: "." + path: ".." finish-args: - "--socket=wayland" - "--socket=fallback-x11" From 685dc5fe989b056314aa289fec8acfa4ed3b9812 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 3 Dec 2023 16:52:52 +0100 Subject: [PATCH 10/10] gitignore: Add .flatpack-builder --- src/hamster/.gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hamster/.gitignore b/src/hamster/.gitignore index 414abbf74..a8213322e 100644 --- a/src/hamster/.gitignore +++ b/src/hamster/.gitignore @@ -1,4 +1,3 @@ *.pyc defs.py - - +.flatpak-builder