2017-08-25 14:39:03 +01:00
|
|
|
{ stdenv, fetchurl, fetchpatch, makeWrapper, autoreconfHook
|
2016-04-17 20:43:48 +01:00
|
|
|
, pkgconfig, which
|
|
|
|
, flex, bison
|
|
|
|
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
2018-01-20 08:29:03 +00:00
|
|
|
, gawk
|
2018-07-29 21:48:24 +01:00
|
|
|
, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform && perl.meta.available or false, perl
|
|
|
|
, withPython ? stdenv.hostPlatform == stdenv.buildPlatform && python.meta.available or false, python
|
2016-04-17 20:43:48 +01:00
|
|
|
, swig
|
2018-01-20 08:29:03 +00:00
|
|
|
, ncurses
|
2016-04-17 20:43:48 +01:00
|
|
|
, pam
|
2018-02-25 14:38:55 +00:00
|
|
|
, buildPackages
|
2015-04-12 08:43:23 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2017-12-30 13:28:40 +00:00
|
|
|
apparmor-series = "2.12";
|
|
|
|
apparmor-patchver = "0";
|
|
|
|
apparmor-version = apparmor-series + "." + apparmor-patchver;
|
2015-04-12 08:43:23 +01:00
|
|
|
|
|
|
|
apparmor-meta = component: with stdenv.lib; {
|
|
|
|
homepage = http://apparmor.net/;
|
2016-04-17 20:43:48 +01:00
|
|
|
description = "A mandatory access control system - ${component}";
|
2015-04-12 08:43:23 +01:00
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = with maintainers; [ phreedom thoughtpolice joachifm ];
|
|
|
|
platforms = platforms.linux;
|
2012-02-29 13:30:10 +00:00
|
|
|
};
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
apparmor-sources = fetchurl {
|
2017-12-30 13:28:40 +00:00
|
|
|
url = "https://launchpad.net/apparmor/${apparmor-series}/${apparmor-version}/+download/apparmor-${apparmor-series}.tar.gz";
|
|
|
|
sha256 = "0mm0mcp0w18si9wl15drndysm7v27az2942p1xjd197shg80qawa";
|
2015-04-12 08:43:23 +01:00
|
|
|
};
|
2012-02-29 13:30:10 +00:00
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
prePatchCommon = ''
|
2018-02-25 14:38:55 +00:00
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2man" "${buildPackages.perl}/bin/pod2man"
|
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/bin/pod2html" "${buildPackages.perl}/bin/pod2html"
|
2016-04-17 20:43:48 +01:00
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
|
2015-04-12 08:43:23 +01:00
|
|
|
substituteInPlace ./common/Make.rules --replace "/usr/share/man" "share/man"
|
2012-02-29 13:30:10 +00:00
|
|
|
'';
|
2014-12-10 15:08:48 +00:00
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
|
2017-08-25 14:39:03 +01:00
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.alpinelinux.org/cgit/aports/plain/testing/apparmor/0002-Provide-missing-secure_getenv-and-scandirat-function.patch?id=74b8427cc21f04e32030d047ae92caa618105b53";
|
|
|
|
name = "0002-Provide-missing-secure_getenv-and-scandirat-function.patch";
|
|
|
|
sha256 = "0pj1bzifghxwxlc39j8hyy17dkjr9fk64kkj94ayymyprz4i4nac";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.alpinelinux.org/cgit/aports/plain/testing/apparmor/0003-Added-missing-typedef-definitions-on-parser.patch?id=74b8427cc21f04e32030d047ae92caa618105b53";
|
|
|
|
name = "0003-Added-missing-typedef-definitions-on-parser.patch";
|
|
|
|
sha256 = "0yyaqz8jlmn1bm37arggprqz0njb4lhjni2d9c8qfqj0kll0bam0";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.alpinelinux.org/cgit/aports/plain/testing/apparmor/0007-Do-not-build-install-vim-file-with-utils-package.patch?id=74b8427cc21f04e32030d047ae92caa618105b53";
|
|
|
|
name = "0007-Do-not-build-install-vim-file-with-utils-package.patch";
|
|
|
|
sha256 = "1m4dx901biqgnr4w4wz8a2z9r9dxyw7wv6m6mqglqwf2lxinqmp4";
|
|
|
|
})
|
|
|
|
# (alpine patches {1,4,5,6,8} are needed for apparmor 2.11, but not 2.12)
|
2018-04-25 04:20:18 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# Set to `true` after the next FIXME gets fixed or this gets some
|
|
|
|
# common derivation infra. Too much copy-paste to fix one by one.
|
|
|
|
doCheck = false;
|
2017-08-25 14:39:03 +01:00
|
|
|
|
2016-09-01 16:51:21 +01:00
|
|
|
# FIXME: convert these to a single multiple-outputs package?
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
libapparmor = stdenv.mkDerivation {
|
|
|
|
name = "libapparmor-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 20:43:48 +01:00
|
|
|
nativeBuildInputs = [
|
2015-07-15 08:31:40 +01:00
|
|
|
autoreconfHook
|
2015-04-12 08:43:23 +01:00
|
|
|
bison
|
|
|
|
flex
|
|
|
|
pkgconfig
|
|
|
|
swig
|
2018-01-20 08:29:03 +00:00
|
|
|
ncurses
|
2015-04-12 08:43:23 +01:00
|
|
|
which
|
2018-02-25 14:38:55 +00:00
|
|
|
perl
|
2015-04-12 08:43:23 +01:00
|
|
|
];
|
|
|
|
|
2018-07-29 21:48:24 +01:00
|
|
|
buildInputs = []
|
|
|
|
++ stdenv.lib.optional withPerl perl
|
|
|
|
++ stdenv.lib.optional withPython python;
|
2016-04-17 20:43:48 +01:00
|
|
|
|
2015-07-15 08:31:40 +01:00
|
|
|
# required to build apparmor-parser
|
|
|
|
dontDisableStatic = true;
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
prePatch = prePatchCommon + ''
|
2016-04-17 20:43:48 +01: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"
|
|
|
|
'';
|
2017-08-25 14:39:03 +01:00
|
|
|
inherit patches;
|
|
|
|
|
2015-07-15 08:31:40 +01:00
|
|
|
postPatch = "cd ./libraries/libapparmor";
|
2018-02-25 14:38:55 +00:00
|
|
|
# https://gitlab.com/apparmor/apparmor/issues/1
|
2018-07-29 21:48:24 +01:00
|
|
|
configureFlags = [
|
|
|
|
(stdenv.lib.withFeature withPerl "perl")
|
|
|
|
(stdenv.lib.withFeature withPython "python")
|
|
|
|
];
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2018-07-29 21:48:24 +01:00
|
|
|
outputs = [ "out" ] ++ stdenv.lib.optional withPython "python";
|
2016-09-01 16:51:21 +01:00
|
|
|
|
2018-07-29 21:48:24 +01:00
|
|
|
postInstall = stdenv.lib.optionalString withPython ''
|
2016-09-01 16:51:21 +01:00
|
|
|
mkdir -p $python/lib
|
|
|
|
mv $out/lib/python* $python/lib/
|
|
|
|
'';
|
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
meta = apparmor-meta "library";
|
|
|
|
};
|
2012-02-29 13:30:10 +00:00
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
apparmor-utils = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-utils-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 20:43:48 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper which ];
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
buildInputs = [
|
2015-07-15 08:45:22 +01:00
|
|
|
perl
|
2018-01-20 08:29:03 +00:00
|
|
|
python
|
2015-04-12 08:43:23 +01:00
|
|
|
libapparmor
|
2016-09-01 16:51:21 +01:00
|
|
|
libapparmor.python
|
2015-04-12 08:43:23 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = prePatchCommon;
|
2017-08-25 14:39:03 +01:00
|
|
|
inherit patches;
|
2015-07-15 08:31:40 +01:00
|
|
|
postPatch = "cd ./utils";
|
|
|
|
makeFlags = ''LANGS='';
|
|
|
|
installFlags = ''DESTDIR=$(out) BINDIR=$(out)/bin VIM_INSTALL_PATH=$(out)/share PYPREFIX='';
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2015-07-15 08:45:22 +01: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
|
2018-01-20 08:29:03 +00:00
|
|
|
wrapProgram $out/bin/$prog --prefix PYTHONPATH : "$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
|
2015-07-15 08:45:22 +01:00
|
|
|
done
|
|
|
|
|
2017-12-30 13:28:40 +00:00
|
|
|
for prog in aa-notify ; do
|
2015-07-15 08:45:22 +01:00
|
|
|
wrapProgram $out/bin/$prog --prefix PERL5LIB : "${libapparmor}/lib/perl5:$PERL5LIB"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2018-07-29 21:48:24 +01:00
|
|
|
meta = apparmor-meta "user-land utilities" // {
|
|
|
|
broken = !(withPython && withPerl);
|
|
|
|
};
|
2015-04-12 08:43:23 +01:00
|
|
|
};
|
|
|
|
|
2018-01-20 08:29:03 +00:00
|
|
|
apparmor-bin-utils = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-bin-utils-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgconfig
|
|
|
|
libapparmor
|
|
|
|
gawk
|
|
|
|
which
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libapparmor
|
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = prePatchCommon;
|
|
|
|
postPatch = "cd ./binutils";
|
|
|
|
makeFlags = ''LANGS= USE_SYSTEM=1'';
|
|
|
|
installFlags = ''DESTDIR=$(out) BINDIR=$(out)/bin'';
|
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2018-01-20 08:29:03 +00:00
|
|
|
meta = apparmor-meta "binary user-land utilities";
|
|
|
|
};
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
apparmor-parser = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-parser-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 20:43:48 +01:00
|
|
|
nativeBuildInputs = [ bison flex which ];
|
|
|
|
|
|
|
|
buildInputs = [ libapparmor ];
|
2015-04-12 08:43:23 +01: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 20:43:48 +01:00
|
|
|
substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
|
2015-04-12 08:43:23 +01:00
|
|
|
## techdoc.pdf still doesn't build ...
|
|
|
|
substituteInPlace ./parser/Makefile --replace "manpages htmlmanpages pdf" "manpages htmlmanpages"
|
|
|
|
'';
|
2017-08-25 14:39:03 +01:00
|
|
|
inherit patches;
|
2015-07-15 08:31:40 +01:00
|
|
|
postPatch = "cd ./parser";
|
|
|
|
makeFlags = ''LANGS= USE_SYSTEM=1 INCLUDEDIR=${libapparmor}/include'';
|
|
|
|
installFlags = ''DESTDIR=$(out) DISTRO=unknown'';
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
meta = apparmor-meta "rule parser";
|
2012-02-29 13:30:10 +00:00
|
|
|
};
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
apparmor-pam = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-pam-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 20:43:48 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig which ];
|
|
|
|
|
|
|
|
buildInputs = [ libapparmor pam ];
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2015-07-15 08:31:40 +01:00
|
|
|
postPatch = "cd ./changehat/pam_apparmor";
|
|
|
|
makeFlags = ''USE_SYSTEM=1'';
|
|
|
|
installFlags = ''DESTDIR=$(out)'';
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
meta = apparmor-meta "PAM service";
|
|
|
|
};
|
|
|
|
|
|
|
|
apparmor-profiles = stdenv.mkDerivation {
|
|
|
|
name = "apparmor-profiles-${apparmor-version}";
|
|
|
|
src = apparmor-sources;
|
|
|
|
|
2016-04-17 20:43:48 +01:00
|
|
|
nativeBuildInputs = [ which ];
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2015-07-15 08:31:40 +01:00
|
|
|
postPatch = "cd ./profiles";
|
|
|
|
installFlags = ''DESTDIR=$(out) EXTRAS_DEST=$(out)/share/apparmor/extra-profiles'';
|
2015-04-12 08:43:23 +01:00
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2015-04-12 08:43:23 +01: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 20:43:48 +01:00
|
|
|
cp -R ./kernel-patches/* "$out"
|
2015-04-12 08:43:23 +01:00
|
|
|
'';
|
|
|
|
|
2018-04-25 04:20:18 +01:00
|
|
|
inherit doCheck;
|
|
|
|
|
2015-04-12 08:43:23 +01:00
|
|
|
meta = apparmor-meta "kernel patches";
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2018-01-20 08:29:03 +00:00
|
|
|
inherit
|
|
|
|
libapparmor
|
|
|
|
apparmor-utils
|
|
|
|
apparmor-bin-utils
|
|
|
|
apparmor-parser
|
|
|
|
apparmor-pam
|
|
|
|
apparmor-profiles
|
|
|
|
apparmor-kernel-patches;
|
2015-04-12 08:43:23 +01:00
|
|
|
}
|