You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
4.6 KiB

  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit flag-o-matic systemd toolchain-funcs
  5. MY_P="${P/_/-}"
  6. DESCRIPTION="The GNU Privacy Guard, a GPL OpenPGP implementation"
  7. HOMEPAGE="https://gnupg.org/"
  8. SRC_URI="mirror://gnupg/gnupg/${MY_P}.tar.bz2"
  9. LICENSE="GPL-3"
  10. SLOT="0"
  11. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
  12. IUSE="bzip2 doc ldap nls readline selinux +smartcard ssl tofu tools usb user-socket wks-server"
  13. # Existence of executables is checked during configuration.
  14. DEPEND=">=dev-libs/libassuan-2.5.0
  15. >=dev-libs/libgcrypt-1.8.0
  16. >=dev-libs/libgpg-error-1.29
  17. >=dev-libs/libksba-1.3.4
  18. >=dev-libs/npth-1.2
  19. >=net-misc/curl-7.10
  20. bzip2? ( app-arch/bzip2 )
  21. ldap? ( net-nds/openldap )
  22. readline? ( sys-libs/readline:0= )
  23. smartcard? ( usb? ( virtual/libusb:1 ) )
  24. ssl? ( >=net-libs/gnutls-3.0:0= )
  25. sys-libs/zlib
  26. tofu? ( >=dev-db/sqlite-3.7 )"
  27. RDEPEND="${DEPEND}
  28. app-crypt/pinentry
  29. nls? ( virtual/libintl )
  30. selinux? ( sec-policy/selinux-gpg )
  31. wks-server? ( virtual/mta )"
  32. BDEPEND="virtual/pkgconfig
  33. doc? ( sys-apps/texinfo )
  34. nls? ( sys-devel/gettext )"
  35. S="${WORKDIR}/${MY_P}"
  36. DOCS=(
  37. ChangeLog NEWS README THANKS TODO VERSION
  38. doc/FAQ doc/DETAILS doc/HACKING doc/TRANSLATE doc/OpenPGP doc/KEYSERVER
  39. )
  40. PATCHES=(
  41. "${FILESDIR}/${PN}-2.1.20-gpgscm-Use-shorter-socket-path-lengts-to-improve-tes.patch"
  42. )
  43. src_prepare() {
  44. default
  45. # Inject SSH_AUTH_SOCK into user's sessions after enabling gpg-agent-ssh.socket in systemctl --user mode,
  46. # idea borrowed from libdbus, see
  47. # https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/bus/systemd-user/dbus.socket.in#L6
  48. #
  49. # This cannot be upstreamed, as it requires determining the exact prefix of 'systemctl',
  50. # which in turn requires discovery in Autoconf, something that upstream deeply resents.
  51. sed -e "/DirectoryMode=/a ExecStartPost=-${EPREFIX}/bin/systemctl --user set-environment SSH_AUTH_SOCK=%t/gnupg/S.gpg-agent.ssh" \
  52. -i doc/examples/systemd-user/gpg-agent-ssh.socket || die
  53. }
  54. src_configure() {
  55. local myconf=(
  56. $(use_enable bzip2)
  57. $(use_enable nls)
  58. $(use_enable smartcard scdaemon)
  59. $(use_enable ssl gnutls)
  60. $(use_enable tofu)
  61. $(use smartcard && use_enable usb ccid-driver || echo '--disable-ccid-driver')
  62. $(use_enable wks-server wks-tools)
  63. $(use_with ldap)
  64. $(use_with readline)
  65. --with-mailprog=/usr/libexec/sendmail
  66. --disable-ntbtls
  67. --enable-all-tests
  68. --enable-gpg
  69. --enable-gpgsm
  70. --enable-large-secmem
  71. CC_FOR_BUILD="$(tc-getBUILD_CC)"
  72. GPG_ERROR_CONFIG="${ESYSROOT}/usr/bin/${CHOST}-gpg-error-config"
  73. KSBA_CONFIG="${ESYSROOT}/usr/bin/ksba-config"
  74. LIBASSUAN_CONFIG="${ESYSROOT}/usr/bin/libassuan-config"
  75. LIBGCRYPT_CONFIG="${ESYSROOT}/usr/bin/${CHOST}-libgcrypt-config"
  76. NPTH_CONFIG="${ESYSROOT}/usr/bin/npth-config"
  77. $("${S}/configure" --help | grep -o -- '--without-.*-prefix')
  78. )
  79. if use prefix && use usb; then
  80. # bug #649598
  81. append-cppflags -I"${EPREFIX}/usr/include/libusb-1.0"
  82. fi
  83. #bug 663142
  84. if use user-socket; then
  85. myconf+=( --enable-run-gnupg-user-socket )
  86. fi
  87. # glib fails and picks up clang's internal stdint.h causing weird errors
  88. [[ ${CC} == *clang ]] && \
  89. export gl_cv_absolute_stdint_h=/usr/include/stdint.h
  90. # Hardcode mailprog to /usr/libexec/sendmail even if it does not exist.
  91. # As of GnuPG 2.3, the mailprog substitution is used for the binary called
  92. # by wks-client & wks-server; and if it's autodetected but not not exist at
  93. # build time, then then 'gpg-wks-client --send' functionality will not
  94. # work. This has an unwanted side-effect in stage3 builds: there was a
  95. # [R]DEPEND on virtual/mta, which also brought in virtual/logger, bloating
  96. # the build where the install guide previously make the user chose the
  97. # logger & mta early in the install.
  98. econf "${myconf[@]}"
  99. }
  100. src_compile() {
  101. default
  102. use doc && emake -C doc html
  103. }
  104. src_test() {
  105. #Bug: 638574
  106. use tofu && export TESTFLAGS=--parallel
  107. default
  108. }
  109. src_install() {
  110. default
  111. use tools &&
  112. dobin \
  113. tools/{convert-from-106,gpg-check-pattern} \
  114. tools/{gpg-zip,gpgconf,gpgsplit,lspgpot,mail-signed-keys} \
  115. tools/make-dns-cert
  116. dosym gpg /usr/bin/gpg2
  117. dosym gpgv /usr/bin/gpgv2
  118. echo ".so man1/gpg.1" > "${ED}"/usr/share/man/man1/gpg2.1 || die
  119. echo ".so man1/gpgv.1" > "${ED}"/usr/share/man/man1/gpgv2.1 || die
  120. dodir /etc/env.d
  121. echo "CONFIG_PROTECT=/usr/share/gnupg/qualified.txt" >> "${ED}"/etc/env.d/30gnupg || die
  122. use doc && dodoc doc/gnupg.html/* doc/*.png
  123. systemd_douserunit doc/examples/systemd-user/*.{service,socket}
  124. }