[Pkg-openldap-devel] [openldap] 03/39: r1656 at pulsar: torsten | 2005-04-02 13:48:03 +0200 * debian/slapd.scripts-common (load_databases): Reimplement automatic fixing of LDIF data via the fix_ldif script. Only tried if an initial slapadd using the original LDIF data fails. With this change upgrading from woody for some simple cases does work again. --

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:35:11 UTC 2013


This is an automated email from the git hooks/post-receive script.

tjaalton-guest pushed a commit to annotated tag 2.2.23-2
in repository openldap.

commit 1131b9233c858730c483c24f9fb100d503b5276e
Author: Torsten Landschoff <torsten at debian.org>
Date:   Sat Apr 2 11:47:37 2005 +0000

     r1656 at pulsar:  torsten | 2005-04-02 13:48:03 +0200
      * debian/slapd.scripts-common (load_databases): Reimplement automatic
        fixing of LDIF data via the fix_ldif script. Only tried if an
        initial slapadd using the original LDIF data fails. With this change
        upgrading from woody for some simple cases does work again.
     --
---
 debian/changelog            |    6 +++++-
 debian/slapd.scripts-common |   41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 07e9d86..b1ec3a9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,12 @@ openldap2.2 (2.2.23-2) unstable; urgency=low
     slapi sockets etc. Problem: The database location is specified relative
     to localstatedir/openldap-data. Another thing to fix...
     (closes: #298271).
+  * debian/slapd.scripts-common (load_databases): Reimplement automatic 
+    fixing of LDIF data via the fix_ldif script. Only tried if an 
+    initial slapadd using the original LDIF data fails. With this change
+    upgrading from woody for some simple cases does work again.
 
- --
+ -- 
 
 openldap2.2 (2.2.23-1) unstable; urgency=low
 
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index 2bb2655..cc4ee30 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -90,6 +90,34 @@ database_dumping_destdir() {						# {{{
 # }}}
 # ----- Dumping and loading the data ------------------------------------ {{{
 
+automatic_ldif_fixing_wanted_for() {					# {{{ 
+# Check if the user wants us to automatically fix the given LDIF file.
+# Usage: if automatic_ldif_fixing_wanted_for "$file"; then ...
+# XXX: Use debconf to configure this
+
+	local file size maxsize
+	file="$1"
+	size=`wc -c < "$file"`
+	maxsize=$((1024 * 1024 * 20))
+
+	if [ "$size" -lt "$maxsize" ]; then 
+		return 0
+	else
+		return 1
+	fi
+}
+
+# }}}
+corrective_ldif_filter() {						# {{{
+# Try to fix any errors found in an LDIF stream.
+# Usage: source | corrective_ldif_filter | target
+# XXX: Store the stderr output of the script somewhere.
+
+	/usr/share/slapd/fix_ldif -f 2>/dev/null
+}
+
+# }}}
+
 dump_databases() {							# {{{
 # If the user wants us to dump the databases they are dumped to the 
 # configured directory.
@@ -134,7 +162,18 @@ load_databases() {							# {{{
 
 		file="$dir/$suffix.ldif"
 		echo -n "  - directory $suffix... " >&2
-		slapadd -b "$suffix" -l "$file" || failed=1
+		slapadd -b "$suffix" -l "$file" 2>/dev/null || failed=1
+		# XXX: capture error output
+		if [ "$failed" ] && \
+			  automatic_ldif_fixing_wanted_for "$file"; then
+			rm -f "$dbdir"/*
+			failed=
+			echo -n "fixing" >&2
+			corrective_ldif_filter < "$file" | \
+				slapadd -b "$suffix" 2>/dev/null || failed=1
+			# XXX: capture error output
+			echo -n ", " >&2
+		fi
 		if [ "$failed" ]; then
 			rm -f "$dbdir"/*
 			echo failed. >&2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git



More information about the Pkg-openldap-devel mailing list