box.matto.nl
Enjoying Open Source Software

Compile GnuPG 2.3.4 on FreeBSD

FreeBSD 14 comes with GnuPG 2.4.3, which results in problems when using Emacs with GnuPG. These problems concern both the encryption of files as the encryption of email messages. Decrypting isn't a problem.

This is a known problem, and the general advise is to install an older version of GnuPG.

To use Emacs with GnuPG I removed the GnuPG package and related packages, compiled GnuPG 2.3.4 from source, and installed it using GNU Stow.

GNU Stow

GNU Stow helps to manage the installation and removal of self compiled software. Install GNU Stow using the FreeBSD package manager.

pkg install stow

Stow works also great for the management of the dotfiles in your home directory.

Dependencies

GnuPG requires the installation of several dependencies before it can be compiled and installed.

To prevent guessing which versions to install, I took the version numbers as installed on a FreeBSD 13.1 jail and downloaded the following tar-balls:

libassuan-2.5.5.tar.bz2
libgcrypt-1.9.4.tar.bz2
libgpg-error-1.45.tar.bz2
libksba-1.6.0.tar.bz2
pinentry-1.2.1.tar.bz2

Prepare Stow directory tree

Create for each tar-ball a corresponding directory under /usr/local/stow:

/usr/local/stow
|-- gnupg
|-- libassuan
|-- libgcrypt
|-- libgpg-error
|-- libksba
`-- pinentry

Compiling

All the dependencies are compiled in the usual way:

./configure, make and make install.

When configuring, use the Stow sub-directories as prefix.

For example, compiling libgpg-error:

./configure --prefix=/usr/local/stow/libgpg-error
make
make install # as root

After make install, the skeleton of the directory /usr/local/stow/libgpg-error looks like this:

/usr/local/stow/libgpg-error
|-- bin
|-- include
|-- lib
|   `-- pkgconfig
`-- share
    |-- aclocal
    |-- common-lisp
    |-- info
    |-- libgpg-error
    `-- man

This view shows only the upper directories. The tree can go deeper, and is populated with all the files.

Install using Stow

As root, go to /usr/local/stow and run stow for each application.

Because the installation of info-files throws errors, use the flag --ignore=dir.

For example:

stow --ignore=dir libgpg-error

This creates symlinks, e.g., from /usr/local/stow/libgpg-error/bin/gpg-error to /usr/local/bin/gpg-error, and so on.

To reverse this, issue stow with the flag -D, for example:

stow -D --ignore=dir libgpg-error

This removes all the symlinks.

Use this to install and uninstall your self compiled software.

Install the software on similar systems by just transferring the stow subdirectory and run the stow command there.

Pinentry

The configuration of pinentry shows two options for Emacs. To be sure, I added them both:

./configure --prefix=/usr/local/stow/pinentry --enable-pinentry-emacs --enable-inside-emacs

Order

Start with the compilation and installation of libgpg-error, including the last step with stow.

GnuPG

To compile GnuPG, the location of iconv must be added to the configuration:

./configure --prefix=/usr/local/stow/gnupg --with-libiconv-prefix=/usr/local

Encryption

After building the dependencies and GnuPG, Emacs encrypts both files and emails :)

Make encryption great again!

Tags:

⇽ Prose linting with Vale and Flycheck in Emacs on FreeBSD Small Gopher HOW-TO ⇾