[kea] MySQL, PostgreSQL, Google Test, systemd.patch

Jiří Popelka jpopelka at fedoraproject.org
Wed Aug 20 10:12:03 UTC 2014


commit 5fc4ba04f113b24dfccbe186072bc8d405c941bf
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Wed Aug 20 12:10:46 2014 +0200

    MySQL, PostgreSQL, Google Test, systemd.patch

 kea-dhcp-ddns.service |   12 ---
 kea-dhcp4.service     |   12 ---
 kea-dhcp6.service     |   12 ---
 kea-systemd.patch     |  193 +++++++++++++++++++++++++++++++++++++++++++++++++
 kea.spec              |   43 +++++++-----
 5 files changed, 218 insertions(+), 54 deletions(-)
---
diff --git a/kea-systemd.patch b/kea-systemd.patch
new file mode 100644
index 0000000..4514099
--- /dev/null
+++ b/kea-systemd.patch
@@ -0,0 +1,193 @@
+From 09ff7038ea23565e923179682ba96f5aa2d0f0c7 Mon Sep 17 00:00:00 2001
+From: Jiri Popelka <jpopelka at redhat.com>
+Date: Tue, 19 Aug 2014 17:16:50 +0200
+Subject: [PATCH] Systemd service unit files.
+
+As of August 2014, all Linux distributions include systemd and most of
+them enable it by default.
+https://en.wikipedia.org/wiki/Systemd#Adoption
+
+There are many systemd HOWTOs, like:
+https://wiki.archlinux.org/index.php/systemd
+https://coreos.com/docs/launching-containers/launching/getting-started-with-systemd/
+https://fedoraproject.org/wiki/Packaging:Systemd
+
+For description of options in the service files, see:
+http://www.freedesktop.org/software/systemd/man/systemd.unit.html
+http://www.freedesktop.org/software/systemd/man/systemd.service.html
+
+Installation of these files is turned on with --enable-systemd
+configure option. They are installed into
+PREFIX/lib/systemd/system/ by default. One can also
+use --with-systemd-unitdir to specify another directory.
+
+For now the template files reside in src/bin/keactrl/
+as I haven't figured out a better place.
+---
+ configure.ac                             | 12 ++++++++++
+ src/bin/keactrl/Makefile.am              | 39 ++++++++++++++++++++++++++++++--
+ src/bin/keactrl/kea-dhcp-ddns.service.in | 12 ++++++++++
+ src/bin/keactrl/kea-dhcp4.service.in     | 12 ++++++++++
+ src/bin/keactrl/kea-dhcp6.service.in     | 12 ++++++++++
+ tools/path_replacer.sh.in                |  4 +++-
+ 6 files changed, 88 insertions(+), 3 deletions(-)
+ create mode 100644 src/bin/keactrl/kea-dhcp-ddns.service.in
+ create mode 100644 src/bin/keactrl/kea-dhcp4.service.in
+ create mode 100644 src/bin/keactrl/kea-dhcp6.service.in
+
+diff --git a/configure.ac b/configure.ac
+index f0dbc4f..3dc4383 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1344,6 +1344,18 @@ if test "x$VALGRIND" != "xno"; then
+    found_valgrind="found"
+ fi
+ 
++AC_ARG_ENABLE([systemd],
++       AS_HELP_STRING([--enable-systemd], [enable systemd support]),
++       [use_systemd=$enableval], [use_systemd=no])
++AM_CONDITIONAL(USE_SYSTEMD, test "x$use_systemd" != "xno")
++AC_SUBST(USE_SYSTEMD)
++
++AC_ARG_WITH([systemd-unitdir],
++       AS_HELP_STRING([--with-systemd-unitdir=PATH],
++                      [specify exact directory for systemd service files, defaults to PREFIX/lib/systemd/system/]),
++       [SYSTEMD_UNITDIR=$withval], [SYSTEMD_UNITDIR="${prefix}/lib/systemd/system"])
++AC_SUBST(SYSTEMD_UNITDIR)
++
+ # Check for optreset in unistd.h. On BSD systems the optreset is
+ # used to reset the state of getopt() function. Resetting its state
+ # is required if command line arguments are parsed multiple times
+diff --git a/src/bin/keactrl/Makefile.am b/src/bin/keactrl/Makefile.am
+index a2d2a82..05b1c9e 100644
+--- a/src/bin/keactrl/Makefile.am
++++ b/src/bin/keactrl/Makefile.am
+@@ -31,9 +31,36 @@ endif
+ kea.conf: kea.conf.in
+ 	$(top_srcdir)/tools/path_replacer.sh $< $@
+ 
++INSTALL_TARGETS = install-empty
++
+ if INSTALL_CONFIGURATIONS
+ 
+-install-data-local:
++INSTALL_TARGETS += install-config-files
++
++endif
++
++if USE_SYSTEMD
++
++EXTRA_DIST += kea-dhcp4.service.in kea-dhcp6.service.in kea-dhcp-ddns.service.in
++DISTCLEANFILES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
++BUILT_SOURCES += kea-dhcp4.service kea-dhcp6.service kea-dhcp-ddns.service
++INSTALL_TARGETS += install-systemd-files
++
++endif
++
++kea-dhcp4.service: kea-dhcp4.service.in
++	$(top_srcdir)/tools/path_replacer.sh $< $@
++
++kea-dhcp6.service: kea-dhcp6.service.in
++	$(top_srcdir)/tools/path_replacer.sh $< $@
++
++kea-dhcp-ddns.service: kea-dhcp-ddns.service.in
++	$(top_srcdir)/tools/path_replacer.sh $< $@
++
++install-empty:
++	:
++
++install-config-files:
+ 	$(mkinstalldirs) $(DESTDIR)/@sysconfdir@/@PACKAGE@
+ 	for f in $(CONFIGFILES) ; do	\
+ 	  if test ! -f $(DESTDIR)$(sysconfdir)/@PACKAGE@/$$f; then	\
+@@ -41,4 +68,12 @@ install-data-local:
+ 	  fi ;	\
+ 	done
+ 
+-endif
++install-systemd-files:
++	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNITDIR)
++	$(INSTALL_DATA) kea-dhcp4.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp4.service
++	$(INSTALL_DATA) kea-dhcp6.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp6.service
++	$(INSTALL_DATA) kea-dhcp-ddns.service $(DESTDIR)$(SYSTEMD_UNITDIR)/kea-dhcp-ddns.service
++
++install-data-local: $(INSTALL_TARGETS)
++
++uninstall-local: $(UNINSTALL_TARGETS)
+diff --git a/src/bin/keactrl/kea-dhcp-ddns.service.in b/src/bin/keactrl/kea-dhcp-ddns.service.in
+new file mode 100644
+index 0000000..d1e0526
+--- /dev/null
++++ b/src/bin/keactrl/kea-dhcp-ddns.service.in
+@@ -0,0 +1,12 @@
++[Unit]
++Description=Kea DHCP-DDNS Server
++Documentation=man:kea-dhcp-ddns(8)
++Wants=network-online.target
++After=network-online.target
++After=time-sync.target
++
++[Service]
++ExecStart=@sbindir@/kea-dhcp-ddns -c @sysconfdir@/kea/kea.conf
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/src/bin/keactrl/kea-dhcp4.service.in b/src/bin/keactrl/kea-dhcp4.service.in
+new file mode 100644
+index 0000000..80977d6
+--- /dev/null
++++ b/src/bin/keactrl/kea-dhcp4.service.in
+@@ -0,0 +1,12 @@
++[Unit]
++Description=Kea DHCPv4 Server
++Documentation=man:kea-dhcp4(8)
++Wants=network-online.target
++After=network-online.target
++After=time-sync.target
++
++[Service]
++ExecStart=@sbindir@/kea-dhcp4 -c @sysconfdir@/kea/kea.conf
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/src/bin/keactrl/kea-dhcp6.service.in b/src/bin/keactrl/kea-dhcp6.service.in
+new file mode 100644
+index 0000000..c24f584
+--- /dev/null
++++ b/src/bin/keactrl/kea-dhcp6.service.in
+@@ -0,0 +1,12 @@
++[Unit]
++Description=Kea DHCPv6 Server
++Documentation=man:kea-dhcp6(8)
++Wants=network-online.target
++After=network-online.target
++After=time-sync.target
++
++[Service]
++ExecStart=@sbindir@/kea-dhcp6 -c @sysconfdir@/kea/kea.conf
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/tools/path_replacer.sh.in b/tools/path_replacer.sh.in
+index 43d7bff..82625ca 100644
+--- a/tools/path_replacer.sh.in
++++ b/tools/path_replacer.sh.in
+@@ -27,12 +27,14 @@
+ prefix=@prefix@
+ sysconfdir=@sysconfdir@
+ localstatedir=@localstatedir@
++sbindir=@sbindir@
+ 
+ echo "Replacing \@prefix\@ with ${prefix}"
+ echo "Replacing \@sysconfdir\@ with ${sysconfdir}"
+ echo "Replacing \@localstatedir\@ with ${localstatedir}"
++echo "Replacing \@sbindir\@ with ${sbindir}"
+ 
+ echo "Input file: $1"
+ echo "Output file: $2"
+ 
+-sed -e "s+\@localstatedir\@+${localstatedir}+g; s+\@prefix at +${prefix}+g; s+\@sysconfdir at +${sysconfdir}+g" $1 > $2
++sed -e "s+\@localstatedir\@+${localstatedir}+g; s+\@prefix\@+${prefix}+g; s+\@sysconfdir\@+${sysconfdir}+g; s+\@sbindir\@+${sbindir}+g" $1 > $2
+-- 
+1.9.3
+
diff --git a/kea.spec b/kea.spec
index 38ffba0..e1bdc2a 100644
--- a/kea.spec
+++ b/kea.spec
@@ -10,13 +10,10 @@
 Summary:  DHCPv4, DHCPv6 and DDNS server from ISC
 Name:     kea
 Version:  0.9
