Subject: [bug#59336] [PATCH 2/6] gnu: Add apparmor.

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

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

diff --git a/gnu/packages/apparmor.scm b/gnu/packages/apparmor.scm
index 8cb4c7e94d..742414e18b 100644
--- a/gnu/packages/apparmor.scm
+++ b/gnu/packages/apparmor.scm
@@ -88,3 +88,40 @@ (define-public libapparmor
 the mainline Linux kernel since version 2.6.36 and its development has been
 supported by Canonical since 2009.")
     (license license:lgpl2.1)))
+
+(define-public apparmor
+  (package
+    (inherit libapparmor)
+    (name "apparmor")
+    (arguments
+     (list #:make-flags
+           #~(list (string-append "CC=" #$(cc-for-target))
+                   (string-append "DESTDIR=" #$output)
+                   "USE_SYSTEM=1")
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)
+               (add-after 'unpack 'fix-makefile-paths
+                 (lambda _
+                   (for-each patch-shebang
+                             '("common/list_af_names.sh"
+                               "common/list_capabilities.sh"))
+                   (for-each (lambda (file)
+                               (substitute* file
+                                 (("/usr/bin/\\<(pod2man|pod2html|prove)\\>" all cmd) cmd)
+                                 (("/usr") "")))
+                             '("common/Make-po.rules"
+                               "common/Make.rules"
+                               "binutils/Makefile"
+                               "parser/Makefile"
+                               "parser/tst/Makefile"
+                               "profiles/Makefile"
+                               "utils/Makefile"
+                               "utils/python-tools-setup.py"
+                               "utils/vim/Makefile"))))
+               (add-after 'fix-makefile-paths 'change-directory
+                 (lambda _
+                   (chdir "binutils"))))))
+    (native-inputs (list gettext-minimal perl which))
+    (inputs (list libapparmor))
+    (license license:gpl2)))
-- 
2.38.1