net-misc/sks: Add ebuild
[portage-overlay.git] / net-misc / sks / sks-1.1.4.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-misc/sks/sks-1.1.2.ebuild,v 1.4 2012/02/07 00:34:06 kingtaco Exp $
4
5 EAPI=4
6
7 inherit eutils multilib
8
9 DESCRIPTION="SKS Keyserver"
10 HOMEPAGE="https://bitbucket.org/skskeyserver/sks-keyserver"
11 SRC_URI="https://bitbucket.org/skskeyserver/sks-keyserver/downloads/${P}.tgz"
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="systemd optimize test"
16
17 DEPEND="dev-lang/ocaml
18                 dev-ml/cryptokit
19                 sys-libs/db:5.2"
20 RDEPEND="${DEPEND}"
21
22 pkg_setup() {
23         ebegin "Creating named group and user"
24         enewgroup sks
25         enewuser sks -1 -1 /var/lib/sks sks
26 }
27
28 src_prepare() {
29         cp Makefile.local.unused Makefile.local || die
30         sed -i \
31                 -e "s:^BDBLIB=.*$:BDBLIB=-L/usr/$(get_libdir):g" \
32                 -e "s:^BDBINCLUDE=.*$:BDBINCLUDE=-I/usr/include/db5.2/:g" \
33                 -e "s:^LIBDB=.*$:LIBDB=-ldb-5.2:g" \
34                 -e "s:^PREFIX=.*$:PREFIX=${D}/usr:g" \
35                 -e "s:^MANDIR=.*$:MANDIR=${D}/usr/share/man:g" \
36                 Makefile.local || die
37         sed -i \
38                 -e 's:^CAMLINCLUDE= -I lib -I bdb$:CAMLINCLUDE= -I lib -I bdb -I +cryptokit:g' \
39                 -e 's:-Werror-implicit-function-declaration::g' \
40                 Makefile bdb/Makefile || die
41 }
42
43 src_compile() {
44         emake dep
45         emake -j1 all
46         if use optimize; then
47                 emake all.bc
48         fi
49 }
50
51 src_test() {
52         ./sks unit_test
53 }
54
55 src_install() {
56         if use optimize; then
57                 emake install.bc
58                 dosym /usr/bin/sks.bc usr/bin/sks
59                 dosym /usr/bin/sks_add_mail.bc usr/bin/sks_add_mail
60         else
61                 emake install
62         fi
63
64         dodoc README.md
65
66         newinitd "${FILESDIR}/sks-db.runscript" sks-db
67         newinitd "${FILESDIR}/sks-recon.runscript" sks-recon
68         newconfd "${FILESDIR}/sks-confd" sks
69         use systemd && systemd_dounit "${FILESDIR}/sks-db.service"
70         use systemd && systemd_dounit "${FILESDIR}/sks-recon.service"
71
72         mkdir -p $D/var/lib/sks/web.typical
73         cp $S/sampleConfig/DB_CONFIG $D/var/lib/sks/DB_CONFIG.typical
74         cp $S/sampleConfig/sksconf.typical $D/var/lib/sks/sksconf.typical
75         cp $S/sampleWeb/HTML5/* $D/var/lib/sks/web.typical/
76
77         keepdir /var/lib/sks
78 }
79
80 pkg_postinst() {
81         einfo "To get sks running, first build the database,"
82         einfo "start the databse, import atleast one key, then"
83         einfo "run a cleandb. See the sks man page for more"
84         einfo "information"
85         einfo "Typical DB_CONFIG file and sksconf has been installed"
86         einfo "in /var/lib/sks and can be used as templates by renaming"
87         einfo "to remove the .typical extension. The DB_CONFIG file has"
88         einfo "to be in place before doing the database build, or the BDB"
89         einfo "environment has to be manually cleared from both KDB and PTree"
90         einfo "using db4.8_recover -h and db4.8_checkpoint -1h"
91         einfo "Additionally a sample web interface has been installed as"
92         einfo "web.typical in /var/lib/sks that can be used by renaming it to web"
93         einfo "Important: It is strongly recommended to set up SKS behind a"
94         einfo "reverse proxy. Instructions on properly configuring SKS can be"
95         einfo "found at https://bitbucket.org/skskeyserver/sks-keyserver/wiki/Peering"
96 }
97