-Release:  0.3.%{prever}%{?dist}
+Release:  0.4.%{prever}%{?dist}
 License:  ISC and Boost
 URL:      http://kea.isc.org
 Source0:  http://ftp.isc.org/isc/kea/%{VERSION}/kea-%{VERSION}.tar.gz
-Source1:  kea-dhcp4.service
-Source2:  kea-dhcp6.service
-Source3:  kea-dhcp-ddns.service
 
 # http://kea.isc.org/ticket/3523
 Patch0:   kea-data-dir.patch
@@ -24,16 +21,30 @@ Patch0:   kea-data-dir.patch
 Patch1:   kea-LT_INIT.patch
 # http://kea.isc.org/ticket/3526
 Patch2:   kea-narrowing.patch
+# http://kea.isc.org/ticket/3529
+Patch3:   kea-systemd.patch
 
+# autoreconf
 BuildRequires: autoconf automake libtool
 BuildRequires: boost-devel
+# %%configure --with-openssl
 BuildRequires: openssl-devel
+# %%configure --with-dhcp-mysql
+BuildRequires: mariadb-devel
+# %%configure --with-dhcp-pgsql
+BuildRequires: postgresql-devel
 BuildRequires: log4cplus-devel
 BuildRequires: valgrind-devel
 BuildRequires: systemd
 # src/lib/testutils/dhcp_test_lib.sh
 BuildRequires: procps-ng
 
