blob: 35e95a0a2bf678270fb202caaee1941bcee00cf8 [file] [log] [blame]
Andrew Geisslerd1d22e62020-10-16 10:14:32 -05001SUMMARY = "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."
8HOMEAPAGE = "http://apparmor.net/"
9SECTION = "admin"
10
11LICENSE = "GPLv2 & GPLv2+ & BSD-3-Clause & LGPLv2.1+"
12LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=fd57a4b0bc782d7b80fd431f10bbf9d0"
13
14DEPENDS = "bison-native apr gettext-native coreutils-native swig-native"
15
16SRC_URI = " \
17 git://gitlab.com/apparmor/apparmor.git;protocol=https;branch=apparmor-3.0 \
18 file://disable_perl_h_check.patch \
19 file://crosscompile_perl_bindings.patch \
20 file://apparmor.rc \
21 file://functions \
22 file://apparmor \
23 file://apparmor.service \
24 file://0001-Makefile.am-suppress-perllocal.pod.patch \
25 file://run-ptest \
26 file://0001-apparmor-fix-manpage-order.patch \
27 file://0001-Revert-profiles-Update-make-check-to-select-tools-ba.patch \
28 file://0001-libapparmor-add-missing-include-for-socklen_t.patch \
29 file://0002-libapparmor-add-aa_features_new_from_file-to-public-.patch \
30 file://0003-libapparmor-add-_aa_asprintf-to-private-symbols.patch \
31 file://0001-aa_status-Fix-build-issue-with-musl.patch \
32 file://0001-parser-Makefile-dont-force-host-cpp-to-detect-reallo.patch \
33 "
34
35SRCREV = "5d51483bfecf556183558644dc8958135397a7e2"
36S = "${WORKDIR}/git"
37
38PARALLEL_MAKE = ""
39
40COMPATIBLE_MACHINE_mips64 = "(!.*mips64).*"
41
42inherit pkgconfig autotools-brokensep update-rc.d python3native perlnative cpan systemd features_check bash-completion
43
44REQUIRED_DISTRO_FEATURES = "apparmor"
45
46PACKAGECONFIG ?= "python perl aa-decode"
47PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man-pages"
48PACKAGECONFIG[python] = "--with-python, --without-python, python3 , python3-core python3-modules"
49PACKAGECONFIG[perl] = "--with-perl, --without-perl, "
50PACKAGECONFIG[apache2] = ",,apache2,"
51PACKAGECONFIG[aa-decode] = ",,,bash"
52
53python() {
54 if 'apache2' in d.getVar('PACKAGECONFIG').split() and \
55 'webserver' not in d.getVar('BBFILE_COLLECTIONS').split():
56 raise bb.parse.SkipRecipe('Requires meta-webserver to be present.')
57}
58
59DISABLE_STATIC = ""
60
61do_configure() {
62 cd ${S}/libraries/libapparmor
63 aclocal
64 autoconf --force
65 libtoolize --automake -c --force
66 automake -ac
67 ./configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
68}
69
70do_compile () {
71 sed -i "s@sed -ie 's///g' Makefile.perl@@" ${S}/libraries/libapparmor/swig/perl/Makefile
72 oe_runmake -C ${B}/libraries/libapparmor
73 oe_runmake -C ${B}/binutils
74 oe_runmake -C ${B}/utils
75 oe_runmake -C ${B}/parser
76 oe_runmake -C ${B}/profiles
77
78 if ${@bb.utils.contains('PACKAGECONFIG','apache2','true','false', d)}; then
79 oe_runmake -C ${B}/changehat/mod_apparmor
80 fi
81
82 if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
83 oe_runmake -C ${B}/changehat/pam_apparmor
84 fi
85}
86
87do_install () {
88 install -d ${D}/${INIT_D_DIR}
89 install -d ${D}/lib/apparmor
90 oe_runmake -C ${B}/libraries/libapparmor DESTDIR="${D}" install
91 oe_runmake -C ${B}/binutils DESTDIR="${D}" install
92 oe_runmake -C ${B}/utils DESTDIR="${D}" install
93 oe_runmake -C ${B}/parser DESTDIR="${D}" install
94 oe_runmake -C ${B}/profiles DESTDIR="${D}" install
95
96 if ! ${@bb.utils.contains('PACKAGECONFIG','aa-decode','true','false', d)}; then
97 rm -f ${D}${sbindir}/aa-decode
98 fi
99
100 if ${@bb.utils.contains('PACKAGECONFIG','apache2','true','false', d)}; then
101 oe_runmake -C ${B}/changehat/mod_apparmor DESTDIR="${D}" install
102 fi
103
104 if ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'true', 'false', d)}; then
105 install -d ${D}/lib/security
106 oe_runmake -C ${B}/changehat/pam_apparmor DESTDIR="${D}" install
107 fi
108
109 install -m 755 ${WORKDIR}/apparmor ${D}/${INIT_D_DIR}/apparmor
110 install -m 755 ${WORKDIR}/functions ${D}/lib/apparmor
111
112 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
113 install -d ${D}${systemd_system_unitdir}
114 install -m 0644 ${WORKDIR}/apparmor.service ${D}${systemd_system_unitdir}
115 fi
116}
117
118#Building ptest on arm fails.
119do_compile_ptest_aarch64 () {
120 :
121}
122
123do_compile_ptest_arm () {
124 :
125}
126
127do_compile_ptest () {
128 sed -i -e 's/cpp \-dM/${HOST_PREFIX}gcc \-dM/' ${B}/tests/regression/apparmor/Makefile
129 oe_runmake -C ${B}/tests/regression/apparmor USE_SYSTEM=0
130 oe_runmake -C ${B}/libraries/libapparmor
131}
132
133do_install_ptest () {
134 t=${D}/${PTEST_PATH}/testsuite
135 install -d ${t}
136 install -d ${t}/tests/regression/apparmor
137 cp -rf ${B}/tests/regression/apparmor ${t}/tests/regression
138
139 cp ${B}/parser/apparmor_parser ${t}/parser
140 cp ${B}/parser/frob_slack_rc ${t}/parser
141
142 install -d ${t}/libraries/libapparmor
143 cp -rf ${B}/libraries/libapparmor ${t}/libraries
144
145 install -d ${t}/common
146 cp -rf ${B}/common ${t}
147
148 install -d ${t}/binutils
149 cp -rf ${B}/binutils ${t}
150}
151
152#Building ptest on arm fails.
153do_install_ptest_aarch64 () {
154 :
155}
156
157do_install_ptest_arm() {
158 :
159}
160
161pkg_postinst_ontarget_${PN} () {
162if [ ! -d /etc/apparmor.d/cache ] ; then
163 mkdir /etc/apparmor.d/cache
164fi
165}
166
167# We need the init script so don't rm it
168RMINITDIR_class-target_remove = " rm_sysvinit_initddir"
169
170INITSCRIPT_PACKAGES = "${PN}"
171INITSCRIPT_NAME = "apparmor"
172INITSCRIPT_PARAMS = "start 16 2 3 4 5 . stop 35 0 1 6 ."
173
174SYSTEMD_PACKAGES = "${PN}"
175SYSTEMD_SERVICE_${PN} = "apparmor.service"
176SYSTEMD_AUTO_ENABLE ?= "enable"
177
178PACKAGES += "mod-${PN}"
179
180FILES_${PN} += "/lib/apparmor/ /lib/security/ ${sysconfdir}/apparmor ${PYTHON_SITEPACKAGES_DIR}"
181FILES_mod-${PN} = "${libdir}/apache2/modules/*"
182
183DEPENDS_append_libc-musl = " fts "
184RDEPENDS_${PN}_libc-musl += "musl-utils"
185RDEPENDS_${PN}_libc-glibc += "glibc-utils"
186
187# Add coreutils and findutils only if sysvinit scripts are in use
188RDEPENDS_${PN} += "${@["coreutils findutils", ""][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd')]} ${@bb.utils.contains('PACKAGECONFIG','python','python3-core python3-modules','', d)}"
189RDEPENDS_${PN}_remove += "${@bb.utils.contains('PACKAGECONFIG','perl','','perl', d)}"
190RDEPENDS_${PN}-ptest += "perl coreutils dbus-lib bash"
191
192INSANE_SKIP_${PN} = "ldflags"
193PRIVATE_LIBS_${PN}-ptest = "libapparmor.so*"