Generate version information on every build

git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@686 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
Heikki Hannikainen 2012-08-24 07:58:24 +00:00
parent a84d781bb3
commit 4cf5d841c7
8 changed files with 55 additions and 11 deletions

View File

@ -16,9 +16,11 @@ CFGFILE= /opt/aprsc/etc/aprsc.conf
# generate version strings
VERSION:=$(shell cat VERSION)
SVNVERSION:=$(shell if test -x /usr/bin/svnversion -a -d ../.svn ; then /usr/bin/svnversion | sed -e 's/^.*://' | tee SVNVERSION ; else cat SVNVERSION; fi)
DATE:=$(shell date +"%Y %B %d")
RFCDATE:=$(shell date +"%a, %d %b %Y %H:%M:%S %z")
DATE:=$(shell TZ=UTC date +"%Y %B %d")
RFCDATE:=$(shell TZ=UTC date +"%a, %d %b %Y %H:%M:%S %z")
BUILD_TIME:=$(shell TZ=UTC date +"%Y-%m-%d %H:%M:%S %z")
LINUXDIST:=$(shell if test -f /etc/lsb-release ; then . /etc/lsb-release && echo "$$DISTRIB_ID-$$DISTRIB_RELEASE-$$DISTRIB_CODENAME"; fi)
BUILD_USER:=$(shell whoami)
# -------------------------------------------------------------------- #
@ -101,6 +103,22 @@ testinstall:
# -------------------------------------------------------------------- #
.PHONY: version_data.h
version_data.h:
@echo "Generating version_data.h"
@echo "/* generated automatically by Makefile - mark your branch in version_branch.h */" > version_data.h.new
@echo "#ifndef VERSIONDATA_H" >> version_data.h.new
@echo "#define VERSIONDATA_H" >> version_data.h.new
@echo "#define SVNVERSION \"$(SVNVERSION)\"" >> version_data.h.new
@echo "#define BUILD_TIME \"$(BUILD_TIME)\"" >> version_data.h.new
@echo "#define BUILD_USER \"$(BUILD_USER)\"" >> version_data.h.new
@echo "#endif" >> version_data.h.new
@if test ! -f /version_data.h; then cp version_data.h.new version_data.h; fi
@diff -q version_data.h.new version_data.h || mv version_data.h.new version_data.h
@rm -f version_data.h.new
# -------------------------------------------------------------------- #
OBJS = aprsc.o accept.o worker.o \
login.o incoming.o dupecheck.o outgoing.o \
clientlist.o client_heard.o \
@ -111,7 +129,7 @@ OBJS = aprsc.o accept.o worker.o \
keyhash.o \
filter.o cellmalloc.o historydb.o \
counterdata.o status.o cJSON.o \
http.o \
http.o version.o \
@LIBOBJS@
clean:

View File

@ -37,6 +37,7 @@
#include "worker.h"
#include "status.h"
#include "http.h"
#include "version.h"
#include "dupecheck.h"
#include "filter.h"
@ -116,7 +117,7 @@ void parse_cmdline(int argc, char *argv[])
break;
case '?':
case 'h':
fprintf(stderr, "%s\n", VERSTR);
fprintf(stderr, "%s\n", verstr);
failed = 1;
}
}

View File

@ -12,9 +12,6 @@
#define CONFIG_H
#define PROGNAME "aprsc"
#define VERSION "0.5.5"
#define VERSTR PROGNAME " v" VERSION
#define SERVERID PROGNAME " " VERSION
#define CRLF "\r\n"
#include <unistd.h>

View File

@ -26,6 +26,7 @@
#include "http.h"
#include "config.h"
#include "version.h"
#include "hlog.h"
#include "hmalloc.h"
#include "worker.h"

View File

@ -18,6 +18,7 @@
#include "cellmalloc.h"
#include "hmalloc.h"
#include "config.h"
#include "version.h"
#include "hlog.h"
#include "worker.h"
#include "historydb.h"
@ -90,7 +91,7 @@ char *status_json_string(int no_cache, int periodical)
cJSON_AddStringToObject(server, "admin", myadmin);
cJSON_AddStringToObject(server, "email", myemail);
cJSON_AddStringToObject(server, "software", "aprsc");
cJSON_AddStringToObject(server, "software_version", VERSION);
cJSON_AddStringToObject(server, "software_version", verstr);
cJSON_AddNumberToObject(server, "uptime", tick - startup_tick);
cJSON_AddNumberToObject(server, "t_started", startup_tick);
cJSON_AddNumberToObject(server, "t_now", tick);

View File

@ -28,6 +28,7 @@
#include <netinet/tcp.h>
#include "config.h"
#include "version.h"
#include "uplink.h"
#include "hmalloc.h"
#include "hlog.h"
@ -269,7 +270,7 @@ int uplink_login_handler(struct worker_t *self, struct client_t *c, int l4proto,
}
// TODO: The uplink login command here could maybe be improved to send a filter command.
len = sprintf(buf, "user %s pass %d vers %s\r\n", c->username, passcode, VERSTR);
len = sprintf(buf, "user %s pass %d vers %s\r\n", c->username, passcode, verstr_aprsis);
hlog(LOG_DEBUG, "%s: my login string: \"%.*s\"", c->addr_rem, len-2, buf, len);

24
src/version_branch.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef VERSION_BRANCH_H
#define VERSION_BRANCH_H
/*
* If you're building your own version of aprsc, and have actually
* made modifications in the code, please insert a branch ID here
* so that your variant can be identified.
*
* Examples:
*
* #define VERSION_BRANCH "-mycall-5"
* (for version 5 of modified tree made by MYCALL)
*
* Don't forget to put a - in the beginning, as the string will be
* concated with the version string (aprsc 1.0-725-mycall-5).
*
* Thanks!
*/
#define VERSION_BRANCH ""
#endif

View File

@ -33,6 +33,7 @@
#include "clientlist.h"
#include "client_heard.h"
#include "cellmalloc.h"
#include "version.h"
time_t now; /* current time, updated by the main thread, MAY be spun around by the simulator */
time_t tick; /* real monotonous clock, may or may not be wallclock */
@ -1135,7 +1136,7 @@ void collect_new_clients(struct worker_t *self)
/* According to http://www.aprs-is.net/ServerDesign.aspx, the server must
* initially transmit it's software name and version string.
*/
client_printf(self, c, "# " SERVERID "\r\n");
client_printf(self, c, "# %s\r\n", verstr_aprsis);
/* If the write failed immediately, c is already invalid at this point. Don't touch it. */
}
@ -1168,7 +1169,7 @@ void send_keepalives(struct worker_t *self)
// Example message:
// # javAPRSSrvr 3.12b12 1 Mar 2008 15:11:20 GMT T2FINLAND 85.188.1.32:14580
sprintf(buf, "# %.40s ",SERVERID);
sprintf(buf, "# %.40s ", verstr_aprsis);
s = buf + strlen(buf);
memset(&t, 0, sizeof(t));