URL: https://github.com/freeipa/bind-dyndb-ldap/pull/7
Author: tomaskrizek
 Title: #7: Added named.conf API transformation script to spec
Action: synchronized

To pull the PR as Git branch:
git remote add ghbind-dyndb-ldap https://github.com/freeipa/bind-dyndb-ldap
git fetch ghbind-dyndb-ldap pull/7/head:pr7
git checkout pr7
From 78b42faa4818f21082efab0b6803afb82a089f2a Mon Sep 17 00:00:00 2001
From: Tomas Krizek <tkri...@redhat.com>
Date: Mon, 9 Jan 2017 10:29:31 +0100
Subject: [PATCH] Added named.conf API transformation script to spec

A script that converts old-style configuration API of named.conf
to the new-style API after rpm isntallation was added to contrib
specfile.
Required version of BIND was also bumped to 9.11.
---
 contrib/bind-dyndb-ldap.spec | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/contrib/bind-dyndb-ldap.spec b/contrib/bind-dyndb-ldap.spec
index 6f5b1f3..e08f9f9 100644
--- a/contrib/bind-dyndb-ldap.spec
+++ b/contrib/bind-dyndb-ldap.spec
@@ -11,13 +11,13 @@ URL:            https://fedorahosted.org/bind-dyndb-ldap
 Source0:        https://fedorahosted.org/released/%{name}/%{name}-%{VERSION}.tar.bz2
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
-BuildRequires:  bind-devel >= 32:9.9.0, bind-lite-devel >= 32:9.9.0
+BuildRequires:  bind-devel >= 32:9.11.0-6.P2, bind-lite-devel >= 32:9.11.0-6.P2
 BuildRequires:  krb5-devel
 BuildRequires:  openldap-devel
 BuildRequires:  libuuid-devel
 BuildRequires:  automake, autoconf, libtool
 
-Requires:       bind >= 32:9.9.0
+Requires:       bind >= 32:9.11.0-6.P2
 
 %description
 This package provides an LDAP back-end plug-in for BIND. It features
@@ -42,6 +42,39 @@ mkdir -m 770 -p %{buildroot}/%{_localstatedir}/named/dyndb-ldap
 rm %{buildroot}%{_libdir}/bind/ldap.la
 rm -r %{buildroot}%{_datadir}/doc/%{name}
 
+%post
+# Transform named.conf if it still has old-style API.
+PLATFORM=$(uname -m)
+
+if [ $PLATFORM == "x86_64" ] ; then
+    LIBPATH=/usr/lib64
+else
+    LIBPATH=/usr/lib
+fi
+
+while read -r PATTERN
+do
+    SEDSCRIPT+="$PATTERN"
+done <<EOF
+/^\s*dynamic-db/,/};/ {
+
+  s/\(\s*\)arg\s\+\(["']\)\([a-Z_]\+\s\)/\1\3\2/g;
+
+  s/^dynamic-db/dyndb/;
+
+  s@\(dyndb "[^"]\+"\)@\1 "$LIBPATH/bind/ldap.so"@;
+  s@\(dyndb '[^']\+'\)@\1 '$LIBPATH/bind/ldap.so'@;
+
+  /\s*library[^;]\+;/d;
+  /\s*cache_ttl[^;]\+;/d;
+  /\s*psearch[^;]\+;/d;
+  /\s*serial_autoincrement[^;]\+;/d;
+  /\s*zone_refresh[^;]\+;/d;
+}
+EOF
+
+sed -i.bak -e "$SEDSCRIPT" /etc/named.conf
+
 
 %clean
 rm -rf %{buildroot}
@@ -55,6 +88,10 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Thu Jan 26 2017 Tomas Krizek <tkri...@redhat.com>
+- Added named.conf API transofrmation script
+- Bumped the required BIND version to 9.11.0-6.P2
+
 * Tue Jan 28 2014 Petr Spacek <pspacek redhat com>
 - package /var/named/dyndb-ldap directory
 
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to