Subject: [bug#59336] [PATCH 4/6] gnu: Add apparmor-utils.

From: Hilton Chain <[email-masked]>
Date: Fri, 18 Nov 2022 00:32:00 +0800

* gnu/packages/apparmor.scm (apparmor-utils): New variable.
---
 gnu/packages/apparmor.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/apparmor.scm b/gnu/packages/apparmor.scm
index 8648a2213f..b753ffc88a 100644
--- a/gnu/packages/apparmor.scm
+++ b/gnu/packages/apparmor.scm
@@ -146,3 +146,39 @@ (define-public apparmor-parser
       (native-inputs
        (modify-inputs (package-native-inputs base)
          (append bison flex python-minimal))))))
+
+(define-public apparmor-utils
+  (let ((base apparmor))
+    (package
+      (inherit base)
+      (name "apparmor-utils")
+      (arguments
+       (append
+        ;; FIXME: Tests required Python library from this package (itself).
+        (list #:tests? #f)
+        (substitute-keyword-arguments (package-arguments base)
+          ((#:phases phases)
+           #~(modify-phases #$phases
+               (replace 'change-directory
+                 (lambda _
+                   (chdir "utils")))
+               (add-after 'change-directory 'fix-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; Fix kernel header path
+                   (substitute* "Makefile"
+                     (("/include/linux/capability.h" path)
+                      (search-input-file inputs path)))
+                   ;; Fix apparmor_parser path
+                   (for-each (lambda (file)
+                               (substitute* file
+                                 (("/sbin/apparmor_parser" path)
+                                  (search-input-file inputs path))))
+                             '("apparmor/aa.py"
+                               "apparmor/easyprof.py"
+                               "logprof.conf")))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs base)
+         (append python-minimal)))
+      (inputs
+       (modify-inputs (package-inputs base)
+         (append apparmor-parser))))))
-- 
2.38.1