89.11. db-5.3.28
Berkeley DB — the embedded key/value database library, with its C++ binding and db_* utilities
| Version | 5.3.28, release 1 |
| Shelf | database — Database engines, embedded key-value stores, database servers, clients and full-text indexes |
| Phase | 41_system (System), 347 of 1047 in build order |
| Licence | Sleepycat |
| Homepage | https://www.oracle.com/database/technologies/related/berkeleydb.html |
| Build time | 0.6 SBU |
| Installed size | 4.6 MiB in 24 files |
| Recipe | ports/core/database/db/kpkgbuild |
About
Berkeley DB is the embedded key-value database library: B-tree, hash, queue and record-number access methods over files, with transactions, locking and recovery. The port builds the C library libdb, the C++ binding libdb_cxx, the db_185.h compatibility interface and the db_* utilities (db_dump, db_load, db_verify, db_recover and the rest). Among the ports built on it are iproute2, perl-db-file (Perl’s DB_File module) and xastir.
Sources
db-5.3.28.tar.gz(33.5 MiB)
sha256e0a992d740709892e81f9d93f06daf305cf73fb81b545afe72478043172c3628
upstream: https://download.oracle.com/berkeley-db/db-5.3.28.tar.gz
archive copy: sources-1/database--db-5.3.28.tar.gz
Dependencies
Depends on: nothing a recipe names.
Required by (3): iproute2, perl-db-file, xastir.
Patches
build.sh applies these; kpkg applies nothing by itself.
atomic.patch— Renames Berkeley DB’s internal__atomic_compare_exchange()insrc/dbinc/atomic.hto__atomic_compare_exchange_db(). GCC has a built-in function of that name, and a static inline function that redefines it does not compile.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install db'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/database/db.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/database/db
echo 'e0a992d740709892e81f9d93f06daf305cf73fb81b545afe72478043172c3628 db-5.3.28.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/db
SRC=$SRC_ROOT/db-5.3.28
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf db-5.3.28.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/atomic.patch"
export CFLAGS="$CFLAGS -fpermissive"
cd build_unix
../dist/configure --prefix=/usr --libdir=/usr/lib \
--enable-shared \
--disable-static \
--enable-compat185 \
--enable-cxx
make
make DESTDIR=$PKG install_include install_lib install_utilities
install -Dm644 ../LICENSE "$PKG/usr/share/licenses/db/LICENSE"
test -e "$PKG/usr/include/db.h"
test -e "$PKG/usr/lib/libdb.so"
The switches, and why each is set:
-fpermissive— Added toCFLAGSso that configure’s test programs, written with implicit function declarations and implicitint, still compile: the compiler rejects both by default, and a test that fails to compile reads to configure as a missing feature.--enable-compat185— Build the DB 1.85 compatibility interface,dbopen()and<db_185.h>, for programs written to the original BSDdbAPI.--enable-cxx— Build the C++ API,libdb_cxxand<db_cxx.h>.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/db, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf db-5.3.28-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/db, and runs the triggers its paths call for.
Contents
Installed programs: db_archive, db_checkpoint, db_deadlock, db_dump, db_hotbackup, db_load, db_log_verify, db_printlog, db_recover, db_replicate, db_stat, db_tuner, db_upgrade, db_verify.
Installed libraries: libdb-5.3.so, libdb-5.so, libdb.so, libdb_cxx-5.3.so, libdb_cxx-5.so, libdb_cxx.so.
Installed directories: /usr/share/licenses/db.
Notes
configure is run from build_unix, the directory Berkeley DB’s build instructions use, as ../dist/configure.
make install would also run install_docs, which copies Berkeley DB’s whole HTML documentation set into the package. build.sh names the other three install targets instead, install_include, install_lib and install_utilities, installs the licence by hand, and checks that db.h and libdb.so are in the package.