101.6. gnutls-3.8.13
Libraries and userspace tools which provide a secure layer over a reliable transport layer
| Version | 3.8.13, release 1 |
| Shelf | crypto — Cryptographic libraries, PKCS#11, smartcards and TPM |
| Phase | 41_system (System), 39 of 1047 in build order |
| Licence | LGPL-2.1-or-later AND GPL-3.0-or-later |
| Homepage | https://www.gnutls.org/ |
| Build time | 4.0 SBU |
| Installed size | 8.7 MiB in 1284 files |
| Recipe | ports/core/crypto/gnutls/kpkgbuild |
About
GnuTLS is the TLS library of much of the GNU and GNOME side of the system: glib-networking and so every GIO program that opens a TLS connection, networkmanager, cups, ffmpeg, qemu and libvirt, wireshark, gnupg’s dirmngr, samba, msmtp, chrony’s NTS and weechat among them. Its cryptography is nettle; its certificate parsing is libtasn1; it reaches smart cards, and the system’s trust anchors, through p11-kit. The port also installs certtool, gnutls-cli, gnutls-cli-debug, gnutls-serv, p11tool, ocsptool and psktool.
Sources
gnutls-3.8.13.tar.xz(6.9 MiB)
sha256ffed8ec1bf09c2426d4f14aae377de4753b53e537d685e604e99a8b16ca9c97e
upstream: https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.13.tar.xz
archive copy: sources-1/crypto--gnutls-3.8.13.tar.xz
Dependencies
Depends on: libidn2, libtasn1, libunistring, p11-kit, nettle, zlib, zstd, brotli, tpm2-tss.
Required by (35): aria2, chrony, cups, dino, ffmpeg, filezilla, fwupd, glib-networking, gnupg, gtk-vnc, kodi, libcamera, libfilezilla, libiscsi, libmicrohttpd, libnbd, libnfs, libvirt, msmtp, nbdkit, networkmanager, ntfs-3g, openconnect, qemu, qpdf, remmina, samba, sane-airscan, swtpm, vlc, vte3, weechat, wine, wireshark, wlvncc.
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 gnutls'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/crypto/gnutls.
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/crypto/gnutls
echo 'ffed8ec1bf09c2426d4f14aae377de4753b53e537d685e604e99a8b16ca9c97e gnutls-3.8.13.tar.xz' | 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/gnutls
SRC=$SRC_ROOT/gnutls-3.8.13
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gnutls-3.8.13.tar.xz -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:
gnutls_cv_dlopen_soname_works=yes \
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--with-default-trust-store-pkcs11="pkcs11:" \
--with-zlib=link \
--with-zstd=link \
--with-brotli=link \
--with-tpm2=dlopen \
--without-tpm \
--without-leancrypto \
--disable-libdane \
--enable-ktls
for _l in ESYS MU TCTILDR; do
grep -q "^#define TSS2_${_l}_LIBRARY_SONAME \"libtss2-" config.h
done
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
make DESTDIR=$PKG install
if readelf -d "$PKG/usr/lib/libgnutls.so.30" | grep -q 'NEEDED.*libtss2'; then
exit 1
fi
The switches, and why each is set:
gnutls_cv_dlopen_soname_works=yes— Pre-answer configure’s test of whether a library can bedlopen()ed by its soname. The test dlopens the soname it finds libm linked under, and musl has no separate libm, so on musl it fails; the answer then decides that nothing may be dlopened, and--with-tpm2=dlopenstops configure withUnable to dlopen TPM2.--with-default-trust-store-pkcs11="pkcs11:"— Make the PKCS #11 URIpkcs11:, which matches every token p11-kit offers, the default trust store. p11-kit’s trust module is one of those tokens, and with this switch it is GnuTLS’s only source of trusted roots; see TLS trust anchors.--with-zlib=link,--with-zstd=link,--with-brotli=link— Link the certificate-compression libraries, zlib, zstd and brotli, as ordinary dependencies oflibgnutls.so. With dlopen working, each switch’s default is to dlopen the library at run time instead.--with-tpm2=dlopen— TPM 2.0 keys through the tpm2-tss libraries, whichlibgnutls.soopens the first time a TPM key is used, so a program that never uses one never loads the TPM stack.--without-tpm— No TPM 1.2 keys, which need TrouSerS; it is not in the tree.--without-leancrypto— No leancrypto, the post-quantum algorithm library; configure’s default is the same, and the library is not in the tree.--disable-libdane— Build nolibgnutls-daneand nodanetool. DANE verification needs libunbound, which is not in the tree.--enable-ktls— Build in kernel TLS offload. It stays off at run time unless a system-wide configuration file,/etc/gnutls/config, setsktls = truein its[global]section, and the image ships no such file.
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/gnutls, 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 gnutls-3.8.13-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/gnutls, and runs the triggers its paths call for.
Contents
Installed programs: certtool, gnutls-cli, gnutls-cli-debug, gnutls-serv, ocsptool, p11tool, psktool.
Installed libraries: libgnutls.so, libgnutlsxx.so.
Installed directories: /usr/include/gnutls, /usr/share/doc/gnutls, /usr/share/licenses/gnutls.
Short descriptions
certtool |
GnuTLS certificate tool |
gnutls-cli |
GnuTLS client |
gnutls-cli-debug |
GnuTLS debug client |
gnutls-serv |
GnuTLS server |
ocsptool |
GnuTLS OCSP tool |
p11tool |
GnuTLS PKCS #11 tool |
psktool |
GnuTLS PSK tool |
gnutls.pc |
Transport Security Layer implementation for the GNU system |
Notes
build.sh checks the TPM wiring twice. After configure it checks that config.h defines the sonames of libtss2-esys, libtss2-mu and libtss2-tctildr, which configure records only when it found each library; and after the install it fails if libgnutls.so.30 NEEDs any libtss2 library. Between the two, the sed on the generated libtool adds -Wl,-O1,--as-needed to its shared-library link, so a library named on the link line that the code does not use is not recorded as NEEDED.
GnuTLS reads its system-wide priority policy from /etc/gnutls/config, a path compiled in from --sysconfdir=/etc; the image ships none, so every program uses the library’s NORMAL priorities.