summaryrefslogtreecommitdiffstats
path: root/src/b2qt-update-application
diff options
context:
space:
mode:
Diffstat (limited to 'src/b2qt-update-application')
-rw-r--r--src/b2qt-update-application/b2qt-update-application.pro19
-rw-r--r--src/b2qt-update-application/main.cpp1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/b2qt-update-application/b2qt-update-application.pro b/src/b2qt-update-application/b2qt-update-application.pro
index 8835eef..51fc06f 100644
--- a/src/b2qt-update-application/b2qt-update-application.pro
+++ b/src/b2qt-update-application/b2qt-update-application.pro
@@ -14,3 +14,22 @@ HEADERS += \
LIBS += -lcrypto
INSTALLS += target
target.path = /usr/bin
+
+# Find out git hash
+unix:system(which git):HAS_GIT=TRUE
+win32:system(where git.exe):HAS_GIT=TRUE
+contains(HAS_GIT, TRUE) {
+ GIT_HASH=$$system(git log -1 --format=%H)
+ !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty"
+ GIT_VERSION=$$system(git describe --tags --exact-match)
+ isEmpty(GIT_VERSION) : GIT_VERSION="unknown"
+} else {
+ GIT_HASH="unknown"
+ GIT_VERSION="unknown"
+}
+
+isEmpty(GIT_VERSION) : error("No suitable tag found")
+isEmpty(GIT_HASH) : error("No hash available")
+
+DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\""
+DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\""
diff --git a/src/b2qt-update-application/main.cpp b/src/b2qt-update-application/main.cpp
index 157af4f..353edd9 100644
--- a/src/b2qt-update-application/main.cpp
+++ b/src/b2qt-update-application/main.cpp
@@ -115,6 +115,7 @@ QStringList find_usb_storage()
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
+ printf("Version %s, SHA1 %s\n", GIT_VERSION, GIT_HASH);
mount(QString(), "/", "remount,rw");
execute("mkdir", QStringList() << "-p" << "/mnt/boot");