1{ stdenv, fetchurl, writeScript, patchelf, glib, opensc, openssl, openct
2, libtool, pcsclite, zlib
3}:
4
5stdenv.mkDerivation rec {
6 name = "libopensc-dnie-1.4.6-2";
7
8 src = if stdenv.system == "i686-linux" then (fetchurl {
9 url = http://www.dnielectronico.es/descargas/PKCS11_para_Sistemas_Unix/1.4.6.Ubuntu_Jaunty_32/Ubuntu_Jaunty_opensc-dnie_1.4.6-2_i386.deb.tar;
10 sha256 = "1i6r9ahjr0rkcxjfzkg2rrib1rjsjd5raxswvvfiya98q8rlv39i";
11 })
12 else if stdenv.system == "x86_64-linux" then (fetchurl { url = http://www.dnielectronico.es/descargas/PKCS11_para_Sistemas_Unix/1.4.6.Ubuntu_Jaunty_64/Ubuntu_Jaunty_opensc-dnie_1.4.6-2_amd64.deb.tar;
13 sha256 = "1py2bxavdcj0crhk1lwqzjgya5lvyhdfdbr4g04iysj56amxb7f9";
14 })
15 else throw "Architecture not supported";
16
17 buildInputs = [ patchelf glib ];
18
19 builder = writeScript (name + "-builder.sh") ''
20 source $stdenv/setup
21 tar xf $src
22 ar x opensc-dnie*
23 tar xf data.tar.gz
24
25 RPATH=${glib}/lib:${opensc}/lib:${openssl}/lib:${openct}/lib:${libtool}/lib:${pcsclite}/lib:${stdenv.cc.libc}/lib:${zlib}/lib
26
27 for a in "usr/lib/"*.so*; do
28 if ! test -L $a; then
29 patchelf --set-rpath $RPATH $a
30 fi
31 done
32
33 sed -i s,/usr,$out, "usr/lib/pkgconfig/"*
34
35 mkdir -p $out
36 cp -R usr/lib $out
37 cp -R usr/share $out
38 '';
39
40 passthru = {
41 # This will help keeping the proper opensc version when using this libopensc-dnie library
42 inherit opensc;
43 };
44
45 meta = {
46 homepage = http://www.dnielectronico.es/descargas/;
47 description = "Opensc plugin to access the Spanish national ID smartcard";
48 license = stdenv.lib.licenses.unfree;
49 maintainers = with stdenv.lib.maintainers; [viric];
50 platforms = with stdenv.lib.platforms; linux;
51 broken = true;
52 };
53}