blob: fd649e400ea86af79f1f739eb1a5bc35d9b80ff1 [file] [log] [blame]
Andrew Geissler9aee5002022-03-30 16:27:02 +00001SUMMARY = "AppArmor another MAC control system"
2DESCRIPTION = "user-space parser utility for AppArmor \
3 This provides the system initialization scripts needed to use the \
4 AppArmor Mandatory Access Control system, including the AppArmor Parser \
5 which is required to convert AppArmor text profiles into machine-readable \
6 policies that are loaded into the kernel for use with the AppArmor Linux \
7 Security Module."
Patrick Williams2194f502022-10-16 14:26:09 -05008HOMEPAGE = "http://apparmor.net/"
Andrew Geissler9aee5002022-03-30 16:27:02 +00009SECTION = "admin"
10
Patrick Williams03907ee2022-05-01 06:28:52 -050011LICENSE = "GPL-2.0-only & GPL-2.0-or-later & BSD-3-Clause & LGPL-2.1-or-later"
Andrew Geissler9aee5002022-03-30 16:27:02 +000012LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=fd57a4b0bc782d7b80fd431f10bbf9d0"
13
14DEPENDS = "bison-native apr gettext-native coreutils-native swig-native"
15
16SRC_URI = " \
Andrew Geissler2daf84b2023-03-31 09:57:23 -050017 git://gitlab.com/apparmor/apparmor.git;protocol=https;branch=apparmor-3.1 \
Andrew Geissler9aee5002022-03-30 16:27:02 +000018 file://run-ptest \
19 file://crosscompile_perl_bindings.patch \
20 file://0001-Makefile.am-suppress-perllocal.pod.patch \
21 file://0001-Makefile-fix-hardcoded-installation-directories.patch \
Andrew Geissler9aee5002022-03-30 16:27:02 +000022 "
23
Andrew Geissler2daf84b2023-03-31 09:57:23 -050024SRCREV = "e69cb5047946818e6a9df326851483bb075a5cfe"
Andrew Geissler9aee5002022-03-30 16:27:02 +000025S = "${WORKDIR}/git"
26
27PARALLEL_MAKE = ""
28
29COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*"
30
31inherit pkgconfig autotools-brokensep update-rc.d python3native python3targetconfig perlnative cpan systemd features_check bash-completion setuptools3
32
33REQUIRED_DISTRO_FEATURES = "apparmor"
34
35PACKAGECONFIG ?= "python perl aa-decode"
36PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man-pages"
37PACKAGECONFIG[python] = "--with-python, --without-python, python3 , python3-core python3-modules"
38PACKAGECONFIG[perl] = "--with-perl, --without-perl, "
39PACKAGECONFIG[apache2] = ",,apache2,"
40PACKAGECONFIG[aa-decode] = ",,,bash"
41
42python() {
43 if 'apache2' in d.getVar('PACKAGECONFIG').split() and \
44 'webserver' not in d.getVar('BBFILE_COLLECTIONS').split():
45 raise bb.parse.SkipRecipe('Requires meta-webserver to be present.')
46}
47
48DISABLE_STATIC = ""
49
50do_configure() {
51 cd ${S}/libraries/libapparmor
52 aclocal
53 autoconf --force
54 libtoolize --automake -c --force
55 automake -ac
56 ./configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
57}
58
59do_compile () {
60 sed -i "s@sed -ie 's///g' Makefile.perl@@" ${S}/libraries/libapparmor/swig/perl/Makefile
61 oe_runmake -C ${B}/libraries/libapparmor
62 oe_runmake -C ${B}/binutils
63 oe_runmake -C ${B}/utils
64 oe_runmake -C ${B}/parser
65 oe_runmake -C ${B}/profiles
66
67 if ${@bb.utils.contains('PACKAGECONFIG','apache2','true','false', d)}; then
68 oe_runmake -C ${B}/changehat/mod_apparmor
69 fi
70
71 if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
72 oe_runmake -C ${B}/changehat/pam_apparmor
73 fi
74}
75
76do_install () {
77 oe_runmake -C ${B}/libraries/libapparmor DESTDIR="${D}" install
78 oe_runmake -C ${B}/binutils DESTDIR="${D}" install
79 oe_runmake -C ${B}/utils DESTDIR="${D}" install
80 oe_runmake -C ${B}/parser DESTDIR="${D}" install
81 oe_runmake -C ${B}/profiles DESTDIR="${D}" install
82
83 if ! ${@bb.utils.contains('PACKAGECONFIG','aa-decode','true','false', d)}; then
84 rm -f ${D}${sbindir}/aa-decode
85 fi
86
87 if ${@bb.utils.contains('PACKAGECONFIG','apache2','true','false', d)}; then
88 oe_runmake -C ${B}/changehat/mod_apparmor DESTDIR="${D}" install
89 fi
90
91 if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
92 oe_runmake -C ${B}/changehat/pam_apparmor DESTDIR="${D}" install
93 fi
94
95 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
96 install -d ${D}${sysconfdir}/init.d
Andrew Geissler2daf84b2023-03-31 09:57:23 -050097 install -m 755 ${B}/parser/rc.apparmor.functions ${D}${sysconfdir}/init.d/apparmor
Andrew Geissler9aee5002022-03-30 16:27:02 +000098 fi
99
100 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
101 oe_runmake -C ${B}/parser DESTDIR="${D}" install-systemd
102 fi
Andrew Geissler615f2f12022-07-15 14:00:58 -0500103 chown root:root -R ${D}/${sysconfdir}/apparmor.d
104 chown root:root -R ${D}/${datadir}/apparmor
Andrew Geissler9aee5002022-03-30 16:27:02 +0000105}
106
107#Building ptest on arm fails.
108do_compile_ptest:aarch64 () {
109 :
110}
111
112do_compile_ptest:arm () {
113 :
114}
115
116do_compile_ptest () {
117 sed -i -e 's/cpp \-dM/${HOST_PREFIX}gcc \-dM/' ${B}/tests/regression/apparmor/Makefile
118 oe_runmake -C ${B}/tests/regression/apparmor USE_SYSTEM=0
119 oe_runmake -C ${B}/libraries/libapparmor
120}
121
122do_install_ptest () {
123 t=${D}/${PTEST_PATH}/testsuite
124 install -d ${t}
125 install -d ${t}/tests/regression/apparmor
126 cp -rf ${B}/tests/regression/apparmor ${t}/tests/regression
127
128 cp ${B}/parser/apparmor_parser ${t}/parser
129 cp ${B}/parser/frob_slack_rc ${t}/parser
130
131 install -d ${t}/libraries/libapparmor
132 cp -rf ${B}/libraries/libapparmor ${t}/libraries
133
134 install -d ${t}/common
135 cp -rf ${B}/common ${t}
136
137 install -d ${t}/binutils
138 cp -rf ${B}/binutils ${t}
139}
140
141#Building ptest on arm fails.
142do_install_ptest:aarch64 () {
143 :
144}
145
146do_install_ptest:arm() {
147 :
148}
149
150INITSCRIPT_PACKAGES = "${PN}"
151INITSCRIPT_NAME = "apparmor"
152INITSCRIPT_PARAMS = "start 16 2 3 4 5 . stop 35 0 1 6 ."
153
154SYSTEMD_PACKAGES = "${PN}"
155SYSTEMD_SERVICE:${PN} = "apparmor.service"
156SYSTEMD_AUTO_ENABLE ?= "enable"
157
158PACKAGES += "mod-${PN}"
159
160FILES:${PN} += "${nonarch_base_libdir}/apparmor/ ${base_libdir}/security/ ${sysconfdir}/apparmor ${nonarch_libdir}/${PYTHON_DIR}/site-packages"
161FILES:mod-${PN} = "${libdir}/apache2/modules/*"
162FILES:${PN}-dbg += "${base_libdir}/security/.debug"
163
164DEPENDS:append:libc-musl = " fts "
165RDEPENDS:${PN}:libc-musl += "musl-utils"
166RDEPENDS:${PN}:libc-glibc += "glibc-utils"
167
168# Add coreutils and findutils only if sysvinit scripts are in use
169RDEPENDS:${PN} += "${@["coreutils findutils", ""][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd')]} ${@bb.utils.contains('PACKAGECONFIG','python','python3-core python3-modules','', d)}"
170RDEPENDS:${PN}:remove = "${@bb.utils.contains('PACKAGECONFIG','perl','','perl', d)}"
171RDEPENDS:${PN}-ptest += "perl coreutils dbus-lib bash"
172
173INSANE_SKIP:${PN} = "ldflags"
174PRIVATE_LIBS:${PN}-ptest = "libapparmor.so*"