lol

apparmor: fix python import issues

With buildPythonApplication the PYTHONPATH is now populated properly,
which should address the ModuleNotFoundError issue.

I also moved some of the substitutions from postInstall to prePatch, so
they don't conflict with the wrapped executables.

Because upstream does not seem to hardcode binary paths in the utils
anymore, some of the old substituteInPlace rules could be removed.

Partial fix for nixpkgs#169056

+16 -15
+16 -15
pkgs/os-specific/linux/apparmor/default.nix
··· 128 128 meta = apparmor-meta "library"; 129 129 }; 130 130 131 - apparmor-utils = stdenv.mkDerivation { 131 + apparmor-utils = python.pkgs.buildPythonApplication { 132 132 pname = "apparmor-utils"; 133 133 version = apparmor-version; 134 + format = "other"; 134 135 135 136 src = apparmor-sources; 136 137 ··· 146 147 libapparmor.python 147 148 ]; 148 149 150 + propagatedBuildInputs = [ 151 + libapparmor.python 152 + 153 + # Used by aa-notify 154 + python.pkgs.notify2 155 + python.pkgs.psutil 156 + ]; 157 + 149 158 prePatch = prePatchCommon + 150 159 # Do not build vim file 151 160 lib.optionalString stdenv.hostPlatform.isMusl '' 152 161 sed -i ./utils/Makefile -e "/\<vim\>/d" 153 162 '' + '' 154 - for file in utils/apparmor/easyprof.py utils/apparmor/aa.py utils/logprof.conf; do 155 - substituteInPlace $file --replace "/sbin/apparmor_parser" "${apparmor-parser}/bin/apparmor_parser" 156 - done 163 + sed -i -E 's/^(DESTDIR|BINDIR|PYPREFIX)=.*//g' ./utils/Makefile 164 + 165 + sed -i utils/aa-unconfined -e "/my_env\['PATH'\]/d" 166 + 167 + substituteInPlace utils/aa-remove-unknown \ 168 + --replace "/lib/apparmor/rc.apparmor.functions" "${apparmor-parser}/lib/apparmor/rc.apparmor.functions" 157 169 ''; 158 170 inherit patches; 159 171 postPatch = "cd ./utils"; ··· 161 173 installFlags = [ "DESTDIR=$(out)" "BINDIR=$(out)/bin" "VIM_INSTALL_PATH=$(out)/share" "PYPREFIX=" ]; 162 174 163 175 postInstall = '' 164 - sed -i $out/bin/aa-unconfined -e "/my_env\['PATH'\]/d" 165 - for prog in aa-audit aa-autodep aa-cleanprof aa-complain aa-disable aa-enforce aa-genprof aa-logprof aa-mergeprof aa-unconfined ; do 166 - wrapProgram $out/bin/$prog --prefix PYTHONPATH : "$out/lib/${python.sitePackages}:$PYTHONPATH" 167 - done 168 - 169 - substituteInPlace $out/bin/aa-notify \ 170 - --replace /usr/bin/notify-send ${libnotify}/bin/notify-send \ 171 - --replace /usr/bin/perl "${perl}/bin/perl -I ${libapparmor}/${perl.libPrefix}" 172 - 173 - substituteInPlace $out/bin/aa-remove-unknown \ 174 - --replace "/lib/apparmor/rc.apparmor.functions" "${apparmor-parser}/lib/apparmor/rc.apparmor.functions" 175 176 wrapProgram $out/bin/aa-remove-unknown \ 176 177 --prefix PATH : ${lib.makeBinPath [ gawk ]} 177 178