3beeaa3
# the set of arches on which libgcj provides gcj and libgcj-javac-placeholder.sh
3beeaa3
%define java_arches %{ix86} alpha ia64 ppc sparc sparcv9 x86_64 s390 s390x
3beeaa3
%define __soversion_major 5
3beeaa3
%define __soversion %{__soversion_major}.0
3beeaa3
3beeaa3
Summary: The Berkeley DB database library for C
3beeaa3
Name: libdb
3beeaa3
Version: 5.0.21
3beeaa3
Release: 1%{?dist}
3beeaa3
Source0: http://download.oracle.com/berkeley-db/db-%{version}.tar.gz
3beeaa3
Source1: http://download.oracle.com/berkeley-db/db.1.85.tar.gz
3beeaa3
# db-1.85 upstream patches
3beeaa3
Patch10: http://www.oracle.com/technology/products/berkeley-db/db/update/1.85/patch.1.1
3beeaa3
Patch11: http://www.oracle.com/technology/products/berkeley-db/db/update/1.85/patch.1.2
3beeaa3
Patch12: http://www.oracle.com/technology/products/berkeley-db/db/update/1.85/patch.1.3
3beeaa3
Patch13: http://www.oracle.com/technology/products/berkeley-db/db/update/1.85/patch.1.4
3beeaa3
# other patches
3beeaa3
Patch20: db-1.85-errno.patch
3beeaa3
Patch22: db-4.6.21-1.85-compat.patch
3beeaa3
Patch24: db-4.5.20-jni-include-dir.patch
3beeaa3
URL: http://www.oracle.com/database/berkeley-db/
3beeaa3
License: BSD
3beeaa3
Group: System Environment/Libraries
3beeaa3
# unversioned obsoletes are OK here as these BDB versions never occur again
3beeaa3
BuildRequires: perl, libtool, ed
3beeaa3
BuildRequires: tcl-devel >= 8.5.2-3
3beeaa3
%ifarch %{java_arches}
3beeaa3
BuildRequires: gcc-java
3beeaa3
BuildRequires: java-1.6.0-openjdk-devel
3beeaa3
%endif
3beeaa3
BuildRequires: chrpath
3beeaa3
BuildRequires: dos2unix
3beeaa3
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
3beeaa3
3beeaa3
%description
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. The Berkeley DB includes B+tree, Extended
3beeaa3
Linear Hashing, Fixed and Variable-length record access methods,
3beeaa3
transactions, locking, logging, shared memory caching, and database
3beeaa3
recovery. The Berkeley DB supports C, C++, Java, and Perl APIs. It is
3beeaa3
used by many applications, including Python and Perl, so this should
3beeaa3
be installed on all systems.
3beeaa3
3beeaa3
%package cxx
3beeaa3
Summary: The Berkeley DB database library for C++
3beeaa3
Group: System Environment/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description cxx
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. The Berkeley DB includes B+tree, Extended
3beeaa3
Linear Hashing, Fixed and Variable-length record access methods,
3beeaa3
transactions, locking, logging, shared memory caching, and database
3beeaa3
recovery. The Berkeley DB supports C, C++, Java, and Perl APIs. It is
3beeaa3
used by many applications, including Python and Perl, so this should
3beeaa3
be installed on all systems.
3beeaa3
3beeaa3
%package utils
3beeaa3
Summary: Command line tools for managing Berkeley DB databases
3beeaa3
Group: Applications/Databases
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description utils
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. Berkeley DB includes B+tree, Extended
3beeaa3
Linear Hashing, Fixed and Variable-length record access methods,
3beeaa3
transactions, locking, logging, shared memory caching, and database
3beeaa3
recovery. DB supports C, C++, Java and Perl APIs.
3beeaa3
3beeaa3
%package devel
3beeaa3
Summary: C development files for the Berkeley DB library
3beeaa3
Group: Development/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description devel
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. This package contains the header files,
3beeaa3
libraries, and documentation for building programs which use the
3beeaa3
Berkeley DB.
3beeaa3
3beeaa3
%package devel-static
3beeaa3
Summary: Berkeley DB static libraries
3beeaa3
Group: Development/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description devel-static
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. This package contains static libraries
3beeaa3
needed for applications that require static linking of
3beeaa3
Berkeley DB.
3beeaa3
3beeaa3
%package tcl
3beeaa3
Summary: Development files for using the Berkeley DB with tcl
3beeaa3
Group: Development/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description tcl
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. This package contains the libraries
3beeaa3
for building programs which use the Berkeley DB in Tcl.
3beeaa3
3beeaa3
%package sql
3beeaa3
Summary: Development files for using the Berkeley DB with sql
3beeaa3
Group: Development/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description sql
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. This package contains the libraries
3beeaa3
for building programs which use the Berkeley DB in SQL.
3beeaa3
3beeaa3
%package java
3beeaa3
Summary: Development files for using the Berkeley DB with Java
3beeaa3
Group: Development/Libraries
3beeaa3
Requires: %{name} = %{version}-%{release}
3beeaa3
3beeaa3
%description java
3beeaa3
The Berkeley Database (Berkeley DB) is a programmatic toolkit that
3beeaa3
provides embedded database support for both traditional and
3beeaa3
client/server applications. This package contains the libraries
3beeaa3
for building programs which use the Berkeley DB in Java.
3beeaa3
3beeaa3
%prep
3beeaa3
%setup -q -n db-%{version} -a 1
3beeaa3
3beeaa3
pushd db.1.85/PORT/linux
3beeaa3
%patch10 -p0 -b .1.1
3beeaa3
popd
3beeaa3
pushd db.1.85
3beeaa3
%patch11 -p0 -b .1.2
3beeaa3
%patch12 -p0 -b .1.3
3beeaa3
%patch13 -p0 -b .1.4
3beeaa3
%patch20 -p1 -b .errno
3beeaa3
popd
3beeaa3
3beeaa3
%patch22 -p1 -b .185compat
3beeaa3
%patch24 -p1 -b .4.5.20.jni
3beeaa3
3beeaa3
# fix encoding
3beeaa3
dos2unix examples_c/bench_001.c
3beeaa3
3beeaa3
# Define a shell function for fixing HREF references in the docs, which
3beeaa3
# would otherwise break when we split the docs up into subpackages.
3beeaa3
fixup_href() {
3beeaa3
	for doc in $@ ; do
3beeaa3
		chmod u+w ${doc}
3beeaa3
		sed	-e 's,="../api_c/,="../../%{name}-devel-%{version}/api_c/,g' \
3beeaa3
			-e 's,="api_c/,="../%{name}-devel-%{version}/api_c/,g' \
3beeaa3
			-e 's,="../api_cxx/,="../../%{name}-devel-%{version}/api_cxx/,g' \
3beeaa3
			-e 's,="api_cxx/,="../%{name}-devel-%{version}/api_cxx/,g' \
3beeaa3
			-e 's,="../api_tcl/,="../../%{name}-devel-%{version}/api_tcl/,g' \
3beeaa3
			-e 's,="api_tcl/,="../%{name}-devel-%{version}/api_tcl/,g' \
3beeaa3
			-e 's,="../java/,="../../%{name}-devel-%{version}/java/,g' \
3beeaa3
			-e 's,="java/,="../%{name}-devel-%{version}/java/,g' \
3beeaa3
			-e 's,="../examples_c/,="../../%{name}-devel-%{version}/examples_c/,g' \
3beeaa3
			-e 's,="examples_c/,="../%{name}-devel-%{version}/examples_c/,g' \
3beeaa3
			-e 's,="../examples_cxx/,="../../%{name}-devel-%{version}/examples_cxx/,g' \
3beeaa3
			-e 's,="examples_cxx/,="../%{name}-devel-%{version}/examples_cxx/,g' \
3beeaa3
			-e 's,="../ref/,="../../%{name}-devel-%{version}/ref/,g' \
3beeaa3
			-e 's,="ref/,="../%{name}-devel-%{version}/ref/,g' \
3beeaa3
			-e 's,="../images/,="../../%{name}-devel-%{version}/images/,g' \
3beeaa3
			-e 's,="images/,="../%{name}-devel-%{version}/images/,g' \
3beeaa3
			-e 's,="../utility/,="../../%{name}-utils-%{version}/utility/,g' \
3beeaa3
			-e 's,="utility/,="../%{name}-utils-%{version}/utility/,g' ${doc} > ${doc}.new
3beeaa3
		touch -r ${doc} ${doc}.new
3beeaa3
		cat ${doc}.new > ${doc}
3beeaa3
		touch -r ${doc}.new ${doc}
3beeaa3
		rm -f ${doc}.new
3beeaa3
	done
3beeaa3
}
3beeaa3
3beeaa3
set +x
3beeaa3
# Fix all of the HTML files.
3beeaa3
fixup_href `find . -name "*.html"`
3beeaa3
set -x
3beeaa3
3beeaa3
cd dist
3beeaa3
./s_config
3beeaa3
3beeaa3
%build
3beeaa3
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"; export CFLAGS
3beeaa3
3beeaa3
# Build the old db-185 libraries.
3beeaa3
make -C db.1.85/PORT/%{_os} OORG="$CFLAGS"
3beeaa3
3beeaa3
build() {
3beeaa3
	test -d dist/$1 || mkdir dist/$1
3beeaa3
	# Static link db_dump185 with old db-185 libraries.
3beeaa3
	/bin/sh libtool --mode=compile	%{__cc} $RPM_OPT_FLAGS -Idb.1.85/PORT/%{_os}/include -D_REENTRANT -c db_dump185/db_dump185.c -o dist/$1/db_dump185.lo
3beeaa3
	/bin/sh libtool --mode=link	%{__cc} -o dist/$1/db_dump185 dist/$1/db_dump185.lo db.1.85/PORT/%{_os}/libdb.a
3beeaa3
3beeaa3
	pushd dist
3beeaa3
	popd
3beeaa3
	pushd dist/$1
3beeaa3
	ln -sf ../configure .
3beeaa3
	# XXX --enable-diagnostic should be disabled for production (but is
3beeaa3
	# useful).
3beeaa3
	# XXX --enable-debug_{r,w}op should be disabled for production.
3beeaa3
	%configure -C \
3beeaa3
		--enable-compat185 --enable-dump185 \
3beeaa3
		--enable-shared --enable-static \
3beeaa3
		--enable-tcl --with-tcl=%{_libdir} \
3beeaa3
		--enable-cxx --enable-sql \
3beeaa3
%ifarch %{java_arches}
3beeaa3
		--enable-java \
3beeaa3
%else
3beeaa3
		--disable-java \
3beeaa3
%endif
3beeaa3
		--enable-test \
3beeaa3
		--with-tcl=%{_libdir}/tcl8.5 \
3beeaa3
		--disable-rpath \
3beeaa3
		# --enable-diagnostic \
3beeaa3
		# --enable-debug --enable-debug_rop --enable-debug_wop \
3beeaa3
3beeaa3
	# Remove libtool predep_objects and postdep_objects wonkiness so that
3beeaa3
	# building without -nostdlib doesn't include them twice.  Because we
3beeaa3
	# already link with g++, weird stuff happens if you don't let the
3beeaa3
	# compiler handle this.
3beeaa3
	perl -pi -e 's/^predep_objects=".*$/predep_objects=""/' libtool
3beeaa3
	perl -pi -e 's/^postdep_objects=".*$/postdep_objects=""/' libtool
3beeaa3
	perl -pi -e 's/-shared -nostdlib/-shared/' libtool
3beeaa3
3beeaa3
	make %{?_smp_mflags}
3beeaa3
3beeaa3
	# XXX hack around libtool not creating ./libs/libdb_java-X.Y.lai
3beeaa3
	LDBJ=./.libs/libdb_java-%{__soversion}.la
3beeaa3
	if test -f ${LDBJ} -a ! -f ${LDBJ}i; then
3beeaa3
		sed -e 's,^installed=no,installed=yes,' < ${LDBJ} > ${LDBJ}i
3beeaa3
	fi
3beeaa3
3beeaa3
	popd
3beeaa3
}
3beeaa3
3beeaa3
build dist-tls
3beeaa3
3beeaa3
%install
3beeaa3
rm -rf ${RPM_BUILD_ROOT}
3beeaa3
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}
3beeaa3
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
3beeaa3
3beeaa3
%makeinstall -C dist/dist-tls
3beeaa3
3beeaa3
# XXX Nuke non-versioned archives and symlinks
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/{libdb.a,libdb_cxx.a,libdb_tcl.a,libdb_sql.a}
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdb-%{__soversion_major}.so
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdb_cxx-%{__soversion_major}.so
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdb_tcl-%{__soversion_major}.so
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdb_sql-%{__soversion_major}.so
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdb_tcl.so
3beeaa3
3beeaa3
chmod +x ${RPM_BUILD_ROOT}%{_libdir}/*.so*
3beeaa3
3beeaa3
# Move the main shared library from /usr/lib* to /lib* directory.
3beeaa3
if [ "%{_libdir}" != "/%{_lib}" ]; then
3beeaa3
  mkdir -p $RPM_BUILD_ROOT/%{_lib}/
3beeaa3
  mv $RPM_BUILD_ROOT/%{_libdir}/libdb-%{__soversion}.so $RPM_BUILD_ROOT/%{_lib}/
3beeaa3
3beeaa3
# Leave relative symlinks in %{_libdir}.
3beeaa3
  touch $RPM_BUILD_ROOT/rootfile
3beeaa3
  root=..
3beeaa3
  while [ ! -e $RPM_BUILD_ROOT/%{_libdir}/${root}/rootfile ] ; do
3beeaa3
	root=${root}/..
3beeaa3
  done
3beeaa3
  rm $RPM_BUILD_ROOT/rootfile
3beeaa3
3beeaa3
  ln -sf ${root}/%{_lib}/libdb-%{__soversion}.so $RPM_BUILD_ROOT/%{_libdir}/libdb.so
3beeaa3
  ln -sf ${root}/%{_lib}/libdb-%{__soversion}.so $RPM_BUILD_ROOT/%{_libdir}/
3beeaa3
  ln -sf libdb_cxx-%{__soversion}.so $RPM_BUILD_ROOT/%{_libdir}/libdb_cxx.so
3beeaa3
fi
3beeaa3
3beeaa3
# Move the header files to a subdirectory, in case we're deploying on a
3beeaa3
# system with multiple versions of DB installed.
3beeaa3
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/%{name}
3beeaa3
mv ${RPM_BUILD_ROOT}%{_includedir}/*.h ${RPM_BUILD_ROOT}%{_includedir}/%{name}/
3beeaa3
3beeaa3
# Create symlinks to includes so that "use <db.h> and link with -ldb" works.
3beeaa3
for i in db.h db_cxx.h db_185.h; do
3beeaa3
	ln -s %{name}/$i ${RPM_BUILD_ROOT}%{_includedir}
3beeaa3
done
3beeaa3
3beeaa3
%ifarch %{java_arches}
3beeaa3
# Move java jar file to the correct place
3beeaa3
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/java
3beeaa3
mv ${RPM_BUILD_ROOT}%{_libdir}/*.jar ${RPM_BUILD_ROOT}%{_datadir}/java
3beeaa3
%endif
3beeaa3
3beeaa3
# Eliminate installed doco
3beeaa3
rm -rf ${RPM_BUILD_ROOT}%{_prefix}/docs
3beeaa3
3beeaa3
# XXX Avoid Permission denied. strip when building as non-root.
3beeaa3
chmod u+w ${RPM_BUILD_ROOT}%{_bindir} ${RPM_BUILD_ROOT}%{_bindir}/*
3beeaa3
3beeaa3
# remove unneeded .la files (#225675)
3beeaa3
rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.la
3beeaa3
3beeaa3
# remove C# devel files
3beeaa3
rm -rf docs/csharp
3beeaa3
3beeaa3
# avoid fancy permissons
3beeaa3
chmod 0755 ${RPM_BUILD_ROOT}%{_libdir}/*.so
3beeaa3
3beeaa3
# remove RPATHs
3beeaa3
chrpath -d ${RPM_BUILD_ROOT}%{_libdir}/*.so ${RPM_BUILD_ROOT}%{_bindir}/*
3beeaa3
3beeaa3
%clean
3beeaa3
rm -rf ${RPM_BUILD_ROOT}
3beeaa3
3beeaa3
%post -p /sbin/ldconfig
3beeaa3
3beeaa3
%postun -p /sbin/ldconfig
3beeaa3
3beeaa3
%post -p /sbin/ldconfig cxx
3beeaa3
3beeaa3
%postun -p /sbin/ldconfig cxx
3beeaa3
3beeaa3
%post -p /sbin/ldconfig sql
3beeaa3
3beeaa3
%postun -p /sbin/ldconfig sql
3beeaa3
3beeaa3
%post -p /sbin/ldconfig tcl
3beeaa3
3beeaa3
%postun -p /sbin/ldconfig tcl
3beeaa3
3beeaa3
%post -p /sbin/ldconfig java
3beeaa3
3beeaa3
%postun -p /sbin/ldconfig java
3beeaa3
3beeaa3
%files
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%doc LICENSE README
3beeaa3
/%{_lib}/libdb-%{__soversion}.so
3beeaa3
%{_libdir}/libdb-%{__soversion}.so
3beeaa3
3beeaa3
%files cxx
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%{_libdir}/libdb_cxx-%{__soversion}.so
3beeaa3
3beeaa3
%files utils
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%{_bindir}/db*_archive
3beeaa3
%{_bindir}/db*_checkpoint
3beeaa3
%{_bindir}/db*_deadlock
3beeaa3
%{_bindir}/db*_dump*
3beeaa3
%{_bindir}/db*_hotbackup
3beeaa3
%{_bindir}/db*_load
3beeaa3
%{_bindir}/db*_printlog
3beeaa3
%{_bindir}/db*_recover
3beeaa3
%{_bindir}/db*_stat
3beeaa3
%{_bindir}/db*_upgrade
3beeaa3
%{_bindir}/db*_verify
3beeaa3
3beeaa3
%files devel
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%doc	docs/*
3beeaa3
%doc	examples_c examples_cxx
3beeaa3
%{_libdir}/libdb.so
3beeaa3
%{_libdir}/libdb_cxx.so
3beeaa3
%dir %{_includedir}/%{name}
3beeaa3
%{_includedir}/%{name}/db.h
3beeaa3
%{_includedir}/%{name}/db_185.h
3beeaa3
%{_includedir}/%{name}/db_cxx.h
3beeaa3
%{_includedir}/db.h
3beeaa3
%{_includedir}/db_185.h
3beeaa3
%{_includedir}/db_cxx.h
3beeaa3
3beeaa3
%files devel-static
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%{_libdir}/libdb-%{__soversion}.a
3beeaa3
%{_libdir}/libdb_cxx-%{__soversion}.a
3beeaa3
%{_libdir}/libdb_tcl-%{__soversion}.a
3beeaa3
%{_libdir}/libdb_sql-%{__soversion}.a
3beeaa3
%ifarch %{java_arches}
3beeaa3
%{_libdir}/libdb_java-%{__soversion}.a
3beeaa3
%endif
3beeaa3
3beeaa3
%files tcl
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%{_libdir}/libdb_tcl-%{__soversion}.so
3beeaa3
3beeaa3
%files sql
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%{_bindir}/dbsql
3beeaa3
%{_libdir}/libdb_sql.so
3beeaa3
%{_libdir}/libdb_sql-%{__soversion}.so
3beeaa3
%{_includedir}/%{name}/dbsql.h
3beeaa3
3beeaa3
%ifarch %{java_arches}
3beeaa3
%files java
3beeaa3
%defattr(-,root,root,-)
3beeaa3
%doc docs/java
3beeaa3
%doc examples_java
3beeaa3
%{_libdir}/libdb_java*.so
3beeaa3
%{_datadir}/java/*.jar
3beeaa3
%endif
3beeaa3
3beeaa3
%changelog
3beeaa3
* Wed Apr 21 2010 Jindrich Novy <jnovy@redhat.com> 5.0.21-1
3beeaa3
- initial build
3beeaa3
3beeaa3
* Thu Apr 15 2010 Jindrich Novy <jnovy@redhat.com> 5.0.21-0.2
3beeaa3
- remove C# documentation
3beeaa3
- disable/remove rpath
3beeaa3
- fix description
3beeaa3
- tighten dependencies
3beeaa3
- run ldconfig for cxx and sql subpackages
3beeaa3
3beeaa3
* Fri Apr  9 2010 Jindrich Novy <jnovy@redhat.com> 5.0.21-0.1
3beeaa3
- enable sql
3beeaa3
- package 5.0.21