# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils
SLOT=0
LICENSE="eID Toolkit Software License"
KEYWORDS="~x86 ~amd64"
DESCRIPTION="Belgian Electronic Identity Card Runtime supplied by the Belgian
Federal Government."
SRC_URI="http://www.belgium.be/zip/beid-2.6.0-20070222.tgz"
RESTRICT="fetch"
HOMEPAGE="http://eid.belgium.be/nl/navigation/12000/index.html"
RDEPEND="
>=dev-util/pkgconfig-0.15.0
>=sys-apps/pcsc-lite-1.2.9
>=x11-libs/qt-3.3.3
>=dev-lang/python-1.5.2
>=dev-libs/openssl-0.9.7
gtk? (x11-libs/wxGTK)
java? (>=virtual/jdk-1.5.0)
>=dev-util/scons-0.97
"
IUSE="java gtk"
S=${WORKDIR}/beid-2.6.0
src_unpack() {
elog "If this package detects a valid java JDK, it will install its java component even if the java use-flag is not set."
elog "If this package detects wxGTK, the beidgui frontend will be built even if the gtk use flag is not set."
unpack ${A}
epatch "${FILESDIR}/${PV}"/disable_qt_detection.patch
epatch "${FILESDIR}/${PV}"/reader.pcsc.c.patch
epatch "${FILESDIR}/${PV}"/list_ccflags.patch
#Replacing all hardcoded references from source code
cd ${S}
sed -i -e "s|/usr/local/bin/beid-tool|/usr/bin/beid-tool|g" \
-e "s|/usr/local/bin/beid-pkcs11-tool|/usr/bin/beid-pkcs11-tool|g"\
-e "s|/usr/local/lib/beidpkcs11.so|/usr/lib/libbeidpkcs11.so|g"\
-e "s|/usr/local/share/beid/beid-pkcs11-register.html|/usr/share/beid/beid-pkcs11-register.html|g"\
-e "s|/usr/local/etc/beidbase.conf|/etc/beid/beidbase.conf|g"\
README
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/eidlibjni/eidlibTest/README
sed -i -e "s|/usr/local/bin/python|/usr/bin/python|g" \
configure
sed -i -e "s|/usr/local/include|${D}usr/include|g"\
-e "s|/usr/local/lib|${D}usr/lib|g"\
-e "s|/usr/local/etc|${D}etc/beid|g"\
-e "s|/usr/local|${D}usr|g"\
SConstruct
sed -i -e "s|/usr/local|${D}usr|g"\
admin/generic.py
sed -i -e "s|/usr/local/lib|${D}usr/lib|g"\
src/newpkcs11/SConscript
sed -i -e "s|/etc/init.d|${D}etc/init.d|g"\
"src/Belpic PCSC Service/SConscript"
sed -i -e "s|/etc/init.d|${D}etc/init.d|g"\
src/beidservicecrl/SConscript
sed -i -e "s|/usr/local/etc/|/etc/|g"\
src/beidcommon/config.cpp
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/newpkcs11/src/libopensc/card-belpic.c
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/newpkcs11/src/tools/opensc-tool.c
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/newpkcs11/src/tools/pkcs11-tool.c
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/newpkcs11/etc/Belgian_eID_PKCS11_java.cfg
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/newpkcs11/etc/beid-pkcs11-register.html
sed -i -e "s|/usr/local/lib|/usr/lib|g"\
src/eidviewer/eidviewerApp.cpp
sed -i -e "s|/usr/local/bin|/usr/bin|g"\
src/eidviewer/beidgui.desktop
sed -i -e "s|/usr/local/bin|/usr/bin|g"\
"src/Belpic PCSC Service/belgium.be-beidpcscd"
sed -i -e "s|/usr/local/bin|/usr/bin|g"\
src/beidservicecrl/belgium.be-beidcrld
sed -i -e "s|/usr/local/share|/usr/share|g"\
src/eidviewer/beidgui.conf
sed -i -e "s|/usr/local/etc|/etc/beid|g"\
src/newpkcs11/config.h
#Patch set QT4 path
sed -i -e "s|/usr/share/qt3|/usr/share/qt4|g"\
-e "s|/usr/lib/qt3/lib64|/usr/lib/qt4|g"\
-e "s|/usr/lib/qt3/lib|/usr/lib/qt4|g"\
SConstruct
}
pkg_nofetch() {
einfo "The Belgian Federal Portal Site prevents automated downloading."
einfo "Please download \"${SRC_URI}\" from:"
einfo "http://www.belgium.be/zip/eid_datacapture_fr.html or"
einfo "http://www.belgium.be/zip/eid_datacapture_nl.html"
einfo "(under the \"Belgian Identity Card Run-time\" and \"Linux\" headers, just above the documentation PDF file.)"
einfo "Place the downloaded file in ${DISTDIR}."
}
src_compile() {
#Using SCons instead of autoconf.
#prefix does not seem to work quite well at this time, so we change all
#references manually.
./configure prefix=${D}usr libdir=${D}usr/lib confdir=${D}etc || die "An error occured while configuring the package."
emake || die "An error occured while building the package."
}
src_install() {
emake install || die "An error occured while installing the package."
# rm ${D}etc/init.d/belgium*
# rm ${D}var -rf
}
pkg_postinst() {
elog "In order for the runtime to work the pcscd daemon MUST be started (/etc/init.d/pcscd start)."
elog "If beidgui complains about an invalid root certificate, enable certificate validation in the options tab."
}