projects/guix·blob python-team · refs

205 lines · 8.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2022 Hilton Chain <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages apparmor)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (gnu packages autotools)
22 #:use-module (gnu packages base)
23 #:use-module (gnu packages bison)
24 #:use-module (gnu packages dejagnu)
25 #:use-module (gnu packages compiler-tools)
26 #:use-module (gnu packages gawk)
27 #:use-module (gnu packages gettext)
28 #:use-module (gnu packages linux)
29 #:use-module (gnu packages perl)
30 #:use-module (gnu packages pkg-config)
31 #:use-module (gnu packages python)
32 #:use-module (gnu packages python-build)
33 #:use-module (gnu packages python-xyz)
34 #:use-module (gnu packages ruby)
35 #:use-module (gnu packages swig)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix gexp)
38 #:use-module (guix git-download)
39 #:use-module (guix packages)
40 #:use-module (guix utils))
41
42(define-public libapparmor
43 (package
44 (name "libapparmor")
45 (version "4.1.2")
46 (source (origin
47 (method git-fetch)
48 (uri (git-reference
49 (url "https://gitlab.com/apparmor/apparmor")
50 (commit (string-append "v" version))))
51 (file-name (git-file-name name version))
52 (sha256
53 (base32
54 "0p3vq0awvn4ar6sblmhcs0i9m7zc9kbwm3f3zcggx4lqgmy8s18b"))))
55 (build-system gnu-build-system)
56 (arguments
57 (list #:configure-flags
58 #~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
59 "--with-perl" "--with-python" "--with-ruby")
60 #:phases
61 #~(modify-phases %standard-phases
62 (add-after 'unpack 'fix-paths
63 (lambda* (#:key inputs #:allow-other-keys)
64 (for-each patch-shebang
65 '("common/list_af_names.sh"
66 "common/list_capabilities.sh"))
67 (for-each (lambda (file)
68 (substitute* file
69 (("/usr") "")
70 (("/bin/\\<(pod2man|pod2html|podchecker|prove)\\>" path)
71 (search-input-file inputs path))
72 (("/include/linux/capability.h" path)
73 (search-input-file inputs path))))
74 '("common/Make-po.rules"
75 "common/Make.rules"
76 "binutils/Makefile"
77 "parser/Makefile"
78 "parser/tst/Makefile"
79 "profiles/Makefile"
80 "utils/Makefile"
81 "utils/python-tools-setup.py"
82 "utils/vim/Makefile"))))
83 (add-after 'fix-paths 'change-directory
84 (lambda _
85 (chdir "libraries/libapparmor"))))))
86 (native-inputs
87 (list autoconf
88 autoconf-archive
89 automake
90 bison
91 dejagnu
92 flex
93 libtool
94 perl
95 python-minimal
96 python-setuptools
97 ruby
98 swig-4.4
99 which))
100 (home-page "https://apparmor.net")
101 (synopsis "Linux kernel security module")
102 (description
103 "AppArmor is an effective and easy-to-use Linux application security
104system.
105
106AppArmor proactively protects the operating system and applications from
107external or internal threats, even zero-day attacks, by enforcing good
108behavior and preventing both known and unknown application flaws from being
109exploited.
110
111AppArmor supplements the traditional Unix discretionary access control (DAC)
112model by providing mandatory access control (MAC). It has been included in
113the mainline Linux kernel since version 2.6.36 and its development has been
114supported by Canonical since 2009.")
115 (license license:lgpl2.1)
116 (supported-systems (filter (lambda (system)
117 (string-suffix? "-linux" system))
118 %supported-systems))))
119
120(define-public apparmor
121 (let ((base libapparmor))
122 (package
123 (inherit base)
124 (name "apparmor")
125 (arguments
126 (append
127 (list #:make-flags
128 #~(list (string-append "CC=" #$(cc-for-target))
129 (string-append "DESTDIR=" #$output)
130 "USE_SYSTEM=1"
131 ;; No need to run the linter
132 "PYFLAKES=true"))
133 (substitute-keyword-arguments arguments
134 ((#:phases phases)
135 #~(modify-phases #$phases
136 (delete 'configure)
137 ;; apparmor-binutils
138 (replace 'change-directory
139 (lambda _
140 (chdir "binutils")))
141
142 ;; apparmor-parser
143 (add-after 'install 'chdir-parser
144 (lambda _
145 (chdir "../parser")))
146 (add-after 'chdir-parser 'patch-source-shebangs-parser
147 (assoc-ref %standard-phases 'patch-source-shebangs))
148 (add-after 'patch-source-shebangs-parser 'build-parser
149 (assoc-ref %standard-phases 'build))
150 (add-after 'build-parser 'check-parser
151 (assoc-ref %standard-phases 'check))
152 (add-after 'check-parser 'install-parser
153 (assoc-ref %standard-phases 'install))
154
155 ;; apparmor-utils
156 ;; FIXME: Tests required Python library from this package
157 ;; (itself).
158 (add-after 'install-parser 'chdir-utils
159 (lambda _
160 (chdir "../utils")
161 ;; Fix paths to installed policygroups and templates for
162 ;; easyprof.
163 (substitute* "easyprof/easyprof.conf"
164 (("/usr") #$output))))
165 (add-after 'chdir-utils 'build-utils
166 (assoc-ref %standard-phases 'build))
167 (add-after 'build-utils 'install-utils
168 (assoc-ref %standard-phases 'install))
169
170 ;; apparmor-profiles
171 ;; FIXME: Tests need an AppArmor-enabled system.
172 (add-after 'install-utils 'chdir-profiles
173 (lambda _
174 (chdir "../profiles")))
175 (add-after 'chdir-profiles 'build-profiles
176 (assoc-ref %standard-phases 'build))
177 (add-after 'build-profiles 'install-profiles
178 (assoc-ref %standard-phases 'install)))))))
179 (propagated-inputs
180 (list libapparmor))
181 ;; Python module `readline' needed
182 (native-inputs
183 (list bison flex gettext-minimal perl python python-setuptools which))
184 (license license:gpl2))))
185
186(define-public pam-apparmor
187 (let ((base apparmor))
188 (package
189 (inherit base)
190 (name "pam-apparmor")
191 (arguments
192 (append
193 (list #:tests? #f) ;no tests
194 (substitute-keyword-arguments arguments
195 ((#:phases phases)
196 #~(modify-phases #$phases
197 (delete 'chdir-parser)
198 (delete 'chdir-utils)
199 (delete 'chdir-profiles)
200 (replace 'change-directory
201 (lambda _
202 (chdir "changehat/pam_apparmor"))))))))
203 (native-inputs (list pkg-config perl which))
204 (inputs (list libapparmor linux-pam))
205 (license license:bsd-3))))