app-crypt/gnupg: improvements
[portage-overlay.git] / app-crypt / gnupg / gnupg-9999.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils flag-o-matic toolchain-funcs
8
9 if [[ ${PV} == *9999* ]]; then
10         inherit autotools git-2
11 fi
12
13 DESCRIPTION="The GNU Privacy Guard, a GPL OpenPGP implementation"
14 HOMEPAGE="http://www.gnupg.org/"
15 LICENSE="GPL-3"
16
17 if [[ ${PV} != *9999* ]]; then
18         MY_P="${P/_/-}"
19         SRC_URI="mirror://gnupg/gnupg/${MY_P}.tar.bz2"
20         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s39    0 ~sh ~sparc ~x86"
21 else
22         KEYWORDS=""
23         WANT_AUTOMAKE=1.14
24         EGIT_REPO_URI="git://git.gnupg.org/${PN}.git"
25 fi
26
27 SLOT="0"
28 KEYWORDS=""
29 IUSE="bzip2 doc +gnutls ldap nls readline selinux smartcard +system-cert-store tofu tools usb"
30
31 COMMON_DEPEND_LIBS="
32         >=dev-libs/npth-1.2
33         >=dev-libs/libassuan-2.4.3
34         >=dev-libs/libgcrypt-1.7.3
35         >=dev-libs/libgpg-error-1.24
36         >=dev-libs/libksba-1.3.4
37         >=net-misc/curl-7.10
38         gnutls? ( >=net-libs/gnutls-3.0:0= )
39         sys-libs/zlib
40         ldap? ( net-nds/openldap )
41         bzip2? ( app-arch/bzip2 )
42         readline? ( sys-libs/readline:0= )
43         smartcard? ( usb? ( virtual/libusb:0 ) )
44         tofu? ( >=dev-db/sqlite-3.7 )
45         "
46 COMMON_DEPEND_BINS="app-crypt/pinentry
47                    !app-crypt/dirmngr"
48
49 # Existence of executables is checked during configuration.
50 DEPEND="${COMMON_DEPEND_LIBS}
51         ${COMMON_DEPEND_BINS}
52         nls? ( sys-devel/gettext )
53         doc? ( sys-apps/texinfo )"
54
55 RDEPEND="${COMMON_DEPEND_LIBS}
56         ${COMMON_DEPEND_BINS}
57         selinux? ( sec-policy/selinux-gpg )
58         nls? ( virtual/libintl )"
59
60 S="${WORKDIR}/${MY_P}"
61
62 src_prepare() {
63         default
64         if [[ ${PV} == *9999* ]]; then
65                 epatch "${FILESDIR}"/${P}-g10-tofu.c-Specify-file-access-mode.patch \
66                 "${FILESDIR}"/${P}-tests-pkits-Makefile.am-Remove-failing-tests.patch
67         fi
68
69         epatch_user
70         if [[ ${PV} == *9999* ]]; then
71                 autoreconf || die
72                 ./autogen.sh || die
73         fi
74 }
75
76 src_configure() {
77         local myconf=()
78
79         if use smartcard; then
80                 myconf+=(
81                         --enable-scdaemon
82                         $(use_enable usb ccid-driver)
83                 )
84         else
85                 myconf+=( --disable-scdaemon )
86         fi
87
88         if use elibc_SunOS || use elibc_AIX; then
89                 myconf+=( --disable-symcryptrun )
90         else
91                 myconf+=( --enable-symcryptrun )
92         fi
93
94         # glib fails and picks up clang's internal stdint.h causing weird errors
95         [[ ${CC} == *clang ]] && \
96                 export gl_cv_absolute_stdint_h=/usr/include/stdint.h
97
98         maintainer_mode=""
99         
100         if [[ ${PV} == *9999* ]]; then
101                 maintainer_mode+="--enable-maintainer-mode "
102         fi
103
104         econf \
105                 ${maintainer_mode} \
106                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
107                 --enable-gpg \
108                 --enable-gpgsm \
109                 --enable-large-secmem \
110                 --without-adns \
111                 "${myconf[@]}" \
112                 $(use_enable bzip2) \
113                 $(use_enable gnutls) \
114                 $(use_with ldap) \
115                 $(use_enable nls) \
116                 $(use_with readline) \
117                 $(use_enable tofu) \
118                 $(use_enable tools) \
119                 $(use_enable tools wks-tools) \
120                 CC_FOR_BUILD="$(tc-getBUILD_CC)"
121 }
122
123 src_compile() {
124         default
125
126         if use doc; then
127                 cd doc
128                 emake html
129         fi
130 }
131
132 src_install() {
133         default
134
135         emake DESTDIR="${D}" -f doc/Makefile uninstall-nobase_dist_docDATA
136
137         dodoc ChangeLog NEWS README THANKS TODO VERSION doc/FAQ doc/DETAILS \
138                 doc/HACKING doc/TRANSLATE doc/OpenPGP doc/KEYSERVER doc/help*
139
140         dosym gpg2 /usr/bin/gpg
141         dosym gpgv2 /usr/bin/gpgv
142         echo ".so man1/gpg2.1" > "${ED}"/usr/share/man/man1/gpg.1
143         echo ".so man1/gpgv2.1" > "${ED}"/usr/share/man/man1/gpgv.1
144
145         dodir /etc/env.d
146         echo "CONFIG_PROTECT=/usr/share/gnupg/qualified.txt" >> "${ED}"/etc/env.d/30gnupg
147
148         if use doc; then
149                 dohtml doc/gnupg.html/* doc/*.png
150         fi
151 }
152
153 pkg_postinst() {
154         if [[ -n ${REPLACING_VERSIONS} ]]; then
155                 elog "If upgrading from a version prior than 2.1 you might have to re-import"
156                 elog "secret keys after restarting the gpg-agent as the new version is using"
157                 elog "a new storage mechanism."
158                 elog "You can migrate the keys using gpg --import \$HOME/.gnupg/secring.gpg"
159         fi
160 }