at 15.09-beta 63 lines 2.0 kB view raw
1{ stdenv, fetchurl, pythonPackages, gettext 2, setools, libsepol, libselinux, libcap_ng, libsemanage, sepolgen 3}: 4 5stdenv.mkDerivation rec { 6 name = "policycoreutils-${version}"; 7 version = "2.4"; 8 inherit (libsepol) se_release se_url; 9 10 src = fetchurl { 11 url = "${se_url}/${se_release}/policycoreutils-${version}.tar.gz"; 12 sha256 = "0y9l9k60iy21hj0lcvfdfxs1fxydg6d3pxp9rhy7hwr4y5vgh6dq"; 13 }; 14 15 postPatch = '' 16 # Fix references to libsepol.a 17 find . -name Makefile -exec sed -i 's,[^ ]*/libsepol.a,${libsepol}/lib/libsepol.a,g' {} \; 18 19 # Fix install references 20 substituteInPlace po/Makefile --replace /usr/bin/install install 21 22 # Fix references to /usr/share 23 grep -r '/usr/share' | awk -F: '{print $1}' | xargs sed -i "s,\(\$(DESTDIR)\)*/usr/share,$out/share,g" 24 25 # Fix sepolicy install 26 sed -i "s,\(setup.py install\).*,\1 --prefix=$out,g" sepolicy/Makefile 27 ''; 28 29 nativeBuildInputs = [ pythonPackages.python gettext ]; 30 buildInputs = [ setools libsepol libselinux libcap_ng libsemanage ]; 31 pythonPath = [ libselinux sepolgen ]; 32 33 preBuild = '' 34 makeFlagsArray+=("PREFIX=$out") 35 makeFlagsArray+=("DESTDIR=$out") 36 ''; 37 38 # Creation of the system-config-selinux directory is broken 39 preInstall = '' 40 mkdir -p $out/share/system-config-selinux 41 ''; 42 43 # Fix the python scripts to include paths to libraries 44 # NOTE: We are not using wrapPythonPrograms or makeWrapper as these scripts 45 # purge the environment as a security measure 46 postInstall = '' 47 grep -r '#!.*python' $out/bin | awk -F: '{print $1}' | xargs sed -i "1a \ 48 import sys; \ 49 sys.path.append('$(toPythonPath "$out")'); \ 50 ${stdenv.lib.flip stdenv.lib.concatMapStrings pythonPath (lib: '' 51 sys.path.append('$(toPythonPath "${lib}")'); \ 52 '')}" 53 ''; 54 55 NIX_CFLAGS_COMPILE = "-fstack-protector-all"; 56 57 meta = with stdenv.lib; { 58 description = "SELinux policy core utilities"; 59 license = licenses.gpl2; 60 inherit (libsepol.meta) homepage platforms maintainers; 61 }; 62} 63