From 5242cc519ae4d39efd8ea63e7e2a4f3b6ed6f0d1 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 22 Apr 2015 17:21:39 +0200 Subject: [PATCH] dnsdist: build RPMs * Add initscript + systemd unitfile * Add defaults file * Add script to build the RPM --- build-scripts/build-dnsdist-rpm | 121 ++++++++++++++++++ pdns/dnsdistdist/Makefile.am | 5 +- pdns/dnsdistdist/contrib/dnsdist.default | 1 + pdns/dnsdistdist/contrib/dnsdist.init.centos6 | 77 +++++++++++ pdns/dnsdistdist/contrib/dnsdist.service | 10 ++ 5 files changed, 212 insertions(+), 2 deletions(-) create mode 100755 build-scripts/build-dnsdist-rpm create mode 100644 pdns/dnsdistdist/contrib/dnsdist.default create mode 100644 pdns/dnsdistdist/contrib/dnsdist.init.centos6 create mode 100644 pdns/dnsdistdist/contrib/dnsdist.service diff --git a/build-scripts/build-dnsdist-rpm b/build-scripts/build-dnsdist-rpm new file mode 100755 index 0000000000..ff38342530 --- /dev/null +++ b/build-scripts/build-dnsdist-rpm @@ -0,0 +1,121 @@ +#!/bin/sh + +if [ "$0" != "./build-scripts/build-dnsdist-rpm" ]; then + echo "Please run me from the root checkout dir" + exit 1 +fi + +if [ -z "$VERSION" ]; then + echo 'Please set $VERSION' >&2 + exit 1 +fi + +set -e +set -x + +# Prepare the build environment +rpmdev-setuptree + +# This is somethat ugly... +if [ -f dnsdist-${VERSION}.tar.bz2 ]; then + mv dnsdist-${VERSION}.tar.bz2 $HOME/rpmbuild/SOURCES +else + echo "dnsdist-${VERSION}.tar.bz2 not found" >&2 + exit 1 +fi + +DIST='' + +# libsodium is not available on all RPM platforms (like CentOS 7) +SODIUM_BUILDREQUIRES='' +SODIUM_CONFIGURE='' + +# Some RPM platforms use systemd, others sysv, we default to systemd here +INIT_BUILDREQUIRES='BuildRequires: systemd' +INIT_INSTALL='install -d -m 755 %{buildroot}/%{_sysconfdir}/systemd/system/ && install -m 664 contrib/dnsdist.service %{buildroot}/%{_sysconfdir}/systemd/system/dnsdist.service' +INIT_FILES='%{_sysconfdir}/systemd/system/dnsdist.service' + +# These two are the same for sysv and systemd +DEFAULTS_INSTALL='install -d -m 755 %{buildroot}/%{_sysconfdir}/sysconfig && install -m 644 contrib/dnsdist.default %{buildroot}/%{_sysconfdir}/sysconfig/dnsdist' +DEFAULTS_FILES='%{_sysconfdir}/sysconfig/dnsdist' + +# On some older distro's *cough* centos 6 *cough* autosetup fails +SETUP='%autosetup -n %{name}-%{version}' + +# Some setups need rpmbuild in a 'special' env +RPMBUILD_COMMAND='rpmbuild -bb dnsdist.spec' + +if [ -f /etc/redhat-release ]; then + OS="$(cat /etc/redhat-release)" + case "$OS" in + Fedora\ *\ 21*) + SODIUM_BUILDREQUIRES='BuildRequires: libsodium-devel' + SODIUM_CONFIGURE='--enable-libsodium' + DIST='.fc21' + ;; + CentOS\ *\ 6*) + INIT_BUILDREQUIRES='' + INIT_INSTALL='install -d -m 755 %{buildroot}/%{_initrddir} && install -m 755 contrib/dnsdist.init.centos6 %{buildroot}/%{_initrddir}/dnsdist' + INIT_FILES='%{_initrddir}/dnsdist' + SETUP='%setup -n %{name}-%{version}' + RPMBUILD_COMMAND="scl enable devtoolset-2 -- ${RPMBUILD_COMMAND}" + DIST='.el6' + ;; + CentOS\ Linux\ *\ 7*) + DIST='.el7' + ;; + *) + echo "No support for $OS (yet?)" + exit 1 + ;; + esac +fi + +# Generate the specfile +cat > dnsdist.spec << EOF +Name: dnsdist +Version: ${VERSION} +Release: 1${DIST} +Summary: Powerful and scriptable DNS loadbalancer +License: GPLv2 +Vendor: PowerDNS.COM BV +Group: System/DNS +Source: dnsdist-${VERSION}.tar.bz2 +BuildRequires: readline-devel +BuildRequires: boost-devel +BuildRequires: lua-devel +${SODIUM_BUILDREQUIRES} +${INIT_BUILDREQUIRES} + +%description +dnsdist is a high-performance DNS loadbalancer that is scriptable in LUA. + +%prep +${SETUP} + +%build +%configure \ + --sysconfdir=/etc/dnsdist \ + ${SODIUM_CONFIGURE} + +make + +%install +%make_install +install -d %{buildroot}/%{_sysconfdir}/dnsdist +${INIT_INSTALL} +${DEFAULTS_INSTALL} + +%files +%{_bindir}/* +%{_mandir}/man1/* +%doc README.md +%dir %{_sysconfdir}/dnsdist +${INIT_FILES} +${DEFAULTS_FILES} + +EOF + +${RPMBUILD_COMMAND} + +mv $HOME/rpmbuild/RPMS/x86_64/dnsdist-${VERSION}-1${DIST}.x86_64.rpm . diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index d6341f3faa..03c1c6ade6 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -16,8 +16,9 @@ EXTRA_DIST=dnslabeltext.rl \ dnsdistconf.lua \ README.md \ html \ - dnsdist.1\ - .version + dnsdist.1 \ + .version \ + contrib bin_PROGRAMS = dnsdist dnsdist_SOURCES = \ diff --git a/pdns/dnsdistdist/contrib/dnsdist.default b/pdns/dnsdistdist/contrib/dnsdist.default new file mode 100644 index 0000000000..4e0e04529f --- /dev/null +++ b/pdns/dnsdistdist/contrib/dnsdist.default @@ -0,0 +1 @@ +DNSDIST_OPTIONS='-l 127.0.0.1' diff --git a/pdns/dnsdistdist/contrib/dnsdist.init.centos6 b/pdns/dnsdistdist/contrib/dnsdist.init.centos6 new file mode 100644 index 0000000000..613481c88c --- /dev/null +++ b/pdns/dnsdistdist/contrib/dnsdist.init.centos6 @@ -0,0 +1,77 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: dnsdist +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: dnsdist +### END INIT INFO +# chkconfig: 2345 80 75 +# description: dnsdist is a powerful, scriptable DNS loadbalancer +# processname: dnsdist + +# Source function library. +. /etc/init.d/functions + +PROG=dnsdist +DNSDIST=/usr/bin/${PROG} +PIDFILE=/var/run/${PROG}.pid +DNSDIST_OPTIONS="-l 127.0.0.1:53" + +if [ -f /etc/default/${PROG} ]; then + . /etc/default/${PROG} +fi + +RETVAL=0 + +do_start() { + echo -n "Starting ${PROG}..." + daemon --pidfile=${PIDFILE} $DNSDIST -d -p ${PIDFILE} ${DNSDIST_OPTIONS} + ret=$? + echo + return $ret +} + +do_stop() { + echo -n "Stopping ${PROG}..." + killproc -p ${PIDFILE} -b $DNSDIST $PROG + ret=$? + echo + return $ret +} + +do_status() { + status -p ${PIDFILE} -b ${DNSDIST} ${PROG} + return $? +} + +case "$1" in + start) + do_start + RETVAL=$?;; + stop) + do_stop + RETVAL=$?;; + restart) + do_status >/dev/null 2>&1 + ret=$? + + if [ $? -eq 0 ]; then + do_stop + ret=$? + fi + + do_start + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit $RETVAL diff --git a/pdns/dnsdistdist/contrib/dnsdist.service b/pdns/dnsdistdist/contrib/dnsdist.service new file mode 100644 index 0000000000..d2b34b6c90 --- /dev/null +++ b/pdns/dnsdistdist/contrib/dnsdist.service @@ -0,0 +1,10 @@ +[Unit] +Description=dnsdist +After=syslog.target + +[Service] +EnvironmentFile=-/etc/sysconfig/dnsdist +ExecStart=/usr/bin/dnsdist --supervised ${DNSDIST_OPTIONS} + +[Install] +WantedBy=multi-user.target -- 2.47.2