236.2. gnupg-2.5.24
GNU Privacy Guard — OpenPGP encryption and signing
| Version | 2.5.24, release 2 |
| Shelf | security — Security applications: GnuPG and front-ends, password and secret managers, certificates, scanners, forensics and audit |
| Phase | 43_toolkits (Toolkits), 43 of 344 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://gnupg.org/ |
| Build time | 2.3 SBU |
| Installed size | 9.4 MiB in 110 files |
| Recipe | ports/core/security/gnupg/kpkgbuild |
About
GnuPG is the GNU implementation of OpenPGP, and of S/MIME through its X.509 support: gpg encrypts and signs, gpg-agent holds the secret keys and asks for passphrases through pinentry, dirmngr fetches keys and certificate revocation lists, and scdaemon talks to smart cards. In KDOS it is the engine behind gpgme, and so behind Kleopatra, notmuch and podman’s image signatures; pass runs gpg directly.
Sources
gnupg-2.5.24.tar.bz2(8.0 MiB)
sha256bf149d01a2b9fcc0e4589b8ae8697d3d5c557ea48ed95a3fa55dd3b1187e6039
upstream: https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.5.24.tar.bz2
archive copy: sources-4/security--gnupg-2.5.24.tar.bz2
Dependencies
Depends on: libassuan, libgcrypt, libgpg-error, libksba, npth, pinentry, gnutls, sqlite, zlib, bzip2, readline, libusb, tpm2-tss, openldap.
Required by (12): gpgme, kgpg, kleopatra, kmail, libkleo, mailcommon, messagelib, notmuch, pass, qca, qca-qt5, volume_key.
Patches
build.sh applies these; kpkg applies nothing by itself.
import-ecdh-key.patch— gpg: Fix import of unprotected ECDH keys* g10/import.c (build_mode1003_sexp): Skip the correct parameter. --
This bug was introduced when I used the new import code also for classic unprotected keys.
GnuPG-bug-id: 8469 Fixes-commit: 2e6549f5de5307e3e84c1ffa5e762d14266546ba
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/43_toolkits/phase.env && kpkg install gnupg'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/security/gnupg.
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/security/gnupg
echo 'bf149d01a2b9fcc0e4589b8ae8697d3d5c557ea48ed95a3fa55dd3b1187e6039 gnupg-2.5.24.tar.bz2' | 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/gnupg
SRC=$SRC_ROOT/gnupg-2.5.24
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gnupg-2.5.24.tar.bz2 -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/import-ecdh-key.patch"
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/lib/$name \
--enable-card-support \
--enable-ccid-driver \
--enable-sqlite \
--enable-gnutls \
--disable-ntbtls \
--with-tss=intel \
--with-readline \
--with-zlib \
--with-bzip2 \
--enable-ldap \
--disable-nls \
--disable-tests
grep -q '^#define USE_LDAP 1' config.h ||
{ echo "gnupg: OpenLDAP not found at configure" >&2; exit 1; }
make
make DESTDIR=$PKG install
The switches, and why each is set:
--libexecdir=/usr/lib/$name— install the helper programs the other GnuPG programs start, such asscdaemon,keyboxd,dirmngr_ldapandgpg-check-pattern, in/usr/lib/gnupg.--enable-ldap— builddirmngr_ldap, whichdirmngrruns forldap://keyservers and for the certificates and revocation lists an X.509 directory serves, against openldap. configure answers a missinglibldapwith a warning and adirmngrwithout LDAP, sobuild.shchecksconfig.hforUSE_LDAPafter configure and stops the build when it is not defined.--disable-ntbtls— with--enable-gnutls:dirmngr’s TLS, forhkps://keyservers and HTTPS fetches, is GnuTLS. configure prefers NTBTLS, GnuPG’s own TLS library, whenever it finds it, and falls back to GnuTLS; ntbtls is not a port.--with-tss=intel— buildtpm2daemon, which keeps a key in the TPM, against the Intel TPM software stack, tpm2-tss. Left to detect, configure looks for IBM’s stack first, and when it finds neither it builds notpm2daemonand says so only in its summary. Named, a missing tpm2-tss stops configure.--enable-card-support— with--enable-ccid-driver: buildscdaemon, and its own CCID driver, which reaches a USB card reader directly through libusb. Both are upstream’s default, named.--enable-sqlite— build the two parts of GnuPG that keep their data in an SQLite database: the TOFU (trust on first use) trust model andkeyboxd, the key-database daemon. Upstream’s default, named. configure answers a missing SQLite with a warning and builds neither.--with-readline— with--with-zliband--with-bzip2: line editing ingpg’s interactive prompts, and the ZLIB and BZIP2 compression algorithms of OpenPGP messages.--disable-tests— run none of the regression tests inmake check.
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/gnupg, 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 gnupg-2.5.24-2.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/gnupg, and runs the triggers its paths call for.
Contents
Installed programs: addgnupghome, applygnupgdefaults, dirmngr, dirmngr-client, gpg, gpg-agent, gpg-authcode-sign.sh, gpg-card, gpg-connect-agent, gpg-mail-tube, gpg-wks-client, gpg-wks-server, gpgconf, gpgparsemail, gpgsm, gpgsplit, gpgtar, gpgv, kbxutil, watchgnupg.
Installed directories: /usr/lib/gnupg, /usr/share/doc/gnupg, /usr/share/gnupg, /usr/share/licenses/gnupg.
Short descriptions
addgnupghome |
Create .gnupg home directories |
applygnupgdefaults |
Run gpgconf --apply-defaults for all users. |
dirmngr |
GnuPG's network access daemon |
dirmngr-client |
Tool to access the Dirmngr services |
gpg |
OpenPGP encryption and signing tool |
gpg-agent |
Secret key management for GnuPG |
gpg-card |
Administrate Smart Cards |
gpg-connect-agent |
Communicate with a running agent |
gpg-mail-tube |
Encrypt rfc822 formatted mail in a pipeline |
gpg-wks-client |
Client for the Web Key Service |
gpg-wks-server |
Server providing the Web Key Service |
gpgconf |
Modify .gnupg home directories |
gpgparsemail |
Parse a mail message into an annotated format |
gpgsm |
CMS encryption and signing tool |
gpgtar |
Encrypt or sign files into an archive |
gpgv |
Verify OpenPGP signatures |
watchgnupg |
Read and print logs from a socket |
Notes
import-ecdh-key.patch is upstream’s own fix, taken from GnuPG’s repository with its commit header. Without it, importing an unprotected ECDH key builds its private key from the wrong public parameter, so a Curve25519 encryption subkey is stored under a keygrip nothing asks for, and every decryption with that subkey fails with “No secret key”.
pinentry’s dialog is Qt, so gnupg builds in 43_toolkits, and so does everything that reaches it through gpgme; see Build phases are named, banded and closed.