d05efcc4f2857e2f6345e4207d317d8d9acf11f0
[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         use tools && dobin tools/{convert-from-106,gpg-check-pattern} \
136                 tools/{gpg-zip,gpgconf,gpgsplit,lspgpot,mail-signed-keys,make-dns-cert}
137
138         emake DESTDIR="${D}" -f doc/Makefile uninstall-nobase_dist_docDATA
139         # The help*txt files are read from the datadir by GnuPG directly.
140         # They do not work if compressed or moved!
141         #rm "${ED}"/usr/share/gnupg/help* || die
142
143         dodoc ChangeLog NEWS README THANKS TODO VERSION doc/FAQ doc/DETAILS \
144                 doc/HACKING doc/TRANSLATE doc/OpenPGP doc/KEYSERVER doc/help*
145
146         dosym gpg2 /usr/bin/gpg
147         dosym gpgv2 /usr/bin/gpgv
148         echo ".so man1/gpg2.1" > "${ED}"/usr/share/man/man1/gpg.1
149         echo ".so man1/gpgv2.1" > "${ED}"/usr/share/man/man1/gpgv.1
150
151         dodir /etc/env.d
152         echo "CONFIG_PROTECT=/usr/share/gnupg/qualified.txt" >> "${ED}"/etc/env.d/30gnupg
153
154         if use doc; then
155                 dohtml doc/gnupg.html/* doc/*.png
156         fi
157 }
158
159 pkg_postinst() {
160         elog "If you wish to view images emerge:"
161         elog "media-gfx/xloadimage, media-gfx/xli or any other viewer"
162         elog "Remember to use photo-viewer option in configuration file to activate"
163         elog "the right viewer."
164         elog
165
166         if use smartcard; then
167                 elog "To use your OpenPGP smartcard (or token) with GnuPG you need one of"
168                 use usb && elog " - a CCID-compatible reader, used directly through libusb;"
169                 elog " - sys-apps/pcsc-lite and a compatible reader device;"
170                 elog " - dev-libs/openct and a compatible reader device;"
171                 elog " - a reader device and drivers exporting either PC/SC or CT-API interfaces."
172                 elog ""
173                 elog "General hint: you probably want to try installing sys-apps/pcsc-lite and"
174                 elog "app-crypt/ccid first."
175         fi
176
177         ewarn "Please remember to restart gpg-agent if a different version"
178         ewarn "of the agent is currently used. If you are unsure of the gpg"
179         ewarn "agent you are using please run 'killall gpg-agent',"
180         ewarn "and to start a fresh daemon just run 'gpg-agent --daemon'."
181
182         if [[ -n ${REPLACING_VERSIONS} ]]; then
183                 elog "If upgrading from a version prior than 2.1 you might have to re-import"
184                 elog "secret keys after restarting the gpg-agent as the new version is using"
185                 elog "a new storage mechanism."
186                 elog "You can migrate the keys using gpg --import \$HOME/.gnupg/secring.gpg"
187         fi
188 }