summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-22 11:40:43 +0100
committerSimon Rettberg2017-12-22 11:40:43 +0100
commit24b5a6bdda8f09593dd908c3fc69315ebb3754e1 (patch)
tree71b72641416040fe15864f8aeb77377b6ba376c7
parentFix compile error (diff)
downloadldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.tar.gz
ldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.tar.xz
ldadp-24b5a6bdda8f09593dd908c3fc69315ebb3754e1.zip
Add version information and --version
-rw-r--r--.gitignore3
-rw-r--r--Makefile13
-rwxr-xr-xgen-version40
-rw-r--r--ldadp.c7
-rw-r--r--version.in13
5 files changed, 70 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index a7b0622..1647974 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,6 @@ config.test
*.o
*.a
/ldadp
+/version.in.h
+/.localversion
+
diff --git a/Makefile b/Makefile
index 4af6135..3c835aa 100644
--- a/Makefile
+++ b/Makefile
@@ -41,16 +41,17 @@ LIBS+=-g -lowfat -lssl -lcrypto
%: %.c
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) ${LIBS}
-ldadp: tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a
+ldadp: version.in.h tmpbuffer.o ini.o client.o server.o helper.o proxy.o epoll.o openssl.o ldap.a asn1.a
+
+version.in.h:
+ ./gen-version
qndtest: ldap.a asn1.a
-.PHONY: clean tar
-clean:
- rm -f *.[ao] ldadp qndtest
+.PHONY: clean version.in.h
-tar: clean
- cd ..; tar cvvf ldadp.tar.bz2 ldadp --use=bzip2 --exclude capture --exclude .git
+clean:
+ rm -f -- *.[ao] ldadp qndtest version.in.h
bindrequest.o: bindrequest.c ldap.h
diff --git a/gen-version b/gen-version
new file mode 100755
index 0000000..eccc47c
--- /dev/null
+++ b/gen-version
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+export LANG=C
+
+# Always create version string for repository this script lies in,
+# not the cwd... Makes usage easier in cmake/out of source builds
+ARG0="$0"
+SELF="$(readlink -f "${ARG0}")"
+if [ -n "$SELF" ]; then
+ ROOT_DIR="$(dirname "${SELF}")"
+ cd "$ROOT_DIR"
+fi
+
+MODDED=
+[ -n "$(git diff)" ] && MODDED='+LOCALMOD'
+
+VERSION=$(git describe || git rev-parse --short HEAD)
+
+BUILDTIME=$(date -R)
+
+COMMIT=$(git rev-parse HEAD)
+
+COMMITTIME=$(git log -1 --date=short --pretty=format:%cD)
+
+if [ -s ".localversion" ]; then
+ . .localversion
+fi
+
+VERSION="$VERSION$MODDED"
+
+# replace
+ssed() {
+ local fnd rep
+ fnd="%${1}%"
+ eval rep='"'\$$1'"'
+ sed "s/$fnd/$(echo "$rep" | sed 's,\\,\\\\,g;s,/,\\/,g')/g"
+}
+
+< "version.in" ssed "VERSION" | ssed "BUILDTIME" | ssed "COMMIT" | ssed "COMMITTIME" > "version.in.h"
+
diff --git a/ldadp.c b/ldadp.c
index bd9d6e0..bc5cdf9 100644
--- a/ldadp.c
+++ b/ldadp.c
@@ -12,6 +12,7 @@
#include "helper.h"
#include "openssl.h"
#include "helper.h"
+#include "version.in.h"
#include <stdio.h>
#include <socket.h>
#include <io.h>
@@ -29,6 +30,12 @@ static char *certFile = NULL, *keyFile = NULL;
int main(int argc, char **argv)
{
BOOL isdaemon = TRUE;
+ printf("Starting up ldadp %s\n", LDADP_VERSION);
+ printf("Commit: %s\n", LDADP_COMMIT);
+ printf("Commit time: %s\n", LDADP_COMMITTIME);
+ printf("Build time: %s\n", LDADP_BUILDTIME);
+ if (argc > 1 && strcmp(argv[1], "--version") == 0)
+ exit(0);
if (argc < 2) {
printf("Nö\n");
exit(1);
diff --git a/version.in b/version.in
new file mode 100644
index 0000000..88f2458
--- /dev/null
+++ b/version.in
@@ -0,0 +1,13 @@
+#ifndef _VERSION_IN_
+#define _VERSION_IN_
+
+#define LDADP_VERSION "%VERSION%"
+
+#define LDADP_COMMIT "%COMMIT%"
+
+#define LDADP_COMMITTIME "%COMMITTIME%"
+
+#define LDADP_BUILDTIME "%BUILDTIME%"
+
+#endif
+