From 681b2c1a2418a1d2470c47fd7e5775502b086d9d Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 24 Jul 2014 10:09:03 -0400 Subject: [PATCH] version reporting: use git branch and commit if available --- daemon/.ycm_extra_conf.py | 2 +- daemon/Makefile | 23 +++++++++++++++++------ daemon/call.c | 2 +- daemon/control_tcp.c | 2 +- daemon/main.c | 6 +++--- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/daemon/.ycm_extra_conf.py b/daemon/.ycm_extra_conf.py index 647d8ed76..f46cabb73 100644 --- a/daemon/.ycm_extra_conf.py +++ b/daemon/.ycm_extra_conf.py @@ -22,7 +22,7 @@ flags = [ '-I../kernel-module/', '-D_GNU_SOURCE', '-D__DEBUG=1', -'-DMEDIAPROXY_VERSION="dummy"', +'-DRTPENGINE_VERSION="dummy"', '-DMP_PLUGIN_DIR="/usr/lib/rtpengine"', '-O2', '-fstack-protector', diff --git a/daemon/Makefile b/daemon/Makefile index e6484cff1..78b982619 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -8,16 +8,27 @@ CFLAGS+= `pkg-config --cflags openssl` CFLAGS+= `pcre-config --cflags` CFLAGS+= -I../kernel-module/ CFLAGS+= -D_GNU_SOURCE -ifneq ($(MEDIAPROXY_VERSION),) - CFLAGS+= -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" -else + +ifeq ($(RTPENGINE_VERSION),) DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) ifneq ($(DPKG_PRSCHNGLG),) - CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\"" - else - CFLAGS+= -DMEDIAPROXY_VERSION="\"undefined\"" + DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}') + endif + GIT_BR_COMMIT=$(shell git branch --no-color --no-column -v 2> /dev/null | awk -e '/^\*/ {OFS="-"; print "git", $$2, $$3}') + + ifneq ($(DPKG_PRSCHNGLG),) + RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) + endif + ifneq ($(GIT_BR_COMMIT),) + RTPENGINE_VERSION+=$(GIT_BR_COMMIT) + endif + + ifeq ($(RTPENGINE_VERSION),) + RTPENGINE_VERSION+=undefined endif endif +CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" + CFLAGS+= -DMP_PLUGIN_DIR="\"/usr/lib/rtpengine\"" #CFLAGS+= -DSRTCP_KEY_DERIVATION_RFC_COMPLIANCE diff --git a/daemon/call.c b/daemon/call.c index f3a61b793..e65449d7f 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -986,7 +986,7 @@ retry: xmlrpc_env_init(&e); xmlrpc_client_setup_global_const(&e); - xmlrpc_client_create(&e, XMLRPC_CLIENT_NO_FLAGS, "ngcp-rtpengine", MEDIAPROXY_VERSION, + xmlrpc_client_create(&e, XMLRPC_CLIENT_NO_FLAGS, "ngcp-rtpengine", RTPENGINE_VERSION, NULL, 0, &c); if (e.fault_occurred) goto fault; diff --git a/daemon/control_tcp.c b/daemon/control_tcp.c index f29c417da..443b14af0 100644 --- a/daemon/control_tcp.c +++ b/daemon/control_tcp.c @@ -123,7 +123,7 @@ static int control_stream_parse(struct control_stream *s, char *line) { else if (!strcmp(out[RE_TCP_DIV_CMD], "status")) calls_status_tcp(c->callmaster, s); else if (!strcmp(out[RE_TCP_DIV_CMD], "build") | !strcmp(out[RE_TCP_DIV_CMD], "version")) - control_stream_printf(s, "Version: %s\n", MEDIAPROXY_VERSION); + control_stream_printf(s, "Version: %s\n", RTPENGINE_VERSION); else if (!strcmp(out[RE_TCP_DIV_CMD], "controls")) control_list(c, s); else if (!strcmp(out[RE_TCP_DIV_CMD], "quit") || !strcmp(out[RE_TCP_DIV_CMD], "exit")) diff --git a/daemon/main.c b/daemon/main.c index bcad4eaaa..152be318e 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -274,7 +274,7 @@ static void options(int *argc, char ***argv) { die("Bad command line: %s\n", er->message); if (version) - die("%s\n", MEDIAPROXY_VERSION); + die("%s\n", RTPENGINE_VERSION); if (!ipv4s) die("Missing option --ip\n"); @@ -549,7 +549,7 @@ int main(int argc, char **argv) { options(&argc, &argv); create_everything(&ctx); - ilog(LOG_INFO, "Startup complete, version %s", MEDIAPROXY_VERSION); + ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION); thread_create_detach(sighandler, NULL); thread_create_detach(timer_loop, ctx.p); @@ -565,7 +565,7 @@ int main(int argc, char **argv) { threads_join_all(1); - ilog(LOG_INFO, "Version %s shutting down", MEDIAPROXY_VERSION); + ilog(LOG_INFO, "Version %s shutting down", RTPENGINE_VERSION); return 0; }