+
+# %%configure --enable-gtest
+BuildRequires: gtest-devel
+# in case you ever wanted to use %%configure --enable-generate-docs
+#BuildRequires: elinks asciidoc plantuml
+
 Requires: kea-libs%{?_isa} = %{version}-%{release}
 Requires(post): systemd
 Requires(preun): systemd
@@ -67,6 +78,7 @@ Header files and API documentation.
 %patch0 -p1 -b .data-dir
 %patch1 -p1 -b .LT
 %patch2 -p1 -b .narrowing
+%patch3 -p1 -b .systemd
 
 %build
 autoreconf --verbose --force --install
@@ -74,8 +86,12 @@ autoreconf --verbose --force --install
 %configure \
     --disable-silent-rules \
     --disable-static \
+    --enable-systemd \
     --with-openssl \
+    --with-dhcp-mysql \
+    --with-dhcp-pgsql \
     --disable-rpath \
+    --enable-gtest \
     --enable-debug
 
 make %{?_smp_mflags}
@@ -96,17 +112,6 @@ mkdir -p %{buildroot}%{_sharedstatedir}/kea/
 touch %{buildroot}%{_sharedstatedir}/kea/kea-leases4.csv
 touch %{buildroot}%{_sharedstatedir}/kea/kea-leases6.csv
 
-# Copy sample config files
-install -p -m 644 doc/examples/kea4/single-subnet.json %{buildroot}%{_sysconfdir}/kea/dhcp4.json
-install -p -m 644 doc/examples/kea6/simple.json %{buildroot}%{_sysconfdir}/kea/dhcp6.json
-install -p -m 644 doc/examples/ddns/template.json %{buildroot}%{_sysconfdir}/kea/dhcp-ddns.json
-
-# systemd unit files
-mkdir -p %{buildroot}%{_unitdir}
-install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}
-install -p -m 644 %{SOURCE2} %{buildroot}%{_unitdir}
-install -p -m 644 %{SOURCE3} %{buildroot}%{_unitdir}
-
 install -p -m 644 ext/LICENSE_1_0.txt %{buildroot}%{_defaultdocdir}/kea/
 
 %post
@@ -138,9 +143,6 @@ install -p -m 644 ext/LICENSE_1_0.txt %{buildroot}%{_defaultdocdir}/kea/
 %dir %{_sysconfdir}/kea/
 %config(noreplace) %{_sysconfdir}/kea/kea.conf
 %config(noreplace) %{_sysconfdir}/kea/keactrl.conf
-%config(noreplace) %{_sysconfdir}/kea/dhcp4.json
-%config(noreplace) %{_sysconfdir}/kea/dhcp6.json
-%config(noreplace) %{_sysconfdir}/kea/dhcp-ddns.json
 %dir %{_datarootdir}/kea/
 %{_datarootdir}/kea/dhcp-ddns.spec
 %{_datarootdir}/kea/dhcp4.spec
@@ -202,6 +204,11 @@ install -p -m 644 ext/LICENSE_1_0.txt %{buildroot}%{_defaultdocdir}/kea/
 %{_libdir}/pkgconfig/dns++.pc
 
 %changelog
+* Wed Aug 20 2014 Jiri Popelka <jpopelka at redhat.com> - 0.9-0.4.beta1
+- install systemd service units with a proper patch that we can send upstream
+- build with MySQL & PostgreSQL & Google Test
+- no need to copy sample configuration, /etc/kea/kea.conf already contains one
+
 * Tue Aug 19 2014 Jiri Popelka <jpopelka at redhat.com> - 0.9-0.3.beta1
 - comment patches
 - use --preserve-timestamps with install


More information about the scm-commits mailing list