[Pkg-openldap-devel] r969 - openldap/trunk/debian

Steve Langasek vorlon at alioth.debian.org
Fri Jan 11 01:46:29 UTC 2008


Author: vorlon
Date: 2008-01-11 01:46:29 +0000 (Fri, 11 Jan 2008)
New Revision: 969

Modified:
   openldap/trunk/debian/changelog
   openldap/trunk/debian/slapd.postinst
   openldap/trunk/debian/slapd.scripts-common
Log:
* "checkpoint" directives are no longer supported as part of the backend
  config, only as part of the database config; move the lines around in
  slapd.conf on upgrade.

Modified: openldap/trunk/debian/changelog
===================================================================
--- openldap/trunk/debian/changelog	2007-12-22 01:19:45 UTC (rev 968)
+++ openldap/trunk/debian/changelog	2008-01-11 01:46:29 UTC (rev 969)
@@ -53,6 +53,9 @@
   * Split slapi dev support into a new libslapi-dev package, as this is
     unrelated to libldap; and drop libslapi.a since it would be insane to try
     to statically link a dynamically-loaded slapi plugin.
+  * "checkpoint" directives are no longer supported as part of the backend
+    config, only as part of the database config; move the lines around in
+    slapd.conf on upgrade.
 
   [ Russ Allbery ]
   * Removed fix_ldif and all remaining code to try running it on LDIF
@@ -93,7 +96,7 @@
   * Remove versioned dependency on an ancient dpkg-dev.
   * Wrap and reorder Build-Depends for readability.
 
- -- Russ Allbery <rra at debian.org>  Fri, 21 Dec 2007 15:37:47 -0800
+ -- Steve Langasek <vorlon at debian.org>  Thu, 10 Jan 2008 17:44:26 -0800
 
 openldap2.3 (2.3.39-1) unstable; urgency=medium
 

Modified: openldap/trunk/debian/slapd.postinst
===================================================================
--- openldap/trunk/debian/slapd.postinst	2007-12-22 01:19:45 UTC (rev 968)
+++ openldap/trunk/debian/slapd.postinst	2008-01-11 01:46:29 UTC (rev 969)
@@ -43,6 +43,10 @@
 		fi
 	fi
 
+	if previous_version_older 2.4.7-1; then
+		migrate_bdb_checkpoint
+	fi
+
 	if database_format_changed; then
 		# During upgrading we have to load the old data
 		move_incompatible_databases_away

Modified: openldap/trunk/debian/slapd.scripts-common
===================================================================
--- openldap/trunk/debian/slapd.scripts-common	2007-12-22 01:19:45 UTC (rev 968)
+++ openldap/trunk/debian/slapd.scripts-common	2008-01-11 01:46:29 UTC (rev 969)
@@ -424,7 +424,81 @@
 
 # }}}
 
+migrate_bdb_checkpoint() {						# {{{
+# move any 'checkpoint' options from the backend stanza to the
+# per-database stanza
 
+	local script
+	script='
+		use File::Temp;
+		use File::Compare;
+		use File::Copy;
+
+		$backend_bdb = $backend_hdb = 0;
+		$checkpoint_bdb = "";
+		$checkpoint_hdb = "";
+
+		sub changeConfig
+		{
+			my ($filename) = @_;
+
+			open(HANDLE, "<". $filename) || return;
+			my @data = <HANDLE>;
+			close(HANDLE);
+
+			my ($fh, $tmpfile) = mkstemp("/tmp/slapd.XXXXXX");
+
+			foreach (@data) {
+				# Parse includes, but forget the schema files.
+				if (/^include\s+([^\s#]+)/) {
+					my $file = $1;
+					if ($file !~ m,/etc/ldap/schema/,) {
+						changeConfig($file) 
+					}
+				}
+				$backend_bdb = $backend_hdb = 0 if (/^\s+(backend|database)\s+/);
+				$backend_bdb = 1 if (/^\s*backend\s+bdb/);
+				$backend_hdb = 1 if (/^\s*backend\s+hdb/);
+				if (/^\s*checkpoint\s+/) {
+					$checkpoint_bdb = $_ if ($backend_bdb);
+					$checkpoint_hdb = $_ if ($backend_hdb);
+					next if ($backend_bdb || $backend_hdb);
+				}
+				if (/^\s*database\s+bdb/)
+				{
+					print $fh $_ . $checkpoint_bdb;
+					next;
+				}
+				if (/^\s*database\s+hdb/)
+				{
+					print $fh $_ . $checkpoint_hdb;
+					next;
+				}
+				print $fh $_;
+			}
+
+			# Close the tempfile handle opened by mkstemp.
+			close($fh);
+
+			# If file is changed replace the original file.
+			if (compare($filename, $tmpfile) != 0) {
+				move($tmpfile, $filename);
+			} else {
+				unlink($tmpfile);
+			}
+		}
+
+		$config = shift;
+		changeConfig ($config);'
+
+	echo -n "  Upgrading BDB 'checkpoint' options... " >&2
+
+	perl -e "$script" $SLAPD_CONF
+
+	echo . >&2
+}
+# }}}
+
 compute_backup_path() {							# {{{
 # Compute the path to backup a database directory
 # Usage: compute_backup_path [-n] <dir> <basedn>




More information about the Pkg-openldap-devel mailing list