@@ -1,4 +1,4 @@
1−{ stdenv, lib, fetchFromGitLab, fetchpatch, makeWrapper, autoreconfHook
1+{ stdenv, lib, fetchurl, fetchpatch, makeWrapper, autoreconfHook
22, pkg-config, which
33, flex, bison
44, linuxHeaders ? stdenv.cc.libc.linuxHeaders
@@ -21,7 +21,7 @@
2121}:
2222
2323let
24− apparmor-version = "3.0.4";
24+ apparmor-version = "3.0.3";
2525
2626 apparmor-meta = component: with lib; {
2727 homepage = "https://apparmor.net/";
@@ -31,11 +31,9 @@ let
3131 platforms = platforms.linux;
3232 };
3333
34− apparmor-sources = fetchFromGitLab {
35− owner = "apparmor";
36− repo = "apparmor";
37− rev = "v${apparmor-version}";
38− sha256 = "1a217j28rgfq4lsmpn0wv1xgmdr9ba8iysv9i6q477kj6z77zrb9";
34+ apparmor-sources = fetchurl {
35+ url = "https://launchpad.net/apparmor/${lib.versions.majorMinor apparmor-version}/${apparmor-version}/+download/apparmor-${apparmor-version}.tar.gz";
36+ sha256 = "0nasq8pdmzkrf856yg1v8z5hcs0nn6gw2qr60ab0a7j9ixfv0g8m";
3937 };
4038
4139 aa-teardown = writeShellScript "aa-teardown" ''
@@ -50,9 +48,8 @@ let
5048 substituteInPlace ./common/Make.rules \
5149 --replace "/usr/bin/pod2man" "${buildPackages.perl}/bin/pod2man" \
5250 --replace "/usr/bin/pod2html" "${buildPackages.perl}/bin/pod2html" \
51+ --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h" \
5352 --replace "/usr/share/man" "share/man"
54− substituteInPlace ./utils/Makefile \
55− --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
5653 '';
5754
5855 patches = lib.optionals stdenv.hostPlatform.isMusl [
@@ -63,8 +60,6 @@ let
6360 })
6461 ];
6562
66− python = python3.withPackages (ps: with ps; [ setuptools ]);
67−
6863 # Set to `true` after the next FIXME gets fixed or this gets some
6964 # common derivation infra. Too much copy-paste to fix one by one.
7065 doCheck = false;
@@ -91,16 +86,19 @@ let
9186 ncurses
9287 which
9388 perl
94− ] ++ lib.optional withPython python;
89+ ] ++ lib.optional withPython python3;
9590
9691 buildInputs = lib.optional withPerl perl
97− ++ lib.optional withPython python;
92+ ++ lib.optional withPython python3;
9893
9994 # required to build apparmor-parser
10095 dontDisableStatic = true;
10196
10297 prePatch = prePatchCommon + ''
10398 substituteInPlace ./libraries/libapparmor/swig/perl/Makefile.am --replace install_vendor install_site
99+ substituteInPlace ./libraries/libapparmor/swig/perl/Makefile.in --replace install_vendor install_site
100+ substituteInPlace ./libraries/libapparmor/src/Makefile.am --replace "/usr/include/netinet/in.h" "${lib.getDev stdenv.cc.libc}/include/netinet/in.h"
101+ substituteInPlace ./libraries/libapparmor/src/Makefile.in --replace "/usr/include/netinet/in.h" "${lib.getDev stdenv.cc.libc}/include/netinet/in.h"
104102 '';
105103 inherit patches;
106104
@@ -134,12 +132,12 @@ let
134132
135133 strictDeps = true;
136134
137− nativeBuildInputs = [ makeWrapper which python ];
135+ nativeBuildInputs = [ makeWrapper which python3 ];
138136
139137 buildInputs = [
140138 bash
141139 perl
142− python
140+ python3
143141 libapparmor
144142 libapparmor.python
145143 ];
@@ -161,7 +159,7 @@ let
161159 postInstall = ''
162160 sed -i $out/bin/aa-unconfined -e "/my_env\['PATH'\]/d"
163161 for prog in aa-audit aa-autodep aa-cleanprof aa-complain aa-disable aa-enforce aa-genprof aa-logprof aa-mergeprof aa-unconfined ; do
164− wrapProgram $out/bin/$prog --prefix PYTHONPATH : "$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
162+ wrapProgram $out/bin/$prog --prefix PYTHONPATH : "$out/lib/${python3.libPrefix}/site-packages:$PYTHONPATH"
165163 done
166164
167165 substituteInPlace $out/bin/aa-notify \