2016-08-19 16:30:22 +01:00
|
|
|
{ stdenv, fetchurl, fetchpatch, pkgconfig, libsepol, pcre
|
2015-08-01 01:00:57 +01:00
|
|
|
, enablePython ? true, swig ? null, python ? null
|
2013-06-24 07:37:33 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert enablePython -> swig != null && python != null;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
2006-08-27 19:05:18 +01:00
|
|
|
|
2011-03-27 05:45:38 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "libselinux-${version}";
|
2015-07-31 20:40:17 +01:00
|
|
|
version = "2.4";
|
2013-02-24 12:25:53 +00:00
|
|
|
inherit (libsepol) se_release se_url;
|
2011-03-27 05:45:38 +01:00
|
|
|
|
2006-08-27 19:05:18 +01:00
|
|
|
src = fetchurl {
|
2013-02-24 12:25:53 +00:00
|
|
|
url = "${se_url}/${se_release}/libselinux-${version}.tar.gz";
|
2015-07-31 20:40:17 +01:00
|
|
|
sha256 = "0yqg73ns97jwjh1iyv0jr5qxb8k5sqq5ywfkx11lzfn5yj8k0126";
|
2006-08-27 19:05:18 +01:00
|
|
|
};
|
|
|
|
|
2017-09-05 22:26:13 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ libsepol pcre ]
|
2013-06-24 07:37:33 +01:00
|
|
|
++ optionals enablePython [ swig python ];
|
2011-03-27 05:45:38 +01:00
|
|
|
|
2016-10-18 21:41:50 +01:00
|
|
|
# Avoid this false warning:
|
|
|
|
# avc_internal.c: In function 'avc_netlink_receive':
|
|
|
|
# avc_internal.c:105:25: error: cast increases required alignment of target type [-Werror=cast-align]
|
|
|
|
# struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
|
|
|
|
# ^
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = "-std=gnu89 -Wno-error=cast-align";
|
2015-07-31 21:02:41 +01:00
|
|
|
|
2016-08-19 16:30:22 +01:00
|
|
|
# Unreleased upstream patch that fixes Python package issue arising
|
|
|
|
# from recent SWIG changes.
|
|
|
|
patches = optional enablePython (fetchpatch {
|
|
|
|
name = "fix-python-swig.patch";
|
|
|
|
url = "https://github.com/SELinuxProject/selinux/commit/a9604c30a5e2f71007d31aa6ba41cf7b95d94822.patch";
|
|
|
|
sha256 = "0mjrclh0sd8m7vq0wvl6pg29ss415j3kn0266v8ixy4fprafagfp";
|
|
|
|
stripLen = 1;
|
|
|
|
});
|
|
|
|
|
2013-06-24 07:37:33 +01:00
|
|
|
postPatch = optionalString enablePython ''
|
|
|
|
sed -i -e 's|\$(LIBDIR)/libsepol.a|${libsepol}/lib/libsepol.a|' src/Makefile
|
2017-11-06 19:18:15 +00:00
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
sed '1i#include <sys/uio.h>' -i src/setrans_client.c
|
2013-06-24 07:37:33 +01:00
|
|
|
'';
|
|
|
|
|
2015-07-31 20:40:17 +01:00
|
|
|
preBuild = ''
|
|
|
|
# Build fails without this precreated
|
|
|
|
mkdir -p $out/include
|
2013-02-24 12:25:53 +00:00
|
|
|
|
2015-07-31 20:40:17 +01:00
|
|
|
makeFlagsArray+=("PREFIX=$out")
|
|
|
|
makeFlagsArray+=("DESTDIR=$out")
|
2013-11-28 08:58:06 +00:00
|
|
|
'';
|
|
|
|
|
2015-07-31 20:40:17 +01:00
|
|
|
installTargets = [ "install" ] ++ optional enablePython "install-pywrap";
|
|
|
|
|
|
|
|
meta = libsepol.meta // {
|
|
|
|
description = "SELinux core library";
|
2013-02-24 12:25:53 +00:00
|
|
|
};
|
2006-08-27 19:05:18 +01:00
|
|
|
}
|