rpms/openldap/devel openldap.spec,1.119,1.120

Jan Šafránek (jsafrane) fedora-extras-commits at redhat.com
Wed Mar 5 12:42:38 UTC 2008


Author: jsafrane

Update of /cvs/pkgs/rpms/openldap/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14159

Modified Files:
	openldap.spec 
Log Message:
- reworked the upgrade logic, slapcat/slapadd of the whole database is needed only if minor version changes (2.3.x -> 2.4.y)
- do not try to save database in LDIF format, if openldap-servers package is  being removed (it's up to the admin to do so manually)


Index: openldap.spec
===================================================================
RCS file: /cvs/pkgs/rpms/openldap/devel/openldap.spec,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- openldap.spec	29 Feb 2008 08:40:16 -0000	1.119
+++ openldap.spec	5 Mar 2008 12:41:56 -0000	1.120
@@ -8,7 +8,7 @@
 Summary: The configuration files, libraries, and documentation for OpenLDAP
 Name: openldap
 Version: %{version}
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: OpenLDAP
 Group: System Environment/Daemons
 Source0: ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-%{version}.tgz
@@ -415,20 +415,27 @@
         done
     fi
 fi
-# (the below is copied from the preun servers scriptlet below)
-# Save an ldif of the database where the "% post servers" scriptlet can
-# restore it.  Also save the database files to a "rpmorig" directory
-# Just In Case (TM)
-files=$(echo /var/lib/ldap/{log.*,__db.*,[a]lock})
-if [ "$files" != '/var/lib/ldap/log.* /var/lib/ldap/__db.* /var/lib/ldap/[a]lock' ] ; then
-  if /usr/sbin/slapcat -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1 ; then
-    if [ -f /var/lib/ldap/upgrade.ldif ] ; then
-      /bin/rm -fr /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-      mkdir /var/lib/ldap/rpmorig
-      mv /var/lib/ldap/{alock,*.bdb,__db.*,log.*} /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-      cp -f /var/lib/ldap/DB_CONFIG /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-    else
-      /bin/rm -f /var/lib/ldap/upgrade.ldif
+
+if [ "$1" = "2" ]; then
+  OLD_VERSION=$( rpm -q --qf "%{VERSION}" openldap-servers | sed 's/\.[0-9]*$//' )
+  NEW_VERSION=$( echo %{version} | sed 's/\.[0-9]*$//' )
+  if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
+    # Minor version number has changed -> slapcat/slapadd of the BDB database 
+    # is necessary. Save an ldif of the database where the "% post servers" 
+    # scriptlet can restore it.  Also save the database files to a "rpmorig" 
+    # directory - Just In Case (TM)
+    files=$(echo /var/lib/ldap/{log.*,__db.*,[a]lock})
+    if [ "$files" != '/var/lib/ldap/log.* /var/lib/ldap/__db.* /var/lib/ldap/[a]lock' ] ; then
+      if /usr/sbin/slapcat -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1 ; then
+        if [ -f /var/lib/ldap/upgrade.ldif ] ; then
+          /bin/rm -fr /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
+          mkdir /var/lib/ldap/rpmorig
+          mv /var/lib/ldap/{alock,*.bdb,__db.*,log.*} /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
+          cp -f /var/lib/ldap/DB_CONFIG /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
+        else
+          /bin/rm -f /var/lib/ldap/upgrade.ldif
+        fi
+      fi
     fi
   fi
 fi
@@ -437,7 +444,7 @@
 /sbin/ldconfig
 /sbin/chkconfig --add ldap
 # If there's a /var/lib/ldap/upgrade.ldif file, slapadd it and delete it.
-# It was created by the uninstall of the previous version.
+# It was created by the % pre above.
 if [ -f /var/lib/ldap/upgrade.ldif ] ; then
     /sbin/runuser -m -s /usr/sbin/slapadd -- "ldap" -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1
     rm /var/lib/ldap/upgrade.ldif
@@ -465,18 +472,11 @@
 if [ "$1" = "0" ] ; then
   /sbin/service ldap stop > /dev/null 2>&1 || :
   /sbin/chkconfig --del ldap
-# Save an ldif of the database where the "% post servers" scriptlet can
-# restore it.  Also save the database files to a "rpmorig" directory
-# Just In Case (TM)
-  files="/var/lib/ldap/log.* /var/lib/ldap/__db.* /var/lib/ldap/[a]lock"
-  if [ "$files" != '/var/lib/ldap/log.* /var/lib/ldap/__db.* /var/lib/ldap/[a]lock' ] ; then
-    if /usr/sbin/slapcat -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1 ; then
-      /bin/rm -fr /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-      mkdir /var/lib/ldap/rpmorig
-      mv /var/lib/ldap/{alock,*.bdb,__db.*,log.*} /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-      cp -f /var/lib/ldap/DB_CONFIG /var/lib/ldap/rpmorig > /dev/null 2>&1 || :
-    fi
-  fi
+# Openldap-servers are being removed from system.
+# Do not touch the database! Older versions of this
+# package attempted to store database in LDIF format, so
+# it can be restored later - but it's up to the administrator 
+# to save the database, if he/she wants so.
 fi
 
 %postun servers
@@ -561,6 +561,12 @@
 %attr(0644,root,root)      %{evolution_connector_libdir}/*.a
 
 %changelog
+* Wed Mar  5 2008 Jan Safranek <jsafranek at redhat.com> 2.4.8-3
+- reworked the upgrade logic, slapcat/slapadd of the whole database
+  is needed only if minor version changes (2.3.x -> 2.4.y)
+- do not try to save database in LDIF format, if openldap-servers package 
+  is  being removed (it's up to the admin to do so manually)
+
 * Thu Feb 28 2008 Jan Safranek <jsafranek at redhat.com> 2.4.8-2
 - migration tools carved out to standalone package "migrationtools"
   (#236697)




More information about the fedora-extras-commits mailing list