- bdb upgraded to 4.6.21

- reworked upgrade logic again to run db_upgrade when bdb version changes
This commit is contained in:
Jan Šafránek 2008-04-23 10:02:32 +00:00
parent 68c2fe40b8
commit bb50ce36bc

View File

@ -1,4 +1,7 @@
%define db_version 4.4.20 # We distribute own version of Berkeley DB to prevent
# problems on db4.rpm upgrade - some versions of db4 do
# not work with some versions of OpenLDAP.
%define db_version 4.6.21
%define ldbm_backend berkeley %define ldbm_backend berkeley
%define version 2.4.8 %define version 2.4.8
%define evolution_connector_prefix %{_libdir}/evolution-openldap %define evolution_connector_prefix %{_libdir}/evolution-openldap
@ -8,7 +11,7 @@
Summary: The configuration files, libraries, and documentation for OpenLDAP Summary: The configuration files, libraries, and documentation for OpenLDAP
Name: openldap Name: openldap
Version: %{version} Version: %{version}
Release: 3%{?dist} Release: 4%{?dist}
License: OpenLDAP License: OpenLDAP
Group: System Environment/Daemons Group: System Environment/Daemons
Source0: ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-%{version}.tgz Source0: ftp://ftp.OpenLDAP.org/pub/OpenLDAP/openldap-release/openldap-%{version}.tgz
@ -37,8 +40,7 @@ Patch10: openldap-2.4.6-multilib.patch
Patch200: openldap-2.4.6-evolution-ntlm.patch Patch200: openldap-2.4.6-evolution-ntlm.patch
# Patches for db4 library # Patches for db4 library
Patch400: db-4.4.20-1.patch
Patch401: db-4.4.20-2.patch
URL: http://www.openldap.org/ URL: http://www.openldap.org/
BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRoot: %{_tmppath}/%{name}-%{version}-root
@ -118,8 +120,6 @@ programs needed for accessing and modifying OpenLDAP directories.
%setup -q -c -a 1 %setup -q -c -a 1
pushd db-%{db_version} pushd db-%{db_version}
%patch400 -b .patch1
%patch401 -b .patch2
popd popd
pushd openldap-%{version} pushd openldap-%{version}
@ -179,13 +179,10 @@ pushd db-%{db_version}/build-rpm
--with-pic \ --with-pic \
--disable-static \ --disable-static \
--enable-shared \ --enable-shared \
--with-uniquename=_openldap_slapd_rhl_42 \ --with-uniquename=_openldap_slapd_46 \
--prefix=${dbdir} \ --prefix=${dbdir} \
--includedir=${dbdir}/include \ --includedir=${dbdir}/include \
--libdir=${dbdir}/%{_lib}${subdir:+/${subdir}} --libdir=${dbdir}/%{_lib}${subdir:+/${subdir}}
# XXX db-4.2.x handles O_DIRECT (by disabling on linux) correctly.
# XXX hack out O_DIRECT support in db4 for now.
perl -pi -e 's/#define HAVE_O_DIRECT 1/#undef HAVE_O_DIRECT/' db_config.h
# fix libtool: no rpath # fix libtool: no rpath
perl -pi -e 's|hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=\"-L\\\$libdir\"|g;' libtool perl -pi -e 's|hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=\"-L\\\$libdir\"|g;' libtool
@ -194,17 +191,15 @@ make install libdb_base=libslapd_db libso_base=libslapd_db strip="false"
ln -sf libslapd_db.so ${dbdir}/%{_lib}/${subdir}/libdb.so ln -sf libslapd_db.so ${dbdir}/%{_lib}/${subdir}/libdb.so
popd popd
# Find OpenSSL's header and library dependencies. export CPPFLAGS="-I${dbdir}/include"
if pkg-config openssl ; then export CFLAGS="$CPPFLAGS $RPM_OPT_FLAGS -D_REENTRANT -fPIC -D_GNU_SOURCE"
OPENSSL_CPPFLAGS=`pkg-config --cflags-only-I openssl` export LDFLAGS="-L${dbdir}/%{_lib}"
CPPFLAGS="$OPENSSL_CPPFLAGS" ; export CPPFLAGS export LD_LIBRARY_PATH=${dbdir}/%{_lib}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
OPENSSL_LDFLAGS=`pkg-config --libs-only-L openssl`
LDFLAGS="$OPENSSL_LDFLAGS" ; export LDFLAGS # hack to get properly named __lock_getlocker - needed for bdb 4.6.21 + openldap2.4.8
fi # check later releases
CPPFLAGS="-I${dbdir}/include $OPENSSL_CPPFLAGS" ; export CPPFLAGS export CPPFLAGS="$CPPFLAGS -D __lock_getlocker=__lock_getlocker_openldap_slapd_46"
CFLAGS="$CPPFLAGS $RPM_OPT_FLAGS -D_REENTRANT -fPIC -D_GNU_SOURCE"; export CFLAGS export CFLAGS="$CFLAGS -D __lock_getlocker=__lock_getlocker_openldap_slapd_46"
LDFLAGS="-L${dbdir}/%{_lib} $OPENSSL_LDFLAGS" ; export LDFLAGS
LD_LIBRARY_PATH=${dbdir}/%{_lib}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}; export LD_LIBRARY_PATH
build() { build() {
%configure \ %configure \
@ -417,28 +412,56 @@ if /usr/sbin/useradd -c "LDAP User" -u 55 \
fi fi
if [ "$1" = "2" ]; then if [ "$1" = "2" ]; then
OLD_VERSION=$( rpm -q --qf "%{VERSION}" openldap-servers | sed 's/\.[0-9]*$//' ) # guess, if database upgrade is necessary
NEW_VERSION=$( echo %{version} | sed 's/\.[0-9]*$//' ) OLD_BDB_VERSION=$( slapd_db_upgrade -V | sed 's/.* \([0-9\.]*\)\.[0-9]*:.*/\1/' )
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then NEW_BDB_VERSION=$( echo %{db_version} | sed 's/.[0-9]*$//' )
# Minor version number has changed -> slapcat/slapadd of the BDB database
# is necessary. Save an ldif of the database where the "% post servers" OLD_SLAPD_VERSION=$( rpm -q --qf "%{VERSION}" openldap-servers | sed 's/\.[0-9]*$//' )
# scriptlet can restore it. Also save the database files to a "rpmorig" NEW_SLAPD_VERSION=$( echo %{version} | sed 's/\.[0-9]*$//' )
# directory - Just In Case (TM)
files=$(echo /var/lib/ldap/{log.*,__db.*,[a]lock}) if [ "$OLD_SLAPD_VERSION" != "$NEW_SLAPD_VERSION" ]; then
if [ "$files" != '/var/lib/ldap/log.* /var/lib/ldap/__db.* /var/lib/ldap/[a]lock' ] ; then # Minor version number has changed -> slapcat/slapadd of the BDB database
if /usr/sbin/slapcat -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1 ; then # is necessary. Save an ldif of the database where the "% post servers"
if [ -f /var/lib/ldap/upgrade.ldif ] ; then # scriptlet can restore it. Also save the database files to a "rpmorig"
/bin/rm -fr /var/lib/ldap/rpmorig > /dev/null 2>&1 || : # directory - Just In Case (TM)
mkdir /var/lib/ldap/rpmorig
mv /var/lib/ldap/{alock,*.bdb,__db.*,log.*} /var/lib/ldap/rpmorig > /dev/null 2>&1 || : # stop the server
cp -f /var/lib/ldap/DB_CONFIG /var/lib/ldap/rpmorig > /dev/null 2>&1 || : if /sbin/service ldap status &>/dev/null; then
else touch /var/lib/ldap/need_start
/bin/rm -f /var/lib/ldap/upgrade.ldif /sbin/service ldap stop &>/dev/null
fi
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
else
if [ "$OLD_BDB_VERSION" != "$NEW_BDB_VERSION" ]; then
# Minor version number of bdb has changed -> run db_upgrade in % post script
# stop the server
if /sbin/service ldap status &>/dev/null; then
touch /var/lib/ldap/need_start
/sbin/service ldap stop &>/dev/null
fi
# Ensure, that the database is correct
/sbin/runuser -m -s /usr/sbin/slapd_db_recover -- "ldap" -h /var/lib/ldap &>/dev/null
# Just create /var/lib/ldap/need_db_upgrade so % post knows
touch /var/lib/ldap/need_db_upgrade &>/dev/null
fi fi
fi
fi fi
fi
fi fi
exit 0
%post servers %post servers
/sbin/ldconfig /sbin/ldconfig
@ -447,9 +470,17 @@ fi
# It was created by the % pre above. # It was created by the % pre above.
if [ -f /var/lib/ldap/upgrade.ldif ] ; then 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 /sbin/runuser -m -s /usr/sbin/slapadd -- "ldap" -l /var/lib/ldap/upgrade.ldif > /dev/null 2>&1
rm /var/lib/ldap/upgrade.ldif rm -f /var/lib/ldap/upgrade.ldif
fi fi
exec > /dev/null 2> /dev/null
# If there's a /var/lib/ldap/need_db_upgrade file, run db_upgrade and delete it.
# It was created by the % pre above.
if [ -f /var/lib/ldap/need_db_upgrade ]; then
/sbin/runuser -m -s /usr/sbin/slapd_db_upgrade -- "ldap" -h /var/lib/ldap /var/lib/ldap/*.bdb
/sbin/runuser -m -s /usr/sbin/slapd_db_checkpoint -- "ldap" -h /var/lib/ldap -1
rm -f /var/lib/ldap/need_db_upgrade
fi
if [ ! -f %{_sysconfdir}/pki/tls/certs/slapd.pem ] ; then if [ ! -f %{_sysconfdir}/pki/tls/certs/slapd.pem ] ; then
pushd %{_sysconfdir}/pki/tls/certs pushd %{_sysconfdir}/pki/tls/certs
umask 077 umask 077
@ -466,6 +497,16 @@ chown root:ldap slapd.pem
chmod 640 slapd.pem chmod 640 slapd.pem
popd popd
fi fi
if [ $1 -ge 1 ] ; then
/sbin/service ldap condrestart &>/dev/null
/sbin/service ldap status &>/dev/null
if [ "$?" != "0" -a -f /var/lib/ldap/need_start ]; then
/sbin/service ldap start &>/dev/null
rm -f /var/lib/ldap/need_start &>/dev/null
fi
fi
exit 0 exit 0
%preun servers %preun servers
@ -481,9 +522,6 @@ fi
%postun servers %postun servers
/sbin/ldconfig /sbin/ldconfig
if [ $1 -ge 1 ] ; then
/sbin/service ldap condrestart > /dev/null 2>&1 || :
fi
%post devel -p /sbin/ldconfig %post devel -p /sbin/ldconfig
@ -561,6 +599,11 @@ fi
%attr(0644,root,root) %{evolution_connector_libdir}/*.a %attr(0644,root,root) %{evolution_connector_libdir}/*.a
%changelog %changelog
* Thu Apr 10 2008 Jan Safranek <jsafranek@redhat.com> 2.4.8-4
- bdb upgraded to 4.6.21
- reworked upgrade logic again to run db_upgrade when bdb version
changes
* Wed Mar 5 2008 Jan Safranek <jsafranek@redhat.com> 2.4.8-3 * Wed Mar 5 2008 Jan Safranek <jsafranek@redhat.com> 2.4.8-3
- reworked the upgrade logic, slapcat/slapadd of the whole database - reworked the upgrade logic, slapcat/slapadd of the whole database
is needed only if minor version changes (2.3.x -> 2.4.y) is needed only if minor version changes (2.3.x -> 2.4.y)