summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@digia.com>2014-09-10 15:54:01 +0200
committerRainer Keller <rainer.keller@digia.com>2014-09-11 09:05:53 +0300
commit3e1d93b8c26ddd91f0c07b6fc22abe0a61e3edad (patch)
tree5137d69cf56310f6f593f71647c96ea0e7b8ff81
parentf9ddfae37b313f76f38b744c20742be6f129df94 (diff)
b2qt-update tools remember their versions
Change-Id: I68d616e419723ed6588ab6324a675b7577e9daa7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com>
-rw-r--r--src/b2qt-update-application/b2qt-update-application.pro19
-rw-r--r--src/b2qt-update-application/main.cpp1
-rw-r--r--src/b2qt-update-util/b2qt-update-util.pro19
-rw-r--r--src/b2qt-update-util/main.cpp3
4 files changed, 42 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");
diff --git a/src/b2qt-update-util/b2qt-update-util.pro b/src/b2qt-update-util/b2qt-update-util.pro
index 5ad8f71..0b5ab32 100644
--- a/src/b2qt-update-util/b2qt-update-util.pro
+++ b/src/b2qt-update-util/b2qt-update-util.pro
@@ -2,3 +2,22 @@ QT = core
SOURCES = main.cpp
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-util/main.cpp b/src/b2qt-update-util/main.cpp
index d22019e..137cbd5 100644
--- a/src/b2qt-update-util/main.cpp
+++ b/src/b2qt-update-util/main.cpp
@@ -134,6 +134,9 @@ int main(int argc, char **argv)
return start_update(QString());
else
return start_update(args.takeFirst());
+ } else if (arg == "version") {
+ printf("Version %s, SHA1 %s\n", GIT_VERSION, GIT_HASH);
+ return 0;
} else {
usage();
return 1;