net-misc/sks: fix path in sks_build.sh
[portage-overlay.git] / net-misc / sks / sks-9999.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 mercurial
8
9 DESCRIPTION="SKS Keyserver"
10 HOMEPAGE="https://bitbucket.org/skskeyserver/sks-keyserver"
11 if [[ ${PV} == "9999" ]]; then
12 EHG_REPO_URI="https://bitbucket.org/skskeyserver/sks-keyserver"
13 EHG_REVISION="tip"
14 else
15 SRC_URI="https://bitbucket.org/skskeyserver/sks-keyserver/downloads/${P}.tgz"
16 fi;
17 LICENSE="GPL-2"
18 SLOT="0"
19 KEYWORDS="~amd64 ~x86"
20 IUSE="systemd optimize test"
21
22 DEPEND="dev-lang/ocaml
23                 dev-ml/cryptokit
24                 sys-libs/db:5.2"
25 RDEPEND="${DEPEND}"
26
27 pkg_setup() {
28         ebegin "Creating named group and user"
29         enewgroup sks
30         enewuser sks -1 -1 /var/lib/sks sks
31 }
32
33 src_prepare() {
34         cp Makefile.local.unused Makefile.local || die
35         sed -i \
36                 -e "s:^BDBLIB=.*$:BDBLIB=-L/usr/$(get_libdir):g" \
37                 -e "s:^BDBINCLUDE=.*$:BDBINCLUDE=-I/usr/include/db5.2/:g" \
38                 -e "s:^LIBDB=.*$:LIBDB=-ldb-5.2:g" \
39                 -e "s:^PREFIX=.*$:PREFIX=${D}/usr:g" \
40                 -e "s:^MANDIR=.*$:MANDIR=${D}/usr/share/man:g" \
41                 Makefile.local || die
42         sed -i \
43                 -e 's:^CAMLINCLUDE= -I lib -I bdb$:CAMLINCLUDE= -I lib -I bdb -I +cryptokit:g' \
44                 -e 's:-Werror-implicit-function-declaration::g' \
45                 Makefile bdb/Makefile || die
46         sed -i \
47                 -e 's:/usr/sbin/sks:/usr/bin/sks:g' \
48                 sks_build.sh || die
49 }
50
51 src_compile() {
52         emake dep
53         emake -j1 all
54         if use optimize; then
55                 emake all.bc
56         fi
57 }
58
59 src_test() {
60         ./sks unit_test
61 }
62
63 src_install() {
64         if use optimize; then
65                 emake install.bc
66                 dosym /usr/bin/sks.bc usr/bin/sks
67                 dosym /usr/bin/sks_add_mail.bc usr/bin/sks_add_mail
68         else
69                 emake install
70         fi
71
72         dodoc README.md
73
74         newinitd "${FILESDIR}/sks-db.runscript" sks-db
75         newinitd "${FILESDIR}/sks-recon.runscript" sks-recon
76         newconfd "${FILESDIR}/sks-confd" sks
77         use systemd && systemd_dounit "${FILESDIR}/sks-db.service"
78         use systemd && systemd_dounit "${FILESDIR}/sks-recon.service"
79
80         mkdir -p $D/var/lib/sks/web.typical
81         cp $S/sampleConfig/DB_CONFIG $D/var/lib/sks/DB_CONFIG.typical
82         cp $S/sampleConfig/sksconf.typical $D/var/lib/sks/sksconf.typical
83         cp $S/sampleWeb/HTML5/* $D/var/lib/sks/web.typical/
84
85         keepdir /var/lib/sks
86 }
87
88 pkg_postinst() {
89         einfo "To get sks running, first build the database,"
90         einfo "start the databse, import atleast one key, then"
91         einfo "run a cleandb. See the sks man page for more"
92         einfo "information"
93         einfo "Typical DB_CONFIG file and sksconf has been installed"
94         einfo "in /var/lib/sks and can be used as templates by renaming"
95         einfo "to remove the .typical extension. The DB_CONFIG file has"
96         einfo "to be in place before doing the database build, or the BDB"
97         einfo "environment has to be manually cleared from both KDB and PTree."
98         einfo "The same applies if you are upgrading to this version with an existing KDB/Ptree,"
99         einfo "using another version of BDB than 5.2; you need to clear the environment"
100         einfo "using e.g. db4.6_recover -h . and db4.6_checkpoint -1h . in both KDB and PTree"
101         einfo "Additionally a sample web interface has been installed as"
102         einfo "web.typical in /var/lib/sks that can be used by renaming it to web"
103         einfo "Important: It is strongly recommended to set up SKS behind a"
104         einfo "reverse proxy. Instructions on properly configuring SKS can be"
105         einfo "found at https://bitbucket.org/skskeyserver/sks-keyserver/wiki/Peering"
106         einfo "If you want SKS to update its KeyDB statistics more often you can add a crontab entry like:"
107         einfo "25 * * * * pkill -USR2 sks || exit 1"
108 }
109