2016-08-01 11:19:48 +03:00
|
|
|
{ stdenv, fetchurl, openssl, expat, libevent, swig, pythonPackages }:
|
2016-07-23 01:25:36 +03:00
|
|
|
|
2016-08-01 11:19:48 +03:00
|
|
|
let
|
|
|
|
inherit (pythonPackages) python;
|
|
|
|
in stdenv.mkDerivation rec {
|
2016-07-23 01:25:36 +03:00
|
|
|
pname = "pyunbound";
|
|
|
|
name = "${pname}-${version}";
|
2018-07-04 17:28:02 +03:00
|
|
|
version = "1.7.3";
|
2016-07-23 01:25:36 +03:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://unbound.net/downloads/unbound-${version}.tar.gz";
|
2018-07-04 17:28:02 +03:00
|
|
|
sha256 = "0bb0p8nbda77ghx20yfl7hqxm9x709223q35465v99i8v4ay27f1";
|
2016-07-23 01:25:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ openssl expat libevent swig python ];
|
|
|
|
|
|
|
|
patchPhase = ''substituteInPlace Makefile.in \
|
|
|
|
--replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
|
|
|
|
--replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
|
|
|
|
'';
|
|
|
|
|
2019-01-03 12:05:50 +03:00
|
|
|
preConfigure = "export PYTHON_VERSION=${python.pythonVersion}";
|
2016-07-23 01:25:36 +03:00
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-ssl=${openssl.dev}"
|
|
|
|
"--with-libexpat=${expat.dev}"
|
|
|
|
"--with-libevent=${libevent.dev}"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--sbindir=\${out}/bin"
|
|
|
|
"--enable-pie"
|
|
|
|
"--enable-relro-now"
|
|
|
|
"--with-pyunbound"
|
|
|
|
"DESTDIR=$out PREFIX="
|
|
|
|
];
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/${python.sitePackages} $out/etc/${pname}
|
|
|
|
cp .libs/_unbound.so .libs/libunbound.so* $out/${python.sitePackages}
|
|
|
|
substituteInPlace _unbound.la \
|
|
|
|
--replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}" \
|
|
|
|
--replace "libdir=\'$PWD/${python.sitePackages}\'" "libdir=\'$out/${python.sitePackages}\'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installFlags = [ "configfile=\${out}/etc/unbound/unbound.conf pyunbound-install lib" ];
|
|
|
|
|
|
|
|
# All we want is the Unbound Python module
|
|
|
|
postInstall = ''
|
2019-01-03 12:05:50 +03:00
|
|
|
# Generate the built in root anchor and root key and store these in a logical place
|
2016-07-23 01:25:36 +03:00
|
|
|
# to be used by tools depending only on the Python module
|
|
|
|
$out/bin/unbound-anchor -l | head -1 > $out/etc/${pname}/root.anchor
|
|
|
|
$out/bin/unbound-anchor -l | tail --lines=+2 - > $out/etc/${pname}/root.key
|
|
|
|
# We don't need anything else
|
|
|
|
rm -fR $out/bin $out/share $out/include $out/etc/unbound
|
2019-01-03 12:05:50 +03:00
|
|
|
patchelf --replace-needed libunbound.so.2 $out/${python.sitePackages}/libunbound.so.2 $out/${python.sitePackages}/_unbound.so
|
2016-07-23 01:25:36 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Python library for Unbound, the validating, recursive, and caching DNS resolver";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
homepage = http://www.unbound.net;
|
|
|
|
maintainers = with maintainers; [ leenaars ];
|
|
|
|
platforms = stdenv.lib.platforms.unix;
|
|
|
|
};
|
|
|
|
}
|