]> granicus.if.org Git - pdns/commitdiff
dnsdist: build RPMs
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 22 Apr 2015 15:21:39 +0000 (17:21 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 22 Apr 2015 15:21:39 +0000 (17:21 +0200)
 * Add initscript + systemd unitfile
 * Add defaults file
 * Add script to build the RPM

build-scripts/build-dnsdist-rpm [new file with mode: 0755]
pdns/dnsdistdist/Makefile.am
pdns/dnsdistdist/contrib/dnsdist.default [new file with mode: 0644]
pdns/dnsdistdist/contrib/dnsdist.init.centos6 [new file with mode: 0644]
pdns/dnsdistdist/contrib/dnsdist.service [new file with mode: 0644]

diff --git a/build-scripts/build-dnsdist-rpm b/build-scripts/build-dnsdist-rpm
new file mode 100755 (executable)
index 0000000..ff38342
--- /dev/null
@@ -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 .
index d6341f3faa6f197fb02a8e26b7dd0158034992e6..03c1c6ade6d27f3aadd646be14cfdeb1b9ce220f 100644 (file)
@@ -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 (file)
index 0000000..4e0e045
--- /dev/null
@@ -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 (file)
index 0000000..613481c
--- /dev/null
@@ -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 (file)
index 0000000..d2b34b6
--- /dev/null
@@ -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