Add version to api/v1/charts
Prereleases now have the suffix _prerelease if git is not there.
Simon Nagl committed
Feb 11, 2017 at 12:08 UTC
541ed96c3a6bff68f9f4a87c4a68db8cc4517599
6 files changed
+9
-5
configure.ac
+2
-2
@@ -7,12 +7,12 @@ define([VERSION_MAJOR], [1])
7
define([VERSION_MINOR], [5])
8
define([VERSION_FIX], [1])
9
define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
10
-define([VERSION_SUFFIX], [_master])
10
+define([VERSION_SUFFIX], [_prerelease])
11
12
dnl Set to "1" for a first RPM release of a new version
13
PACKAGE_RPM_RELEASE="0.0.$(echo VERSION_SUFFIX | sed s/^_//)"
14
15
-define([VERSION_STRING], m4_esyscmd_s(git describe 2> /dev/null))
15
+define([VERSION_STRING], m4_esyscmd_s(git describe 2>/dev/null | sed 's/^v//'))
16
m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_NUMBER[]VERSION_SUFFIX)])
17
18
AC_INIT([netdata], VERSION_STRING)
packaging/update-tags
+1
-1
@@ -135,7 +135,7 @@ then
135
fi
136
137
echo "Resetting suffix in configure.ac:"
138
- sed -i -e 's/define(\[VERSION_SUFFIX\], \[.*])/define([VERSION_SUFFIX], [_master])/' configure.ac
138
+ sed -i -e 's/define(\[VERSION_SUFFIX\], \[.*])/define([VERSION_SUFFIX], [_prerelease])/' configure.ac
139
sed -i -e 's:^PACKAGE_RPM_RELEASE=.*:PACKAGE_RPM_RELEASE="0.0.$(echo VERSION_SUFFIX | sed s/^_//)":' configure.ac
140
141
echo "Committing new configure.ac:"
src/common.c
+1
@@ -13,6 +13,7 @@ int enable_ksm = 1;
13
14
volatile sig_atomic_t netdata_exit = 0;
15
const char *os_type = NETDATA_OS_TYPE;
16
+const char *program_version = VERSION;
17
18
// ----------------------------------------------------------------------------
19
// memory allocation functions that handle failures
src/common.h
+2
@@ -277,6 +277,8 @@ extern void get_system_HZ(void);
277
extern volatile sig_atomic_t netdata_exit;
278
extern const char *os_type;
279
280
+extern const char *program_version;
281
+
282
/* fix for alpine linux */
283
#ifndef RUSAGE_THREAD
284
#ifdef RUSAGE_CHILDREN
src/main.c
+1
-2
@@ -434,8 +434,7 @@ int main(int argc, char **argv)
434
config_set("global", "run as user", optarg);
435
break;
436
case 'v':
437
- // TODO: Outsource version to makefile which can compute version from git.
438
- printf("netdata %s\n", VERSION);
437
+ printf("%s %s\n", program_name, program_version);
438
return 0;
439
case 'W':
440
{
src/rrd2json.c
+2
@@ -85,11 +85,13 @@ void rrd_stats_api_v1_charts(BUFFER *wb)
85
86
buffer_sprintf(wb, "{\n"
87
"\t\"hostname\": \"%s\""
88
+ ",\n\t\"version\": \"%s\""
89
",\n\t\"os\": \"%s\""
90
",\n\t\"update_every\": %d"
91
",\n\t\"history\": %d"
92
",\n\t\"charts\": {"
93
, localhost.hostname
94
+ , program_version
95
, os_type
96
, rrd_update_every
97
, rrd_default_history_entries