89.6. lmdb-0.9.36
Lightning Memory-Mapped Database: an embedded B+tree key-value store, and its mdb_* tools
| Version | 0.9.36, release 1 |
| Shelf | database — Database engines, embedded key-value stores, database servers, clients and full-text indexes |
| Phase | 41_system (System), 338 of 1047 in build order |
| Licence | OLDAP-2.8 |
| Homepage | https://www.symas.com/mdb |
| Build time | 0.1 SBU |
| Installed size | 267.1 KiB in 15 files |
| Recipe | ports/core/database/lmdb/kpkgbuild |
About
LMDB, the Lightning Memory-Mapped Database, is an embedded key-value store from the OpenLDAP project: a copy-on-write B+tree in one memory-mapped file, with ACID transactions, many readers alongside one writer, and reads that copy nothing. nheko keeps its Matrix state in it, and baloo, KDE’s file indexer, its index; lmdbxx is the C++ wrapper nheko uses. The port installs liblmdb.so, lmdb.h, the mdb_stat, mdb_copy, mdb_dump and mdb_load tools with their manual pages, and a pkg-config file.
Sources
lmdb-0.9.36.tar.gz(146.7 KiB)
sha25690a595ea500074af61b213464452d8d212405261094667a686357467ae7b57b9
upstream: https://git.openldap.org/openldap/openldap/-/archive/LMDB_0.9.36/openldap-LMDB_0.9.36.tar.gz
archive copy: sources-1/database--lmdb-0.9.36.tar.gz
Dependencies
Depends on: make.
Required by (3): baloo, lmdbxx, nheko.
Patches
build.sh applies these; kpkg applies nothing by itself.
lmdb-make.patch— Makes the Makefile build a versioned shared library:liblmdb.so.0.0.0with the sonameliblmdb.so.0, and the symlinksliblmdb.so.0andliblmdb.soto it. Upstream buildsliblmdb.sowith no soname and a staticliblmdb.a, and links its tools against the static one; with the patch no static library is installed, the tools link the shared library, andmake installcopies withcp -aso the symlinks stay symlinks.
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 lmdb'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/database/lmdb.
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/lmdb
echo '90a595ea500074af61b213464452d8d212405261094667a686357467ae7b57b9 lmdb-0.9.36.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/lmdb
SRC=$SRC_ROOT/lmdb-0.9.36
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lmdb-0.9.36.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:
cd libraries/liblmdb
patch -p1 -i "$PORT_SRC/lmdb-make.patch"
make CC="$CC" OPT="-O2" XCFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
make DESTDIR="$PKG" prefix=/usr install
install -d "$PKG/usr/lib/pkgconfig"
cat > "$PKG/usr/lib/pkgconfig/lmdb.pc" <<PC
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: liblmdb
Description: Lightning Memory-mapped key-value database
URL: https://www.symas.com/mdb
Version: $version
Libs: -L\${libdir} -llmdb
Cflags: -I\${includedir}
PC
chmod 644 "$PKG/usr/lib/pkgconfig/lmdb.pc"
install -Dm644 "$SRC/libraries/liblmdb/LICENSE" "$PKG/usr/share/licenses/$name/LICENSE"
install -Dm644 "$SRC/libraries/liblmdb/COPYRIGHT" "$PKG/usr/share/licenses/$name/COPYRIGHT"
The switches, and why each is set:
CC="$CC"— The tree’s compiler; the Makefile namesgcc.OPT="-O2"— Replace the Makefile’sOPT,-O2 -g, so the library is built without debug information.XCFLAGS="$CFLAGS"— Add the tree’sCFLAGS: the Makefile builds itsCFLAGSfromTHREADS,OPT, its warning flags andXCFLAGS, so a plainCFLAGSgiven to make would replace the-pthreadand warnings too.LDFLAGS="$LDFLAGS"— The tree’s link flags, on every link. The Makefile sets noLDFLAGSof its own, so this names on the command line what make would otherwise take from the environment.prefix=/usr— The Makefile’s install prefix,/usr/localby default.
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/lmdb, 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 lmdb-0.9.36-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/lmdb, and runs the triggers its paths call for.
Contents
Installed programs: mdb_copy, mdb_dump, mdb_load, mdb_stat.
Installed libraries: liblmdb.so.
Installed directories: /usr/share/licenses/lmdb.
Short descriptions
mdb_copy |
LMDB environment copy tool |
mdb_dump |
LMDB environment export tool |
mdb_load |
LMDB environment import tool |
mdb_stat |
LMDB environment status tool |
lmdb.pc |
Lightning Memory-mapped key-value database |
Notes
The library is in libraries/liblmdb of an OpenLDAP source archive cut at the LMDB_<version> tag, so build.sh works from that directory. Upstream ships no pkg-config file; build.sh writes lmdb.pc with the recipe’s version, for consumers that find LMDB through pkg-config lmdb.