2016-04-17 21:43:48 +02:00
|
|
|
{ stdenv, fetchurl, makeWrapper, autoreconfHook
|
|
|
|
, pkgconfig, which
|
|
|
|
, flex, bison
|
|
|
|
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
|
|
|
, pythonPackages
|
|
|
|
, perl
|
|
|
|
, swig
|
|
|
|
, pam
|
2015-04-12 09:43:23 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2015-07-15 07:29:50 +02:00
|
|
|
apparmor-series = "2.10";
|
|
|
|
apparmor-version = apparmor-series;
|
2015-04-12 09:43:23 +02:00
|
|
|
|
|
|
|
apparmor-meta = component: with stdenv.lib; {
|
|
|
|
homepage = http://apparmor.net/;
|
2016-04-17 21:43:48 +02:00
|
|
|
description = "A mandatory access control system - ${component}";
|
2015-04-12 09:43:23 +02:00
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = with maintainers; [ phreedom thoughtpolice joachifm ];
|
|
|
|
platforms = platforms.linux;
|
2012-02-29 14:30:10 +01:00
|
|
|
};
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
apparmor-sources = fetchurl {
|
|
|
|
url = "https://launchpad.net/apparmor/${apparmor-series}/${apparmor-version}/+download/apparmor-${apparmor-version}.tar.gz";
|
2015-07-15 07:29:50 +02:00
|
|
|
sha256 = "1x06qmmbha9krx7880pxj2k3l8fxy3nm945xjjv735m2ax1243jd";
|
2015-04-12 09:43:23 +02:00
|
|
|
};
|
2012-02-29 14:30:10 +01:00
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
prePatchCommon = ''
|
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2man" "${perl}/bin/pod2man"
|
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2html" "${perl}/bin/pod2html"
|
2016-04-17 21:43:48 +02:00
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
|
2015-04-12 09:43:23 +02:00
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/share/man" "share/man"
|
2012-02-29 14:30:10 +01:00
|
|
|
'';
|
2014-12-10 16:08:48 +01:00
|
|
|
|
2016-09-01 17:51:21 +02:00
|
|
|
# FIXME: convert these to a single multiple-outputs package?
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
libapparmor = stdenv.mkDerivation {
|
|
|
|
name = "libapparmor-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
nativeBuildInputs = [
|
2015-07-15 09:31:40 +02:00
|
|
|
autoreconfHook
|
2015-04-12 09:43:23 +02:00
|
|
|
bison
|
|
|
|
flex
|
|
|
|
pkgconfig
|
|
|
|
swig
|
|
|
|
which
|
|
|
|
];
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
buildInputs = [
|
|
|
|
perl
|
|
|
|
pythonPackages.python
|
|
|
|
];
|
|
|
|
|
2015-07-15 09:31:40 +02:00
|
|
|
# required to build apparmor-parser
|
|
|
|
dontDisableStatic = true;
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
prePatch = prePatchCommon + ''
|
2016-04-17 21:43:48 +02:00
|
|
|
substituteInPlace ./libraries/libapparmor/src/Makefile.am --replace "/usr/include/netinet/in.h" "${stdenv.cc.libc.dev}/include/netinet/in.h"
|
|
|
|
substituteInPlace ./libraries/libapparmor/src/Makefile.in --replace "/usr/include/netinet/in.h" "${stdenv.cc.libc.dev}/include/netinet/in.h"
|
|
|
|
'';
|
2015-04-12 09:43:23 +02:00
|
|
|
|
2015-07-15 09:31:40 +02:00
|
|
|
postPatch = "cd ./libraries/libapparmor";
|
|
|
|
configureFlags = "--with-python --with-perl";
|
2015-04-12 09:43:23 +02:00
|
|
|
|
2016-09-01 17:51:21 +02:00
|
|
|
outputs = [ "out" "python" ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $python/lib
|
|
|
|
mv $out/lib/python* $python/lib/
|
|
|
|
'';
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
meta = apparmor-meta "library";
|
|
|
|
};
|
2012-02-29 14:30:10 +01:00
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
apparmor-utils = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-utils-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper which ];
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
buildInputs = [
|
2015-07-15 09:45:22 +02:00
|
|
|
perl
|
2016-04-17 21:43:48 +02:00
|
|
|
pythonPackages.python
|
|
|
|
pythonPackages.readline
|
2015-04-12 09:43:23 +02:00
|
|
|
libapparmor
|
2016-09-01 17:51:21 +02:00
|
|
|
libapparmor.python
|
2015-04-12 09:43:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = prePatchCommon;
|
2015-07-15 09:31:40 +02:00
|
|
|
postPatch = "cd ./utils";
|
|
|
|
makeFlags = ''LANGS='';
|
|
|
|
installFlags = ''DESTDIR=$(out) BINDIR=$(out)/bin VIM_INSTALL_PATH=$(out)/share PYPREFIX='';
|
2015-04-12 09:43:23 +02:00
|
|
|
|
2015-07-15 09:45:22 +02:00
|
|
|
postInstall = ''
|
|
|
|
for prog in aa-audit aa-autodep aa-cleanprof aa-complain aa-disable aa-enforce aa-genprof aa-logprof aa-mergeprof aa-status aa-unconfined ; do
|
2016-04-17 21:43:48 +02:00
|
|
|
wrapProgram $out/bin/$prog --prefix PYTHONPATH : "$out/lib/${pythonPackages.python.libPrefix}/site-packages:$PYTHONPATH"
|
2015-07-15 09:45:22 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
for prog in aa-exec aa-notify ; do
|
|
|
|
wrapProgram $out/bin/$prog --prefix PERL5LIB : "${libapparmor}/lib/perl5:$PERL5LIB"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
meta = apparmor-meta "user-land utilities";
|
|
|
|
};
|
|
|
|
|
|
|
|
apparmor-parser = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-parser-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
nativeBuildInputs = [ bison flex which ];
|
|
|
|
|
|
|
|
buildInputs = [ libapparmor ];
|
2015-04-12 09:43:23 +02:00
|
|
|
|
|
|
|
prePatch = prePatchCommon + ''
|
|
|
|
substituteInPlace ./parser/Makefile --replace "/usr/bin/bison" "${bison}/bin/bison"
|
|
|
|
substituteInPlace ./parser/Makefile --replace "/usr/bin/flex" "${flex}/bin/flex"
|
2016-04-17 21:43:48 +02:00
|
|
|
substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
|
2015-04-12 09:43:23 +02:00
|
|
|
## techdoc.pdf still doesn't build ...
|
|
|
|
substituteInPlace ./parser/Makefile --replace "manpages htmlmanpages pdf" "manpages htmlmanpages"
|
|
|
|
'';
|
2015-07-15 09:31:40 +02:00
|
|
|
postPatch = "cd ./parser";
|
|
|
|
makeFlags = ''LANGS= USE_SYSTEM=1 INCLUDEDIR=${libapparmor}/include'';
|
|
|
|
installFlags = ''DESTDIR=$(out) DISTRO=unknown'';
|
2015-04-12 09:43:23 +02:00
|
|
|
|
|
|
|
meta = apparmor-meta "rule parser";
|
2012-02-29 14:30:10 +01:00
|
|
|
};
|
|
|
|
|
2015-04-12 09:43:23 +02:00
|
|
|
apparmor-pam = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-pam-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
nativeBuildInputs = [ pkgconfig which ];
|
|
|
|
|
|
|
|
buildInputs = [ libapparmor pam ];
|
2015-04-12 09:43:23 +02:00
|
|
|
|
2015-07-15 09:31:40 +02:00
|
|
|
postPatch = "cd ./changehat/pam_apparmor";
|
|
|
|
makeFlags = ''USE_SYSTEM=1'';
|
|
|
|
installFlags = ''DESTDIR=$(out)'';
|
2015-04-12 09:43:23 +02:00
|
|
|
|
|
|
|
meta = apparmor-meta "PAM service";
|
|
|
|
};
|
|
|
|
|
|
|
|
apparmor-profiles = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-profiles-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 21:43:48 +02:00
|
|
|
nativeBuildInputs = [ which ];
|
2015-04-12 09:43:23 +02:00
|
|
|
|
2015-07-15 09:31:40 +02:00
|
|
|
postPatch = "cd ./profiles";
|
|
|
|
installFlags = ''DESTDIR=$(out) EXTRAS_DEST=$(out)/share/apparmor/extra-profiles'';
|
2015-04-12 09:43:23 +02:00
|
|
|
|
|
|
|
meta = apparmor-meta "profiles";
|
|
|
|
};
|
|
|
|
|
|
|
|
apparmor-kernel-patches = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-kernel-patches-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
|
|
|
phases = ''unpackPhase installPhase'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir "$out"
|
2016-04-17 21:43:48 +02:00
|
|
|
cp -R ./kernel-patches/* "$out"
|
2015-04-12 09:43:23 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = apparmor-meta "kernel patches";
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
inherit libapparmor apparmor-utils apparmor-parser apparmor-pam
|
|
|
|
apparmor-profiles apparmor-kernel-patches;
|
|
|
|
}
|