ikskuh / kristall

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.
https://kristall.random-projects.net/
GNU General Public License v3.0
742 stars 42 forks source link

kristall -v option doesn't have a version when built outside a git repo #264

Closed charles2910 closed 1 year ago

charles2910 commented 1 year ago

Hi,

while building kristall for Debian sergiodj noticed an error:

--8<---------------cut here---------------start------------->8---
make[2]: Entering directory '/<<PKGBUILDDIR>>/build'
/usr/lib/qt5/bin/uic ../src/browsertab.ui -o ui_browsertab.h
/bin/sh: 1: git: not found
/bin/sh: 1: git: not found
--8<---------------cut here---------------end--------------->8---

This happens because we don't build from the git repo, but from the downloaded tarball. So the following command from src/kristall.pro fails.

DEFINES += KRISTALL_VERSION="\"$(shell cd $$PWD; git describe --tags)\""

And the built application doesn't get a proper version when kristall -v is invoked:

# xvfb-run kristall -v
new locale is "en" "American English"
kristall

We (sergiodj and I) came up with a solution to the problem - I'll attach below and will be very happy to open a PR. But I think it's very specific so you might not want it merged - it keeps working when in a git repo though.

Description: fix missing kristall version when not building in git repo
Author: Sergio Durigan Junior <sergiodj@debian.org>
Author: Carlos Henrique Lima Melara <charlesmelara@outlook.com>
Forwarded: https://github.com/MasterQ32/kristall/issues/262
Last-Update: 2022-12-29

--- a/src/kristall.pro
+++ b/src/kristall.pro
@@ -9,7 +9,13 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets network multimedia multimediawid
 # deprecated API in order to know how to port your code away from it.
 DEFINES += QT_DEPRECATED_WARNINGS

-DEFINES += KRISTALL_VERSION="\"$(shell cd $$PWD; git describe --tags)\""
+KRISTALL_VERSION = $$(KRISTALL_VERSION)
+
+isEmpty(KRISTALL_VERSION) {
+    KRISTALL_VERSION = $(shell cd $$PWD; git describe --tags)
+}
+
+DEFINES += KRISTALL_VERSION="\"$$KRISTALL_VERSION\""

 # You can also make your code fail to compile if it uses deprecated APIs.
 # In order to do so, uncomment the following line.

TLDR we're exporting KRISTALL_VERSION to the build environment so the qmake variable is not empty in our case.

ikskuh commented 1 year ago

I tried applying the patch in d88dd7bfd107dc8c22ae9b91a3b2a06bc7afe815, should be good now

charles2910 commented 1 year ago

Thanks!

And version 0.4 will be in Debian next stable release (12 - Bookworm, due around July) and also in Ubuntu 23.04, so people will be able to just apt install kristall!

ikskuh commented 1 year ago

That's pretty cool. I hope i can spend some time on Kristall the next days, so i can finally tack a 1.0 to the program and officially go into "maintainence" mode