RFC: FreeBSD DB Port Reform
ma at dt.e-technik.uni-dortmund.de
Thu Nov 6 03:44:22 PST 2003
I am planning to reform the way the BerkeleyDB 3, 4 and 4.1 ports are
currently laid out, to reduce the mess that a BDB dependent port leaves
in Makefile and files/patch-*.
This will involve changes to all BerkeleyDB dependent ports!
I have a web site on this topic with preview tarballs of the new ports,
Here is the lynx dump of the web site:
The FreeBSD BerkeleyDB Port Reform
Revision: $Id: index.html,v 0.1 2003/11/06 11:24:33 emma Exp emma $
The current databases/db* ports are a mess. They use nonstandard
library names that require porters to ship a lot of FreeBSD
files/patch-* patches to make the port compile with the non-canonical
I believe the layout has historical reasons in a.out. ELF, with its
SONAME feature, allows for a more elegant and standard-conforming
layout that allows us to drop FreeBSD specific patches from the ports.
* Any ELF shared object (library), seen as .so file, bears an
"SONAME" tag that can be made visible with "readelf -d FILENAME"
and that needs not match the file name (it often does, see below).
* Any ELF executable that links against shared object bears a
corresponding "NEEDED" tag. A link time, here is recorded the
SONAME of the .so file linked against, not the file name. Example:
Linking a program with -L/usr/local/BerkeleyDB.4.1 -ldb will
insert a "NEEDED: libdb-4.1.so.1" trait into the program. The
program will, at run time, automatically choose
/usr/local/lib/libdb-4.1.so.1. This NEEDED information is also
visible in "readelf -d FILENAME".
* An ELF executable MAY have one or more "RPATH" tag that specifies
exactly one shared object search path element. It allows to
specify the link path in an executable, and saves the end user the
hassle of editing ld.so.conf or LD_LIBRARY_PATH for non-default
library paths. This is, you guessed it, visible in "readelf -d
1. Remove db2 port (move it into the Attic). According to INDEX, not
a single port depends on it.
2. bsd.ports.mk should be extended to support WITH_BDB_VER,
USE_BDB_VER or WANT_BDB_VER or something that presets a set of
variables, for instance BDB_VERSION, BDB_INCLUDES, BDB_LIBNAME,
BDB_LIBPATH and LIB_DEPENDS, to lift shared code out of the
individual ports into bsd.ports.mk.
3. for db3, db4 and db41, the following changes are made:
1. all programs move into $PREFIX/BerkeleyDB.N.M/bin/db_*
2. programs will no longer be renamed to db41_* db4_* or db3_*.
3. all libraries maintain their official SleepyCat names,
libdb-3.3, libdb-4.0, libdb-4.1, and will not be renamed to
libdb3, libdb4 or libdb41 - this removes the need for a good
deal or REINPLACE_CMD or patches.
4. all libraries move into $PREFIX/BerkeleyDB.N.M/lib, because
BerkeleyDB installs not only libdb-N.M* but also libdb-N* and
libdb* (where * is .so.N, .so or .a), which cannot work in
the same path.
5. a relative symbolic link from $PREFIX/lib/libdb-N.M.so.M to
../BerkeleyDB.N.M/lib/libdb-N.M.so.M (the SONAME, see above)
6. documentation moves into $PREFIX/share/doc/BerkeleyDB.N.M and
is symlinked from $PREFIX/BerkeleyDB.N.M/docs
7. All BerkeleyDB distributions will be compiled with
--with-uniquename, so that the same application can link two
different DB versions without conflicts. It's not too common,
but can happen indirectly through other libraries. See
NOTE: This changes the ABI (but not the API), which means all
applications will have to be recompiled and relinked.
4. Dependent ports will have to be updated and recompiled, this will
need the help of original maintainers.
5. db2 references will be removed, the WITH_BDB_VER stuff will be
updated to the new port directory layout, will be unified across
all ports (so no WITH_BDB4 games as some Ruby ports do) so that it
can move into Mk/bsd.ports.mk
* no more makefile file patching for the arcane layout. -ldb with
proper LDFLAGS will "just work".
* ports that use the official library names such as -ldb-3.3,
ldb-4.0, ldb-4.1, will also "just work".
* ports that have --with-db switches and expect a standard
BerkeleyDB.N.M directory under /usr/local will also "just work".
* Fewer FreeBSD-specific patches in the ports tree will be needed.
All ports that depend on DB will have to be updated once.
Port tarballs for preview are here. Comments are solicited.
1. mailto:matthias.andree at gmx.de?subject=FreeBSD+BDB+reform
Encrypt your mail: my GnuPG key ID is 0x052E7D95
More information about the freebsd-ports