1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit flag-o-matic systemd toolchain-funcs
10 DESCRIPTION="The GNU Privacy Guard, a GPL OpenPGP implementation"
11 HOMEPAGE="http://www.gnupg.org/"
12 SRC_URI="mirror://gnupg/gnupg/${MY_P}.tar.bz2"
16 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
17 IUSE="bzip2 doc ldap nls readline selinux +smartcard ssl tofu tools usb user-socket wks-server"
19 # Existence of executables is checked during configuration.
20 DEPEND="!app-crypt/dirmngr
21 >=dev-libs/libassuan-2.5.0
22 >=dev-libs/libgcrypt-1.7.3
23 >=dev-libs/libgpg-error-1.28
24 >=dev-libs/libksba-1.3.4
27 bzip2? ( app-arch/bzip2 )
28 ldap? ( net-nds/openldap )
29 readline? ( sys-libs/readline:0= )
30 smartcard? ( usb? ( virtual/libusb:1 ) )
31 ssl? ( >=net-libs/gnutls-3.0:0= )
33 tofu? ( >=dev-db/sqlite-3.7 )"
37 nls? ( virtual/libintl )
38 selinux? ( sec-policy/selinux-gpg )
39 wks-server? ( virtual/mta )"
41 BDEPEND="virtual/pkgconfig
42 doc? ( sys-apps/texinfo )
43 nls? ( sys-devel/gettext )"
45 S="${WORKDIR}/${MY_P}"
48 ChangeLog NEWS README THANKS TODO VERSION
49 doc/FAQ doc/DETAILS doc/HACKING doc/TRANSLATE doc/OpenPGP doc/KEYSERVER
53 "${FILESDIR}/${PN}-2.1.20-gpgscm-Use-shorter-socket-path-lengts-to-improve-tes.patch"
59 # Inject SSH_AUTH_SOCK into user's sessions after enabling gpg-agent-ssh.socket in systemctl --user mode,
60 # idea borrowed from libdbus, see
61 # https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/bus/systemd-user/dbus.socket.in#L6
63 # This cannot be upstreamed, as it requires determining the exact prefix of 'systemctl',
64 # which in turn requires discovery in Autoconf, something that upstream deeply resents.
65 sed -e "/DirectoryMode=/a ExecStartPost=-${EPREFIX}/bin/systemctl --user set-environment SSH_AUTH_SOCK=%t/gnupg/S.gpg-agent.ssh" \
66 -i doc/examples/systemd-user/gpg-agent-ssh.socket || die
72 if use prefix && use usb; then
74 append-cppflags -I"${EPREFIX}/usr/include/libusb-1.0"
77 if use elibc_SunOS || use elibc_AIX; then
78 myconf+=( --disable-symcryptrun )
80 myconf+=( --enable-symcryptrun )
84 if use user-socket; then
85 myconf+=( --enable-run-gnupg-user-socket )
88 # glib fails and picks up clang's internal stdint.h causing weird errors
89 [[ ${CC} == *clang ]] && \
90 export gl_cv_absolute_stdint_h=/usr/include/stdint.h
92 # Hardcode mailprog to /usr/libexec/sendmail even if it does not exist.
93 # As of GnuPG 2.3, the mailprog substitution is used for the binary called
94 # by wks-client & wks-server; and if it's autodetected but not not exist at
95 # build time, then then 'gpg-wks-client --send' functionality will not
96 # work. This has an unwanted side-effect in stage3 builds: there was a
97 # [R]DEPEND on virtual/mta, which also brought in virtual/logger, bloating
98 # the build where the install guide previously make the user chose the
99 # logger & mta early in the install.
103 $(use_enable bzip2) \
105 $(use_enable smartcard scdaemon) \
106 $(use_enable ssl gnutls) \
108 $(use smartcard && use_enable usb ccid-driver || echo '--disable-ccid-driver') \
109 $(use_enable wks-server wks-tools) \
111 $(use_with readline) \
112 --with-mailprog=/usr/libexec/sendmail \
117 --enable-large-secmem \
118 CC_FOR_BUILD="$(tc-getBUILD_CC)" \
119 GPG_ERROR_CONFIG="${EROOT}/usr/bin/${CHOST}-gpg-error-config" \
120 KSBA_CONFIG="${EROOT}/usr/bin/ksba-config" \
121 LIBASSUAN_CONFIG="${EROOT}/usr/bin/libassuan-config" \
122 LIBGCRYPT_CONFIG="${EROOT}/usr/bin/${CHOST}-libgcrypt-config" \
123 NPTH_CONFIG="${EROOT}/usr/bin/npth-config" \
124 $("${S}/configure" --help | grep -- '--without-.*-prefix' | sed -e 's/^ *\([^ ]*\) .*/\1/g')
130 use doc && emake -C doc html
135 use tofu && export TESTFLAGS=--parallel
144 tools/{convert-from-106,gpg-check-pattern} \
145 tools/{gpg-zip,gpgconf,gpgsplit,lspgpot,mail-signed-keys} \
148 dosym gpg /usr/bin/gpg2
149 dosym gpgv /usr/bin/gpgv2
150 echo ".so man1/gpg.1" > "${ED}"/usr/share/man/man1/gpg2.1 || die
151 echo ".so man1/gpgv.1" > "${ED}"/usr/share/man/man1/gpgv2.1 || die
154 echo "CONFIG_PROTECT=/usr/share/gnupg/qualified.txt" >> "${ED}"/etc/env.d/30gnupg || die
156 use doc && dodoc doc/gnupg.html/* doc/*.png
158 systemd_douserunit doc/examples/systemd-user/*.{service,socket}
162 elog "See https://wiki.gentoo.org/wiki/GnuPG for documentation on gnupg"
164 elog "If you wish to use 'gpg-wks-client --send', you must install an MTA!"