From 61a1fd50400a9eaf64be018ace5e4d7e36f31b3e Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 6 May 2013 20:42:38 +0200 Subject: [PATCH] Be explicit about versions --- .gitignore | 1 + build-scripts/jenkins-driver | 2 +- build-scripts/set-version-auth | 9 ++++++++- build-scripts/set-version-recursor | 3 +++ configure.ac | 9 ++++++++- pdns/Makefile-recursor | 5 +++++ pdns/config-recursor.h | 1 - pdns/dist-recursor | 19 ++++++++++++++++++- pdns/misc.cc | 25 +++++++++++++++++++++++++ pdns/misc.hh | 2 ++ pdns/packethandler.cc | 2 +- pdns/pdns_recursor.cc | 26 +++++++++----------------- pdns/receiver.cc | 22 ++++++---------------- pdns/ws.cc | 2 +- 14 files changed, 88 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index 8dd3668efc..5a94d734fe 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ ltversion.m4 lt~obsolete.m4 pdns-*.tar.gz .*DS_Store +VERSION diff --git a/build-scripts/jenkins-driver b/build-scripts/jenkins-driver index 019e80e904..5c56762f96 100755 --- a/build-scripts/jenkins-driver +++ b/build-scripts/jenkins-driver @@ -25,4 +25,4 @@ then DESC="${DESC} (${PDNS_TAG})" fi java -jar /shared/jenkins-cli.jar set-build-display-name ${JOB_NAME} ${BUILD_NUMBER} "${DESC}" -fi \ No newline at end of file +fi diff --git a/build-scripts/set-version-auth b/build-scripts/set-version-auth index 4786ce767a..06163109a0 100755 --- a/build-scripts/set-version-auth +++ b/build-scripts/set-version-auth @@ -4,6 +4,13 @@ DEB_VERSION=$2 RPM_VERSION=$3 [ -z "$VERSION" -o -z "$DEB_VERSION" -o -z "$RPM_VERSION" ] && exit 1 +DIST_HOST="$(id -u -n)@$(hostname -f)" + ssed -r "s/Version: (.*)/Version: $RPM_VERSION/" -i pdns.spec -ssed -r "s/AC_INIT\\(\\[pdns\\],\\[(.*)\\]\\)/AC_INIT\([pdns],[$VERSION\])/" -i configure.ac ssed -r "1 s/^pdns \\(([^)]*)-([0-9.])\\)/pdns \\($DEB_VERSION-\\2\\)/" -i debian-pdns/changelog + +cat >VERSION </dev/null || echo "exported")])) AC_CONFIG_SRCDIR([pdns/receiver.cc]) AM_INIT_AUTOMAKE([tar-ustar]) AC_CANONICAL_HOST @@ -20,6 +20,13 @@ AC_PROG_MAKE_SET AC_PROG_LIBTOOL AC_LANG_CPLUSPLUS +AC_DEFINE([DIST_HOST], m4_esyscmd_s([test -f ./VERSION && (. ./VERSION; echo \"$DIST_HOST\") || (echo \"$(id -u -n)@$(hostname -f)\")]), [Where sources were built.]) + +build_date=$(LC_TIME=C date '+%Y%m%d%H%M%S') +AC_DEFINE_UNQUOTED([BUILD_DATE], ["$build_date"], [When binaries were built.]) +build_host=$(id -u -n)@$(hostname -f) +AC_DEFINE_UNQUOTED([BUILD_HOST], ["$build_host"], [Where binaries were built.]) + BOOST_REQUIRE([1.34]) BOOST_FOREACH #BOOST_FILESYSTEM([mt]) diff --git a/pdns/Makefile-recursor b/pdns/Makefile-recursor index 6d87cdd40b..251694e129 100644 --- a/pdns/Makefile-recursor +++ b/pdns/Makefile-recursor @@ -12,6 +12,11 @@ CC?=gcc # Lua 5.1 settings +BUILD_DATE=$(shell LC_TIME=C date '+%Y%m%d%H%M%S') +BUILD_HOST=$(shell id -u -n)@$(shell hostname -f) +CFLAGS:=$(CFLAGS) -DBUILD_HOST=\"$(BUILD_HOST)\" -DBUILD_DATE=\"$(BUILD_DATE)\" +CXXFLAGS:=$(CXXFLAGS) -DBUILD_HOST=\"$(BUILD_HOST)\" -DBUILD_DATE=\"$(BUILD_DATE)\" + # static dependencies PDNS_RECURSOR_OBJECTS=syncres.o misc.o unix_utility.o qtype.o logger.o \ diff --git a/pdns/config-recursor.h b/pdns/config-recursor.h index b895f743f4..491b46c653 100644 --- a/pdns/config-recursor.h +++ b/pdns/config-recursor.h @@ -1,4 +1,3 @@ #define SYSCONFDIR "/etc/powerdns/" #define LOCALSTATEDIR "/var/run/" -#define VERSION "3.5.1" #define RECURSOR diff --git a/pdns/dist-recursor b/pdns/dist-recursor index 5b7c6b0011..4d8fbb1e3d 100755 --- a/pdns/dist-recursor +++ b/pdns/dist-recursor @@ -4,7 +4,20 @@ set -e ragel dnslabeltext.rl -o dnslabeltext.cc -VERSION=3.5.1 +## The following lines will be patched by set-version-recursor. +VERSION="" +DIST_HOST="" +## End patch area. + +if [ -z "$VERSION" ]; then + VERSION=$(git rev-parse HEAD 2>/dev/null) + if [ -z "$VERSION" ]; then + VERSION="exported" + else + VERSION="git-"$VERSION + fi + DIST_HOST="$(id -u -n)@$(hostname -f)" +fi INCLUDES="iputils.hh arguments.hh base64.hh zoneparser-tng.hh \ rcpgenerator.hh lock.hh dnswriter.hh dnsrecords.hh dnsparser.hh utility.hh \ @@ -37,6 +50,10 @@ cp Makefile-recursor.win32 $DIRNAME/Makefile.win32 cp README-recursor $DIRNAME/README cp ../COPYING $DIRNAME/ cp config-recursor.h $DIRNAME/config.h +cat >>$DIRNAME/config.h < #include "utility.hh" #include +#include "logger.hh" bool g_singleThreaded; @@ -783,3 +784,27 @@ Regex::Regex(const string &expr) if(regcomp(&d_preg, expr.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED)) throw AhuException("Regular expression did not compile"); } + +string compilerVersion() +{ +#if defined(__clang__) + // clang defines __GNUC__ as well, so put it first. + return string("clang "__clang__version); +#elif defined(__GNUC__) + return string("gcc "__VERSION__); +#elif defined(_MSC_VER) + return string("MSVC "<<_MSC_VER); +#endif // add other compilers here + return string("Unknown compiler"); +} + +void showProductVersion(string product) +{ + L<setRcode(RCode::ServFail); return 1; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 7d159675aa..32db7c48de 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1652,6 +1652,11 @@ void parseACLs() l_initialized = true; } +static void showServiceVersion() +{ + showProductVersion("Recursor"); +} + int serviceMain(int argc, char*argv[]) { L.setName("pdns_recursor"); @@ -1666,20 +1671,7 @@ int serviceMain(int argc, char*argv[]) L< @@ -421,11 +424,7 @@ int main(int argc, char **argv) ::arg().laxParse(argc,argv); // do a lax parse if(::arg().mustDo("version")) { - cerr<<"Version: "VERSION", compiled on "<<__DATE__", "__TIME__; -#ifdef __GNUC__ - cerr<<" with gcc version "<<__VERSION__; -#endif - cout<"<PowerDNS Authoritative Server "VERSION". © 2013 PowerDNS.COM BV."<PowerDNS Authoritative Server "VERSION" ("DIST_HOST" built "BUILD_DATE" by "BUILD_HOST"). © 2013 PowerDNS.COM BV."<"<