Subject: [PATCH] testing/hamster-time-tracker: new aport

From: Hakan Erduman <[email-masked]>
Date: Thu, 6 Jan 2022 18:45:15 +0100

Hamster is time tracking for individuals.

	It is a python3/gtk3 rewrite of the original hamster-applet.
	A flatpak exists but is rather clumsy in alpine.
---
I am willing to maintain this and the adjacent xfce4-hamster-plugin.
---
 testing/hamster-time-tracker/APKBUILD         | 50 +++++++++++++++++++
 testing/hamster-time-tracker/catch-i18n.patch | 31 ++++++++++++
 2 files changed, 81 insertions(+)
 create mode 100644 testing/hamster-time-tracker/APKBUILD
 create mode 100644 testing/hamster-time-tracker/catch-i18n.patch

diff --git a/testing/hamster-time-tracker/APKBUILD b/testing/hamster-time-tracker/APKBUILD
new file mode 100644
index 0000000000..0c61699fcc
--- /dev/null
+++ b/testing/hamster-time-tracker/APKBUILD
@@ -0,0 +1,50 @@
+# Contributor: Hakan Erduman <[email-masked]>
+# Maintainer: Hakan Erduman <[email-masked]>
+pkgname="hamster-time-tracker"
+pkgver=3.0.2
+pkgrel=0
+pkgdesc="time tracking for individuals"
+url="https://github.com/projecthamster/hamster"
+arch="noarch"
+license="GPL-3.0-or-later"
+makedepends="
+	gettext
+	gtk+3.0-dev
+	gtk-update-icon-cache
+	intltool
+	glib-dev
+	py3-cairo
+	py3-dbus
+	py3-xdg
+	"
+source="
+	$pkgname-$pkgver.tar.gz::https://github.com/projecthamster/hamster/archive/refs/tags/v$pkgver.tar.gz
+	catch-i18n.patch
+"
+builddir="$srcdir/hamster-$pkgver"
+subpackages="
+	$pkgname-lang
+	$pkgname-doc
+	$pkgname-bash-completion
+"
+
+build() {
+	cd $builddir
+	python3 ./waf configure --skip-gsettings --skip-icon-cache-update
+	python3 ./waf build
+}
+
+package() {
+	cd $builddir
+	python3 ./waf install --destdir="$pkgdir"
+	install -Dm644 -t "$pkgdir"/usr/share/glib-2.0/schemas ./data/org.gnome.hamster.gschema.xml
+}
+
+check() {
+	python3 -m unittest || true
+}
+
+sha512sums="
+f619746e6742cf798a40fadf2b38c489a94693b6b55403839f80c3abc618b2795511242664f8a9ce2c070fd178c117462720f52ffb7c3c32aa801c63bdbaaabc  hamster-time-tracker-3.0.2.tar.gz
+84366bdc252d1f3bec3f70f897d98a75bbffc8e135535beb84feac6656efbbb1c3abaca69a0447b3ca35e7c4906e7f86893b286aaf01e90c9bbd74f52537a853  catch-i18n.patch
+"
diff --git a/testing/hamster-time-tracker/catch-i18n.patch b/testing/hamster-time-tracker/catch-i18n.patch
new file mode 100644
index 0000000000..9d56208531
--- /dev/null
+++ b/testing/hamster-time-tracker/catch-i18n.patch
@@ -0,0 +1,31 @@
+diff --git a/src/hamster/lib/i18n.py b/src/hamster/lib/i18n.py
+index 7bb89773..caab44d8 100644
+--- a/src/hamster/lib/i18n.py
++++ b/src/hamster/lib/i18n.py
+@@ -14,16 +14,19 @@ def setup_i18n():
+     # localedir/language.mo at it's best (after build)
+     # and there does not seem to be any way to run straight from sources
+     if hamster.installed:
+-        from hamster import defs  # only available when running installed
+-        locale_dir = os.path.realpath(os.path.join(defs.DATA_DIR, "locale"))
++        try:
++            from hamster import defs  # only available when running installed
++            locale_dir = os.path.realpath(os.path.join(defs.DATA_DIR, "locale"))
+ 
+-        for module in (locale,gettext):
+-            module.bindtextdomain('hamster', locale_dir)
+-            module.textdomain('hamster')
++            for module in (locale,gettext):
++                module.bindtextdomain('hamster', locale_dir)
++                module.textdomain('hamster')
+ 
+-            module.bind_textdomain_codeset('hamster','utf8')
++                module.bind_textdomain_codeset('hamster','utf8')
+ 
+-        gettext.install("hamster", locale_dir)
++            gettext.install("hamster", locale_dir)
++        except:
++            gettext.install("hamster-uninstalled")
+ 
+     else:
+         gettext.install("hamster-uninstalled")
-- 
2.34.1

---

From: Hakan Erduman <[email-masked]>
Date: Fri, 7 Jan 2022 10:05:16 +0100

It is a python3/gtk3 rewrite of the original hamster-applet.
	A flatpak exists but is rather clumsy in alpine.
---
I am willing to maintain this and the adjacent xfce4-hamster-plugin.
---
 ...eError-if-bindtextdomain-isn-t-there.patch | 35 ++++++++++++
 testing/hamster-time-tracker/APKBUILD         | 57 +++++++++++++++++++
 2 files changed, 92 insertions(+)
 create mode 100644 testing/hamster-time-tracker/0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
 create mode 100644 testing/hamster-time-tracker/APKBUILD

