summaryrefslogtreecommitdiff
blob: 00db3fa4a4111cce3d2d85d87e608b07f932c94c (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-libs/osptoolkit/osptoolkit-3.4.2.ebuild,v 1.2 2009/04/20 17:06:55 volkmar Exp $

EAPI="2"

inherit eutils multilib toolchain-funcs

S_DATE="20071227"

DESCRIPTION="Open Settlement Protocol development kit"
HOMEPAGE="http://www.transnexus.com/OSP%20Toolkit/OSP%20Toolkit%20Documents/OSP%20Toolkit%20Documents.htm"
SRC_URI="mirror://sourceforge/osp-toolkit/OSPToolkit-${PV}.tar.gz
	mirror://sourceforge/osp-toolkit/${PN}_${PV}-1.diff.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~x86"
IUSE=""

RDEPEND="dev-libs/openssl"
DEPEND="${RDEPEND}"

S="${WORKDIR}"/TK-${PV//./_}-${S_DATE}

# TODO:
# generate a shared lib

# NOTES:
# debian patch is used atm but will surely not for further versions
# osptest isn't a test that can be used for src_test, it's part of the toolkit

src_prepare() {
	# applying debian patches
	epatch "${WORKDIR}"/${PN}_${PV}-1.diff

	# change enroll path from debian paches
	sed -i -e "s:^\(ospdir\).*:\1=/usr/lib/${PN}:" \
		bin/enroll.sh || die "patching bin/enroll.sh failed"

	# remove -O and use users CFLAGS, see bug 241034
	sed -i -e "s/ -O//" -e "s/^CFLAGS =/CFLAGS +=/" src/Makefile test/Makefile \
		enroll/Makefile || die "patching Makefiles failed"

	# use users LDFLAGS
	sed -i -e "s:LFLAGS:LDFLAGS:" test/Makefile \
		|| die "patching test/Makefile failed"
	sed -i -e "s:\(\$(LIBS\):\$(LDFLAGS) \1:" enroll/Makefile \
		|| die "patching enroll/Makefile failed"

	# change lib dir to $(get_libdir)
	sed -i -e "s:\$(INSTALL_PATH)/lib:\$(INSTALL_PATH)/$(get_libdir):" \
		src/Makefile || die "patching src/Makefile failed"

	# test.cfg is located in /etc/${PN}/test.cfg
	sed -i -e \
		"s:\(^#define CONFIG_FILENAME.*\"\).*\(test.cfg\"\):\1/etc/${PN}/\2:" \
		test/test_app.c || die "patching test/test_app.c failed"

	# configure enroll.sh
	sed -i -e "s:^\(OPENSSL_CONF\).*:\1=/etc/ssl/openssl.cnf:" \
		-e "s:^\(RANDFILE\).*:\1=\/etc/${PN}/.rnd:" \
		bin/enroll.sh || die "patching bin/enroll.sh failed"
}

src_compile() {
	local my_cc=$(tc-getCC)

	emake -C src CC="${my_cc}" build || die "emake libosp failed"
	emake -C enroll CC="${my_cc}" linux || die "emake enroll failed"
	# line above doesn't build tests but osptest (see NOTES)
	emake -C test CC="${my_cc}" linux || die "emake test failed"
}

src_install() {
	local ospdir="/usr/$(get_libdir)/${PN}"

	emake -C src INSTALL_PATH="${D}"/usr install || die "emake install failed"

	insinto /etc/${PN}
	doins bin/test.cfg bin/.rnd || die "doins failed"

	# install enroll and enroll.sh in lib dir to prevent executing them
	dodir ${ospdir}
	exeinto ${ospdir}
	doexe bin/enroll bin/enroll.sh || die "doexe failed"

	# use the symlink to execute enroll.sh
	dosym ${ospdir}/enroll.sh /usr/bin/ospenroll || die "dosym failed"

	newbin bin/test_app osptest || die "newbin failed"

	dodoc README.txt RELNOTES.txt || die "dodoc failed"
}

pkg_postinst() {
	elog "OSP test application is now available with 'osptest' command"
	elog "OSP enroll application is now available with 'ospenroll' command"
}