dragotin / kraft

Kraft helps to handle your daily quotes and invoices in your small business.
http://volle-kraft-voraus.de
GNU General Public License v2.0
56 stars 18 forks source link

Include grantlee in the AppImage #142

Closed noseshimself closed 2 years ago

noseshimself commented 2 years ago

(unless you plan to remove it).

On a Debian (Googlian) I'm getting

Using this template:  "/home/ap/NextCloud/xxx/Kraft/reports/invoice_xxx.gtmpl"
grantlee.template: "Plugin library 'grantlee_defaulttags' not found."
Grantlee template load failed: "Plugin library 'grantlee_defaulttags' not found."

which might be the result of some initialization being wrong.

I used the packages provided by apt

and the libraries are on the system:

ap@Office:/usr/lib/x86_64-linux-gnu/grantlee/5.2$ ls -al /lib/x86_64-linux-gnu/grantlee/5.2/
insgesamt 488
drwxr-xr-x 1 root root    182 30. Jun 03:12 .
drwxr-xr-x 1 root root      6 30. Jun 03:12 ..
-rw-r--r-- 1 root root 134760 11. Jan 2021  grantlee_defaultfilters.so
-rw-r--r-- 1 root root 188256 11. Jan 2021  grantlee_defaulttags.so
-rw-r--r-- 1 root root  97248 11. Jan 2021  grantlee_i18ntags.so
-rw-r--r-- 1 root root  77224 11. Jan 2021  grantlee_loadertags.so
ap@Office:/usr/lib/x86_64-linux-gnu/grantlee/5.2$ apt search grantlee
Sortierung… Fertig
Volltextsuche… Fertig
libgrantlee-templates5/stable,now 5.2.0-3 amd64  [installiert]
  Qt-Vorlagen-Engine -- Templates

libgrantlee-textdocument5/stable,now 5.2.0-3 amd64  [installiert]
  Grantlee templating library for Qt - TextDocument

libgrantlee5-dev/stable,now 5.2.0-3 amd64  [installiert]
  Qt-Vorlagen-Engine -- Entwicklungsdateien

The libraries are in Debian's standard location. Please keep in mind that the system is not carrying a standard KDE/Qt5 installation which might have links to them.

noseshimself commented 2 years ago

I took a closer look at the problem:

According to http://www.grantlee.org/apidox/using_and_deploying.html:

Grantlee looks for plugins in the paths from the Engine::pluginPaths property. It does so in the same order they appear there.

The property defaults to the following directories

The default plugin directory of your Qt installation (qmake -query QT_INSTALL_PLUGINS). The directories specified in the environment variable QT_PLUGIN_DIR. The default plugin directory of your Grantlee installation.

It seems that the AppImage does contain grantlee and its libraries but due to the fuse mount the path is off. At the same time the path on a Debian system is different from the path on the system the AppImage was created on. To make things even more complicated, there is no QT on the system kraft is running on.

Result: No printing if Grantlee templates are involved.

Fixing that by defining QT_PLUGIN_DIR before running kraft should be easy. Wait... With the mount point of the AppImage moving with every launch, that's impossible.

Would it be possible to include the necessary setup to find and set the path before initializing the Grantlee template engine?

The paths used to search for plugins can be overriden by using Engine::setPluginPaths. If you just want to add some additional paths use Engine::addPluginPath. The added path will be prepended to the list of search paths.

If kraft is running as AppImage there should be an environment variable APPDIR pointing to its current root.

dragotin commented 2 years ago

Also add missing icons:

kraft_appimage

dragotin commented 2 years ago

The original issue around grantlee should be fixed in the master builds of the AppImage available here: https://download.opensuse.org/repositories/home:/kfreitag:/KraftAppI/AppImage/

Grantlee is looking for its plugins pretty strict in the Qt plugin dir. The grantlee package does put it somewhere else.

Fixed by a brave link in the appimage.yml that creates the AppImage in OBS by

  - mkdir -p $BUILD_APPDIR/usr/lib64/qt5/plugins/grantlee
  - cd $BUILD_APPDIR/usr/lib64/qt5/plugins/grantlee && ln -s ../../../grantlee/5.2 .
noseshimself commented 1 year ago

Debichrome:

All configuration files remained in place after I did

apt remove kraft
[download kraft-master..., copy it to /usr/local/bin and ln -s kraft-... kraft
cp kraft.desktop /usr/share/applications
kraft

The drama unfolds:

image

So it found a valid database configuration (but was not able to connect to the database itself; that message is a bit misleading)... And wants me to create a new database:

image image

What is the reason for this requiring a new setup even though there is a valid (and connectable -- I did a mysqldump before risking to destroy the data) database? I abort the setup I will get this:

image

Using another client (compiled on 20220826) shows the database still being available and working as intended.

If I try to finish the database setup the behavior is similar to not having installed the package ``libqt5sql5-mysql```and tcpdump shows no IP packets leaving in the direction of the database server. Is it possible that the AppImage is expecting this library in a different location?