From: Christian Hofstaedtler Date: Thu, 9 May 2013 23:09:01 +0000 (+0200) Subject: Be explicit about versions (v2) X-Git-Tag: auth-3.3-rc1~79^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F789%2Fhead;p=thirdparty%2Fpdns.git Be explicit about versions (v2) Caveats: - Auth now bears additional cost for version.bind queries - make always relinks pdns_server/pdns_recursor - the full version string is a bit long --- 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..addb2ef42f 100755 --- a/build-scripts/set-version-auth +++ b/build-scripts/set-version-auth @@ -1,9 +1,12 @@ -#!/bin/bash +#!/bin/bash VERSION=$1 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 "s/AC_INIT\(\[pdns\],(.*)/AC_INIT([pdns], [$VERSION])/" -i configure.ac +ssed -r "s/^(.*)AC_SUBST\(\[DIST_HOST\],(.*)/AC_SUBST([DIST_HOST], [$DIST_HOST])/" -i configure.ac ssed -r "1 s/^pdns \\(([^)]*)-([0-9.])\\)/pdns \\($DEB_VERSION-\\2\\)/" -i debian-pdns/changelog diff --git a/build-scripts/set-version-recursor b/build-scripts/set-version-recursor index 358754016d..9593c9d7ac 100755 --- a/build-scripts/set-version-recursor +++ b/build-scripts/set-version-recursor @@ -4,5 +4,8 @@ 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=$VERSION/" -i pdns/dist-recursor +ssed -r "s/^DIST_HOST=(.*)/DIST_HOST=$DIST_HOST/" -i pdns/dist-recursor ssed -r "s/Version: (.*)/Version: $RPM_VERSION/" -i pdns/pdns-recursor.spec diff --git a/configure.ac b/configure.ac index b7b4ae49f2..ae989b5b75 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,10 @@ dnl intro -AC_INIT([pdns],[3.2]) +dnl The following lines may be patched by set-version-auth. +AC_INIT([pdns], [git]) +dnl AC_SUBST([DIST_HOST], [TO_BE_PATCHED]) +dnl End patch area. AC_CONFIG_SRCDIR([pdns/receiver.cc]) -AM_INIT_AUTOMAKE([tar-ustar]) +AM_INIT_AUTOMAKE([tar-ustar -Wno-portability]) AC_CANONICAL_HOST LT_INIT AC_CONFIG_MACRO_DIR([m4]) @@ -20,6 +23,8 @@ AC_PROG_MAKE_SET AC_PROG_LIBTOOL AC_LANG_CPLUSPLUS +AM_CONDITIONAL([RELEASE_BUILD], [test "$PACKAGE_VERSION" != "git"]) + BOOST_REQUIRE([1.34]) BOOST_FOREACH #BOOST_FILESYSTEM([mt]) diff --git a/pdns/.gitignore b/pdns/.gitignore index bf4b04ef0f..4146647514 100644 --- a/pdns/.gitignore +++ b/pdns/.gitignore @@ -30,3 +30,4 @@ /speedtest /toysdig /tsig-tests +version_generated.h diff --git a/pdns/Makefile-recursor b/pdns/Makefile-recursor index 6d87cdd40b..0eeb26790d 100644 --- a/pdns/Makefile-recursor +++ b/pdns/Makefile-recursor @@ -20,13 +20,26 @@ dnswriter.o dnsrecords.o rcpgenerator.o base64.o zoneparser-tng.o \ rec_channel.o rec_channel_rec.o selectmplexer.o sillyrecords.o \ dns_random.o aescrypt.o aeskey.o aes_modes.o aestab.o dnslabeltext.o \ lua-pdns.o lua-recursor.o randomhelper.o recpacketcache.o dns.o \ -reczones.o base32.o nsecrecords.o json.o json_ws.o +reczones.o base32.o nsecrecords.o json.o json_ws.o version.o REC_CONTROL_OBJECTS=rec_channel.o rec_control.o arguments.o misc.o \ unix_utility.o logger.o qtype.o # what we need -all: message pdns_recursor rec_control +all: message version_generated.h pdns_recursor rec_control + +# Version +build_date=$(shell LC_TIME=C date '+%Y%m%d%H%M%S') +build_host=$(shell id -u -n)@$(shell hostname -f) +.PHONY: version_generated.h +version_generated.h: + echo '#ifndef VERSION_GENERATED_H' > $@ + echo '#define VERSION_GENERATED_H' >> $@ + echo '#include "config.h"' >> $@ + echo '#define PDNS_VERSION VERSION' >> $@ + echo '#define BUILD_DATE "$(build_date)"' >> $@ + echo '#define BUILD_HOST "$(build_host)"' >> $@ + echo '#endif //!VERSION_GENERATED_H' >> $@ # OS specific instructions -include sysdeps/$(shell uname).inc @@ -88,7 +101,7 @@ clean: binclean binclean: -rm -f *.o pdns_recursor rec_control optional/*.o - + dep: $(CXX) $(CXXFLAGS) -MM -MG *.cc *.c *.hh > $@ diff --git a/pdns/Makefile.am b/pdns/Makefile.am index f82d2d8721..3c284ef5f8 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -27,7 +27,7 @@ else SUBDIRS= ext/polarssl-1.1.2 backends endif -BUILT_SOURCES=bind-dnssec.schema.sqlite3.sql.h +BUILT_SOURCES=bind-dnssec.schema.sqlite3.sql.h version_generated.h noinst_SCRIPTS = pdns sysconf_DATA = pdns.conf-dist @@ -67,7 +67,8 @@ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \ randomhelper.cc namespaces.hh nsecrecords.cc base32.cc dbdnsseckeeper.cc dnssecinfra.cc \ dnsseckeeper.hh dnssecinfra.hh base32.hh dns.cc dnssecsigner.cc polarrsakeyinfra.cc md5.cc \ md5.hh signingpipe.cc signingpipe.hh dnslabeltext.cc lua-pdns.cc lua-auth.cc lua-auth.hh serialtweaker.cc \ -ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh +ednssubnet.cc ednssubnet.hh cachecleaner.hh json.cc json.hh \ +version.hh version.cc # pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) -rdynamic @@ -95,7 +96,7 @@ endif if ORACLE pdns_server_LDADD += $(ORACLE_LIBS) endif - + pdnssec_SOURCES=pdnssec.cc dbdnsseckeeper.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnswriter.hh \ misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \ logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc dnssecinfra.cc dnssecinfra.hh \ @@ -259,7 +260,7 @@ rec_channel_rec.cc selectmplexer.cc epollmplexer.cc sillyrecords.cc htimer.cc ht aes/dns_random.cc aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c \ lua-pdns.cc lua-pdns.hh lua-recursor.cc lua-recursor.hh randomhelper.cc \ recpacketcache.cc recpacketcache.hh dns.cc nsecrecords.cc base32.cc cachecleaner.hh json_ws.cc json_ws.hh \ -json.cc json.hh +json.cc json.hh version.hh version.cc pdns_recursor_LDFLAGS= $(LUA_LIBS) pdns_recursor_LDADD= @@ -280,3 +281,26 @@ backends/bind/bindlexer.c: backends/bind/bindparser.cc: make -C backends/bind bindparser.cc + + +build_date=$(shell LC_TIME=C date '+%Y%m%d%H%M%S') +build_host=$(shell id -u -n)@$(shell hostname -f) +if RELEASE_BUILD +pdns_version=$(PACKAGE_VERSION) +dist_host=$(DIST_HOST) +else +git_version=$(shell git describe --always --dirty=+ 2>/dev/null) +# Do the test in shell, so we don't confuse automake with ifeq/ifneq. +pdns_version=$(shell test -z "$(git_version)" && echo UNKNOWN || echo "git-$(git_version)") +dist_host=$(build_host) +endif + +.PHONY: version_generated.h +version_generated.h: + echo '#ifndef VERSION_GENERATED_H' > $@ + echo '#define VERSION_GENERATED_H' >> $@ + echo '#define PDNS_VERSION "$(pdns_version)"' >> $@ + echo '#define DIST_HOST "$(dist_host)"' >> $@ + echo '#define BUILD_DATE "$(build_date)"' >> $@ + echo '#define BUILD_HOST "$(build_host)"' >> $@ + echo '#endif //!VERSION_GENERATED_H' >> $@ 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..8222263bde 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 describe --always --dirty=+ 2>/dev/null) + if [ -z "$VERSION" ]; then + VERSION="UNKNOWN" + 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 \ @@ -12,7 +25,7 @@ recursor_cache.hh rec_channel.hh qtype.hh misc.hh dns.hh syncres.hh \ sstuff.hh mtasker.hh mtasker.cc lwres.hh logger.hh ahuexception.hh \ mplexer.hh win32_mtasker.hh win32_utility.cc ntservice.hh singleton.hh \ recursorservice.hh dns_random.hh lua-pdns.hh lua-recursor.hh namespaces.hh \ -recpacketcache.hh base32.hh cachecleaner.hh json.hh" +recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh" CFILES="syncres.cc misc.cc unix_utility.cc qtype.cc \ logger.cc arguments.cc lwres.cc pdns_recursor.cc \ @@ -22,7 +35,7 @@ selectmplexer.cc epollmplexer.cc kqueuemplexer.cc portsmplexer.cc pdns_hw.cc \ win32_mtasker.cc win32_rec_channel.cc win32_logger.cc ntservice.cc \ recursorservice.cc sillyrecords.cc lua-pdns.cc lua-recursor.cc randomhelper.cc \ devpollmplexer.cc recpacketcache.cc dns.cc reczones.cc base32.cc nsecrecords.cc \ -dnslabeltext.cc json.cc json_ws.cc json_ws.hh" +dnslabeltext.cc json.cc json_ws.cc json_ws.hh version.cc" cd docs make pdns_recursor.1 rec_control.1 @@ -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; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index b5ed6a2ad0..9a28cf660f 100755 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -37,6 +37,7 @@ #include "resolver.hh" #include "communicator.hh" #include "dnsproxy.hh" +#include "version.hh" #if 0 #undef DLOG @@ -265,7 +266,7 @@ int PacketHandler::doVersionRequest(DNSPacket *p, DNSPacket *r, string &target) const static string mode=::arg()["version-string"]; if(mode.empty() || mode=="full") - rr.content="Served by POWERDNS "VERSION" $Id$"; + rr.content=fullVersionString(); else if(mode=="anonymous") { r->setRcode(RCode::ServFail); return 1; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 7d159675aa..89007c9388 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -65,6 +65,7 @@ #include "mplexer.hh" #include "config.h" #include "lua-recursor.hh" +#include "version.hh" #ifndef RECURSOR #include "statbag.hh" @@ -1666,20 +1667,7 @@ int serviceMain(int argc, char*argv[]) L< static void tbhandler(int num) @@ -396,7 +395,8 @@ static void tbhandler(int num) //! The main function of pdns, the pdns process int main(int argc, char **argv) -{ +{ + versionSetProduct("Authoritative Server"); reportAllTypes(); // init MOADNSParser s_programname="pdns"; @@ -421,11 +421,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< +#include + +std::string compilerVersion(); +void showProductVersion(); +std::string fullVersionString(); +void versionSetProduct(std::string product); + +#endif //!VERSION_HH diff --git a/pdns/ws.cc b/pdns/ws.cc index 3050ccedb9..1581839bc3 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -32,6 +32,7 @@ #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" +#include "version.hh" using namespace rapidjson; @@ -235,7 +236,7 @@ string StatWebServer::indexfunction(const string& method, const string& post, co printtable(ret,rvarmap["ring"],S.getRingTitle(rvarmap["ring"]),100); ret<<""<PowerDNS Authoritative Server "VERSION". © 2013 PowerDNS.COM BV."<"<© 2013 PowerDNS.COM BV."<"<