[Pkg-openldap-devel] [openldap] 08/39: r1668 at pulsar: torsten | 2005-04-03 23:28:14 +0200 * debian/slapd.scripts-common: Store the diagnostic output from slapadd and output it before aborting if the command failed. -- Torsten Landschoff <torsten at debian.org> Sun, 3 Apr 2005 23:22:41 +0200

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:35:12 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 ba2435112278f01d19f71def64cb897a98fa1290
Author: Torsten Landschoff <torsten at debian.org>
Date:   Sun Apr 3 21:22:59 2005 +0000

     r1668 at pulsar:  torsten | 2005-04-03 23:28:14 +0200
      * debian/slapd.scripts-common: Store the diagnostic output from
        slapadd and output it before aborting if the command failed.
     -- Torsten Landschoff <torsten at debian.org>  Sun,  3 Apr 2005 23:22:41 +0200
---
 debian/TODO                 |    2 --
 debian/changelog            |    4 +++-
 debian/slapd.scripts-common |   55 ++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/debian/TODO b/debian/TODO
index 2156edb..784ad9d 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -2,8 +2,6 @@ openldap2.2 (2.2.23-2) unstable; urgency=low
 
   * Updated maintainer scripts to keep DB_CONFIG for LDAP databases over 
     upgrades (closes: #265860).
-  * debian/slapd.scripts-common: Store the diagnostic output from
-    slapadd/slapcat and output it before aborting if the command failed.
   * debian/slapd.templates: Clean up the debconf templates of the slapd
     packages (closes: #302829).
     + Removed unused templates.
diff --git a/debian/changelog b/debian/changelog
index d74bb05..c73bcde 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,8 +13,10 @@ openldap2.2 (2.2.23-2) unstable; urgency=low
     libdb4.2 package should work but of course using the latest will give
     you the best results (closes: #300851).
   * debian/slapd.scripts-common (import_database): Removed, no longer used.
+  * debian/slapd.scripts-common: Store the diagnostic output from
+    slapadd and output it before aborting if the command failed.
 
- -- 
+ -- Torsten Landschoff <torsten at debian.org>  Sun,  3 Apr 2005 23:22:41 +0200
 
 openldap2.2 (2.2.23-1) unstable; urgency=low
 
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index 91aa3d0..80dd05a 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -162,8 +162,8 @@ load_databases() {							# {{{
 
 		file="$dir/$suffix.ldif"
 		echo -n "  - directory $suffix... " >&2
-		slapadd -b "$suffix" -l "$file" 2>/dev/null || failed=1
-		# XXX: capture error output
+		capture_diagnostics slapadd -b "$suffix" -l "$file" \
+			|| failed=1
 		if [ "$failed" ] && \
 			  automatic_ldif_fixing_wanted_for "$file"; then
 			rm -f "$dbdir"/*
@@ -171,12 +171,17 @@ load_databases() {							# {{{
 			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
+			echo >&2
+			cat <<-EOF
+	Loading the database from the LDIF dump failed with the following
+	error while running slapadd:
+EOF
+			release_diagnostics "    "
 			exit 1
 		fi
 		echo "done." >&2
@@ -1034,5 +1039,49 @@ fi
 
 # }}}
 
+# ----- Handling diagnostic output ------------------------------------ {{{
+#
+# Often you want to run a program while you are showing progress 
+# information to the user. If the program you are running outputs some 
+# diagnostics it will mess up your screen. 
+#
+# This is what the following functions are designed for. When running the
+# program, use capture_diagnostics to store what the program outputs to 
+# stderr and use release_diagnostics to write out the captured output.
+
+
+capture_diagnostics() {							# {{{
+# Run the command passed and capture the diagnostic output in a temporary
+# file. You can dump that file using release_diagnostics.
+
+	# Create the temporary file
+	local tmpfile
+	tmpfile=`mktemp`
+	exec 7<>"$tmpfile"
+	rm "$tmpfile"
+
+	# Run the program and capture stderr. If the program fails the 
+	# function fails with the same status.
+	"$@" 2>&7 || return $?
+}
+
+# }}}
+release_diagnostics() {							# {{{
+# Dump the diagnostic output captured via capture_diagnostics, optionally
+# prefixing each line.
+# Usage: release_diagnostics "prefix"
+
+	local script
+	script='
+		seek STDIN, 0, 0;
+		print "$ARGV[0]$_" while (<STDIN>);';
+	perl -e "$script" "$1" <&7
+}
+
+# }}}
+
+
+# }}}
+
 # vim: set sw=8 foldmethod=marker: 
 

-- 
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