Berkeley DB 5.3.28

Tested on LFS 12.3 system. Given that Berkeley DB is listed as deprecated in LFS/BLFS, I had to spend a bit of time getting this to work (the instructions in 12.0 don't work out of the box anymore). Most distros aren't adopting Berkeley DB version 6.x as the licensing changed somewhere in that series. I need BDB still for apt-ftparchive, but there are some other applications where BDB is still used. Here's how I got it working on LFS. Note: This hint works with GCC 14, but will likely NOT work on GCC 15 without some modifications.

I don't generally recommend nabbing stuff from a distro as that can potentially lead to issues on LFS systems, but in this case, the Debian patches are necessary (both for security and build-time issues) and work properly, so call this a one-off exception.

You'll need the following files:

http://ftp.debian.org/debian/pool/main/d/db5.3/db5.3_5.3.28+dfsg2-9.debian.tar.xz

http://ftp.debian.org/debian/pool/main/d/db5.3/db5.3_5.3.28+dfsg2.orig.tar.xz

Extract both tarballs. You should have two folders, `db-5.3.28` and `debian`. cd into the `db-5.3.28` folder.

The first step is to apply the patches.

patch -p1 < ../debian/patches/0015-Add-missing-includes.patch
patch -p1 < ../debian/patches/001-checkpoint-opd-deadlock.patch
patch -p1 < ../debian/patches/002-versioned_symbols.patch
patch -p1 < ../debian/patches/003-jni_javac.patch
patch -p1 < ../debian/patches/004-tclsleep.patch
patch -p1 < ../debian/patches/005-pg_crypt_size.patch
patch -p1 < ../debian/patches/006-mutex_alignment.patch
patch -p1 < ../debian/patches/007-link-sql-libs.patch
patch -p1 < ../debian/patches/008-autoconf-in-lang-sql-sqlite.patch
patch -p1 < ../debian/patches/009-java-10.patch
patch -p1 < ../debian/patches/010-__atomic_compare_exchange.patch
patch -p1 < ../debian/patches/011-Use-one-object-for-shqueue.h-test.patch
patch -p1 < ../debian/patches/012-Don-t-expo-progname-symbol.patch
patch -p1 < ../debian/patches/014-implicit-int.patch
patch -p1 < ../debian/patches/CVE-2017-10140-cwd-db_config.patch
patch -p1 < ../debian/patches/CVE-2019-8457.patch
patch -p1 < ../debian/patches/gcc-14.patch
patch -p1 < ../debian/patches/mmap_extend-mode-requires-page-aligned-extends.patch

Since we've touched the *.m4 files, we need to regenerate configure:

cd dist
./s_config

You can safely ignore warnings about outdated macros.

Next, we need to run configure

cd ../build_unix

make clean

../dist/configure --prefix=/usr --disable-option-checking --disable-silent-rules --disable-maintainer-mode --disable-dependency-tracking --enable-cxx --enable-compat185 --disable-java --disable-sql --disable-stl --enable-dbm --with-mutex=POSIX/pthreads/library

Now to install - we don't want the static libraries so we do this in a couple steps. First we install to a temp directory, then copy the needed parts to their final places, and finally run ldconfig to update the loader cache.

make -j1 install DESTDIR=$(pwd)/temp

cp -av temp/usr/bin/* /usr/bin/

cp -av temp/usr/lib/*.so /usr/lib/

cp -av temp/usr/include/*.h /usr/include/

ldconfig