diff --git a/testing/hamster-time-tracker/0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch b/testing/hamster-time-tracker/0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
new file mode 100644
index 0000000000..2bd68a770c
--- /dev/null
+++ b/testing/hamster-time-tracker/0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
@@ -0,0 +1,35 @@
+From 1bfb5def3babb3d4ee9b9c865e029e485b5f07ae Mon Sep 17 00:00:00 2001
+From: Hakan Erduman <[email-masked]>
+Date: Fri, 7 Jan 2022 09:44:04 +0100
+Subject: [PATCH] Catch AttributeError if bindtextdomain isn't there
+
+	Affects musl based python compilations
+	and may be also useful for the *BSDs
+---
+ src/hamster/lib/i18n.py | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/src/hamster/lib/i18n.py b/src/hamster/lib/i18n.py
+index 7bb89773..58c435a4 100644
+--- a/src/hamster/lib/i18n.py
++++ b/src/hamster/lib/i18n.py
+@@ -18,10 +18,13 @@ def setup_i18n():
+         locale_dir = os.path.realpath(os.path.join(defs.DATA_DIR, "locale"))
+ 
+         for module in (locale,gettext):
+-            module.bindtextdomain('hamster', locale_dir)
+-            module.textdomain('hamster')
++	        try:
++	            module.bindtextdomain('hamster', locale_dir)
++	            module.textdomain('hamster')
+ 
+-            module.bind_textdomain_codeset('hamster','utf8')
++	            module.bind_textdomain_codeset('hamster','utf8')
++	        except:
++	            continue
+ 
+         gettext.install("hamster", locale_dir)
+ 
+-- 
+2.34.1
+
diff --git a/testing/hamster-time-tracker/APKBUILD b/testing/hamster-time-tracker/APKBUILD
new file mode 100644
index 0000000000..decffe5a1e
--- /dev/null
+++ b/testing/hamster-time-tracker/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: Hakan Erduman <[email-masked]>
+# Maintainer: Hakan Erduman <[email-masked]>
+pkgname="hamster-time-tracker"
+pkgver=3.0.2
+pkgrel=0
+pkgdesc="time tracking for individuals"
+url="https://github.com/projecthamster/hamster"
+arch="noarch"
+license="GPL-3.0-or-later"
+makedepends="
+	intltool
+	itstool
+	"
+checkdepends="
+	dbus-x11
+	xvfb-run
+	"
+depends="
+	gsettings-desktop-schemas
+	gtk+3.0
+	py3-cairo
+	py3-gobject3
+	py3-dbus
+	py3-xdg
+	"
+conflicts="hamster-applet"
+source="
+	$pkgname-$pkgver.tar.gz::https://github.com/projecthamster/hamster/archive/refs/tags/v$pkgver.tar.gz
+	0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
+	"
+builddir="$srcdir/hamster-$pkgver"
+subpackages="
+	$pkgname-lang
+	$pkgname-doc
+	$pkgname-bash-completion
+	"
+
+build() {
+	python3 ./waf configure --skip-gsettings --skip-icon-cache-update
+	python3 ./waf build
+}
+
+package() {
+	python3 ./waf install --destdir="$pkgdir"
+	install -Dm644 -t "$pkgdir"/usr/share/glib-2.0/schemas ./data/org.gnome.hamster.gschema.xml
+}
+
+check() {
+	install -Dm644 -t ~/schemas ./data/org.gnome.hamster.gschema.xml
+	export GSETTINGS_SCHEMA_DIR=~/schemas/
+	dbus-launch xvfb-run python3 -m unittest
+}
+
+sha512sums="
+f619746e6742cf798a40fadf2b38c489a94693b6b55403839f80c3abc618b2795511242664f8a9ce2c070fd178c117462720f52ffb7c3c32aa801c63bdbaaabc  hamster-time-tracker-3.0.2.tar.gz
+94fbc2179870174c4c012533de5e7268dfea8c3449a69c2a1d2978b9e217033815fa17639436d2ed25bcf6015fb5f5d935222b4aa827f4cc62f9fa2443954c3f  0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
+"
-- 
2.34.1

---

From: Hakan Erduman <[email-masked]>
Date: Fri, 7 Jan 2022 11:43:52 +0100

It is a python3/gtk3 rewrite of the original hamster-applet.
	A flatpak exists but is rather clumsy in alpine.
---
This fixes the issues raised from the first patch:
- tests run now in clean chroot
- indentation
- removed surplus 'cd to $builddir'
- fixed dependencies
- refactored patch to be more telling

Still to do:
- decide 'webbrowser' dependency
---
 ...eError-if-bindtextdomain-isn-t-there.patch | 35 +++++++++++
 testing/hamster-time-tracker/APKBUILD         | 59 +++++++++++++++++++
 2 files changed, 94 insertions(+)
 create mode 100644 testing/hamster-time-tracker/0001-Catch-AttributeError-if-bindtextdomain-isn-t-there.patch
 create mode 100644 testing/hamster-time-tracker/APKBUILD

index 0000000000..8a380a19d8
@@ -0,0 +1,59 @@
+	export XDG_RUNTIME_DIR="$builddir"
+	export GSETTINGS_SCHEMA_DIR="$builddir/schemas"
+	install -Dm644 -t "$builddir/schemas" ./data/org.gnome.hamster.gschema.xml
+	glib-compile-schemas "$builddir/schemas"
+	dbus-run-session xvfb-run python3 -m unittest