summaryrefslogtreecommitdiff
blob: f98f5fea4e40e03adca11d29dada7e9fce3a8019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils flag-o-matic toolchain
MY_P=${P/_p/-}
MY_P2=${P/_p/.}

DESCRIPTION="The OpenCA Project is a collaborative effort to develop a robust, full-featured and Open Source out-of-the-box Certification Authority implementing the most used protocols with full-strength cryptography world-wide."
HOMEPAGE="http://www.openca.org/"
SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~x86"
IUSE="uclibc doc dbm mysql postgres ldap vhosts"

RDEPEND="virtual/libc"
DEPEND="${RDEPEND}
	!dev-perl/OpenCA-X509
	!dev-perl/OpenCA-REQ
	!dev-perl/OpenCA-OpenSSL
	!dev-perl/OpenCA-CRL
	>=dev-libs/openssl-0.9.7
	net-www/apache
	>=perl-core/MIME-Base64-2.20
	>=dev-perl/Digest-HMAC-1.01
	>=dev-perl/Digest-SHA1-2.02
	>=perl-core/Digest-MD5-2.24
	>=dev-perl/libintl-perl-1.10
	>=dev-perl/IO-stringy-2.108
	>=dev-perl/MIME-Lite-3.01
	>=dev-perl/MIME-tools-5.411
	>=dev-perl/MailTools-1.58
	>=dev-perl/Parse-RecDescent-1.94
	>=dev-perl/X500-DN-0.28
	>=dev-perl/XML-Twig-3.09
	>=dev-perl/CGI-Session-3.95
	>=dev-perl/net-server-0.86
	>=dev-perl/Convert-ASN1-0.18
	dbm? ( perl-core/DB_File )
	mysql? ( dev-perl/DBD-mysql )
	postgres? ( dev-perl/DBD-Pg )
	!mysql? ( !postgres? ( perl-core/DB_File ) )
	ldap? ( net-nds/openldap
		>=dev-perl/perl-ldap-0.28
		>=dev-perl/IO-Socket-SSL-0.92
		>=dev-perl/URI-1.23
		)
	sasl? ( >=dev-perl/Authen-SASL-2.04 )
	!uclibc? ( sys-devel/bc )"

S=${WORKDIR}/${MY_P2}

src_unpack() {
	unpack ${A}
	cd ${S}
	if ! use ldap ; then
		epatch ${FILESDIR}/openca-0.9.2_noldap.patch
	fi

	case $( gcc-version ) in
		3.4 | 3.3 | 3.2 )
			filter-flags -fprefetch-loop-arrays -freduce-all-givs -funroll-loops
		;;
	esac
	econf
}

src_compile() {
	cd ${S}
	einfo "Compiling ${P}"
	myconf="--with-openca-user=openca \
		--with-openca-group=openca \
		--with-htdocs-fs-prefix=/var/www/localhost/htdocs/openca \
		--with-cgi-fs-prefix=/var/www/localhost/cgi-bin \
		--with-etc-prefix=/etc/openca \
		--with-var-prefix=/var/openca \
		--with-lib-prefix=/usr/lib/openca \
		--with-httpd-user=apache \
		--with-httpd-group=apache \
		--disable-external-modules"
	if ! use vhosts ; then
		myconf="${myconf} --with-htdocs-url-prefix=/openca"
	fi
	if use ldap; then
		myconf="${myconf} --with-ldap-port=389 \
			--with-ldap-root='cn=Manager,o=OpenCA,c=IT' \
			--with-ldap-root-pwd='openca'"
	else
		myconf="${myconf} --disable-ldap"
	fi
	if ! use mysql && ! use postgres || use dbm; then
		myconf="${myconf} --enable-db"
	else
		myconf="${myconf} --disable-db"
	fi
	if use mysql; then
	        einfo "Setting random user/password details for the mysql database"
	        local dbpass="${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
	        sed -e "s/@dbpass@/${dbpass}/g" \
	                ${FILESDIR}/mysql-setup.sql.in > ${T}/mysql-setup.sql

		myconf="${myconf}  --enable-dbi \
			--with-db-type=mysql \
			--with-db-name=openca \
			--with-db-host=localhost \
			--with-db-port=3306 \
			--with-db-user=openca \
			--with-db-passwd='${dbpass}'"
	fi
	if use postgres; then
	        einfo "Setting random user/password details for the postgres database"
	        local dbpass="${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
#	        sed -e "s/@dbpass@/${dbpass}/g" \
#	                ${FILESDIR}/postgres-setup.sql.in > ${T}/posgres-setup.sql

		myconf="${myconf}  --enable-dbi \
			--with-db-type=Pg \
			--with-db-name=openca \
			--with-db-host=localhost \
			--with-db-port=5432 \
			--with-db-user=openca \
			--with-db-passwd='${dbpass}'"
	fi

	econf ${myconf}
	emake || die
}

src_install() {
	cd ${S}
	make install-online install-ca DESTDIR=${D} || die

	dodir /var/openca/tmp
	keepdir /var/openca/tmp
	dosym /var/openca/log /var/log/openca
	keepdir /var/openca/log
	dodir /var/openca/log/xml
	keepdir /var/openca/log/xml

	dodoc CHANGES* LICENSE README
	dodoc docs/*.txt
	doman docs/man3/*.3
	if use doc; then
		dohtml -r docs/guide
		dohtml -r docs/howto
		docinto shared
		dodocs docs/shared/*.txt
	fi
	if use ldap; then
		docinto openldap
		dodocs contrib/openldap/openca.schema
	fi
	if ! use mysql && ! use postgres || use dbm ; then
		dodir /var/openca/db
		keepdir /var/openca/db
	fi
	if use vhosts; then
		insinto /etc/apache2/conf/vhosts
		#***more to come***
	fi
	dosym /etc/openca/openca_rc /etc/init.d/openca
}

pkg_setup() {
	enewgroup openca
	enewuser openca -1 -1 /dev/null openca
}

pkg_postinst() {
	einfo "Please check file '/etc/openca/config.xml'"
	einfo "Then run '/etc/openca/configure_etc.sh' script"
}