5d4cb3eb323c11c77c014c19acec309b2c6021c7
[gentoo.git] / app-crypt / gnupg / gnupg-2.2.20.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic systemd toolchain-funcs
7
8 MY_P="${P/_/-}"
9
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"
13
14 LICENSE="GPL-3"
15 SLOT="0"
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"
18
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
25         >=dev-libs/npth-1.2
26         >=net-misc/curl-7.10
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= )
32         sys-libs/zlib
33         tofu? ( >=dev-db/sqlite-3.7 )"
34
35 RDEPEND="${DEPEND}
36         app-crypt/pinentry
37         nls? ( virtual/libintl )
38         selinux? ( sec-policy/selinux-gpg )
39         wks-server? ( virtual/mta )"
40
41 BDEPEND="virtual/pkgconfig
42         doc? ( sys-apps/texinfo )
43         nls? ( sys-devel/gettext )"
44
45 S="${WORKDIR}/${MY_P}"
46
47 DOCS=(
48         ChangeLog NEWS README THANKS TODO VERSION
49         doc/FAQ doc/DETAILS doc/HACKING doc/TRANSLATE doc/OpenPGP doc/KEYSERVER
50 )
51
52 PATCHES=(
53         "${FILESDIR}/${PN}-2.1.20-gpgscm-Use-shorter-socket-path-lengts-to-improve-tes.patch"
54 )
55
56 src_prepare() {
57         default
58
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
62         #
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
67 }
68
69 src_configure() {
70         local myconf=()
71
72         if use prefix && use usb; then
73                 # bug #649598
74                 append-cppflags -I"${EPREFIX}/usr/include/libusb-1.0"
75         fi
76
77         if use elibc_SunOS || use elibc_AIX; then
78                 myconf+=( --disable-symcryptrun )
79         else
80                 myconf+=( --enable-symcryptrun )
81         fi
82
83         #bug 663142
84         if use user-socket; then
85                 myconf+=( --enable-run-gnupg-user-socket )
86         fi
87
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
91
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.
100
101         econf \
102                 "${myconf[@]}" \
103                 $(use_enable bzip2) \
104                 $(use_enable nls) \
105                 $(use_enable smartcard scdaemon) \
106                 $(use_enable ssl gnutls) \
107                 $(use_enable tofu) \
108                 $(use smartcard && use_enable usb ccid-driver || echo '--disable-ccid-driver') \
109                 $(use_enable wks-server wks-tools) \
110                 $(use_with ldap) \
111                 $(use_with readline) \
112                 --with-mailprog=/usr/libexec/sendmail \
113                 --disable-ntbtls \
114                 --enable-all-tests \
115                 --enable-gpg \
116                 --enable-gpgsm \
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')
125 }
126
127 src_compile() {
128         default
129
130         use doc && emake -C doc html
131 }
132
133 src_test() {
134         #Bug: 638574
135         use tofu && export TESTFLAGS=--parallel
136         default
137 }
138
139 src_install() {
140         default
141
142         use tools &&
143                 dobin \
144                         tools/{convert-from-106,gpg-check-pattern} \
145                         tools/{gpg-zip,gpgconf,gpgsplit,lspgpot,mail-signed-keys} \
146                         tools/make-dns-cert
147
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
152
153         dodir /etc/env.d
154         echo "CONFIG_PROTECT=/usr/share/gnupg/qualified.txt" >> "${ED}"/etc/env.d/30gnupg || die
155
156         use doc && dodoc doc/gnupg.html/* doc/*.png
157
158         systemd_douserunit doc/examples/systemd-user/*.{service,socket}
159 }
160
161 pkg_postinst() {
162         elog "See https://wiki.gentoo.org/wiki/GnuPG for documentation on gnupg"
163         elog
164         elog "If you wish to use 'gpg-wks-client --send', you must install an MTA!"
165 }