blob: 6183064f4044a0381dcb063f61e5d8c811e25a34 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001SUMMARY = "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"
15
16SRC_URI = " \
Brad Bishopc342db32019-05-15 21:57:59 -040017 git://gitlab.com/apparmor/apparmor.git;protocol=https;branch=apparmor-2.13 \
Brad Bishop19323692019-04-05 15:28:33 -040018 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 \
Brad Bishopf0244752019-09-30 07:50:12 -040024 file://0001-Makefile.am-suppress-perllocal.pod.patch \
Brad Bishop19323692019-04-05 15:28:33 -040025 file://run-ptest \
26 "
27
Brad Bishop49e29a12019-09-01 15:21:06 -040028SRCREV = "2f9d9ea7e01a115b29858455d3b1b5c6a0bab75c"
Brad Bishopc342db32019-05-15 21:57:59 -040029S = "${WORKDIR}/git"
Brad Bishop19323692019-04-05 15:28:33 -040030
31PARALLEL_MAKE = ""
32
33inherit pkgconfig autotools-brokensep update-rc.d python3native perlnative ptest cpan manpages systemd
34
Brad Bishop64940c32019-10-15 07:47:39 -040035PACKAGECONFIG ??= "python perl aa-decode"
Brad Bishop19323692019-04-05 15:28:33 -040036PACKAGECONFIG[manpages] = "--enable-man-pages, --disable-man-pages"
37PACKAGECONFIG[python] = "--with-python, --without-python, python3 swig-native"
38PACKAGECONFIG[perl] = "--with-perl, --without-perl, perl perl-native swig-native"
39PACKAGECONFIG[apache2] = ",,apache2,"
Brad Bishop64940c32019-10-15 07:47:39 -040040PACKAGECONFIG[aa-decode] = ",,,bash"
Brad Bishop19323692019-04-05 15:28:33 -040041
42PAMLIB="${@bb.utils.contains('DISTRO_FEATURES', 'pam', '1', '0', d)}"
43HTTPD="${@bb.utils.contains('PACKAGECONFIG', 'apache2', '1', '0', d)}"
44
45
46python() {
47 if 'apache2' in d.getVar('PACKAGECONFIG').split() and \
48 'webserver' not in d.getVar('BBFILE_COLLECTIONS').split():
49 raise bb.parse.SkipRecipe('Requires meta-webserver to be present.')
50}
51
52DISABLE_STATIC = ""
53
54do_configure() {
55 cd ${S}/libraries/libapparmor
56 aclocal
57 autoconf --force
58 libtoolize --automake -c --force
59 automake -ac
60 ./configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
61}
62
63do_compile () {
64 # Fixes:
65 # | sed -ie 's///g' Makefile.perl
66 # | sed: -e expression #1, char 0: no previous regular expression
67 #| Makefile:478: recipe for target 'Makefile.perl' failed
68 sed -i "s@sed -ie 's///g' Makefile.perl@@" ${S}/libraries/libapparmor/swig/perl/Makefile
69
70
71 oe_runmake -C ${B}/libraries/libapparmor
72 oe_runmake -C ${B}/binutils
73 oe_runmake -C ${B}/utils
74 oe_runmake -C ${B}/parser
75 oe_runmake -C ${B}/profiles
76
77 if test -z "${HTTPD}" ; then
78 oe_runmake -C ${B}/changehat/mod_apparmor
79 fi
80
81 if test -z "${PAMLIB}" ; then
82 oe_runmake -C ${B}/changehat/pam_apparmor
83 fi
84}
85
86do_install () {
87 install -d ${D}/${INIT_D_DIR}
88 install -d ${D}/lib/apparmor
89
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 perl is disabled this script won't be any good
97 if ! ${@bb.utils.contains('PACKAGECONFIG','perl','true','false', d)}; then
98 rm -f ${D}${sbindir}/aa-notify
99 fi
100
Brad Bishop64940c32019-10-15 07:47:39 -0400101 if ! ${@bb.utils.contains('PACKAGECONFIG','aa-decode','true','false', d)}; then
102 rm -f ${D}${sbindir}/aa-decode
103 fi
104
Brad Bishop19323692019-04-05 15:28:33 -0400105 if test -z "${HTTPD}" ; then
106 oe_runmake -C ${B}/changehat/mod_apparmor DESTDIR="${D}" install
107 fi
108
109 if test -z "${PAMLIB}" ; then
110 oe_runmake -C ${B}/changehat/pam_apparmor DESTDIR="${D}" install
111 fi
112
113 # aa-easyprof is installed by python-tools-setup.py, fix it up
114 sed -i -e 's:/usr/bin/env.*:/usr/bin/python3:' ${D}${bindir}/aa-easyprof
115 chmod 0755 ${D}${bindir}/aa-easyprof
116
117 install ${WORKDIR}/apparmor ${D}/${INIT_D_DIR}/apparmor
118 install ${WORKDIR}/functions ${D}/lib/apparmor
119 install -d ${D}${systemd_system_unitdir}
120 install ${WORKDIR}/apparmor.service ${D}${systemd_system_unitdir}
121}
122
123do_compile_ptest () {
124 oe_runmake -C ${B}/tests/regression/apparmor
125 oe_runmake -C ${B}/parser/tst
126 oe_runmake -C ${B}/libraries/libapparmor
127}
128
129do_install_ptest () {
130 t=${D}/${PTEST_PATH}/testsuite
131 install -d ${t}
132 install -d ${t}/tests/regression/apparmor
133 cp -rf ${B}/tests/regression/apparmor ${t}/tests/regression
134
135 install -d ${t}/parser/tst
136 cp -rf ${B}/parser/tst ${t}/parser
137 cp ${B}/parser/apparmor_parser ${t}/parser
138 cp ${B}/parser/frob_slack_rc ${t}/parser
139
140 install -d ${t}/libraries/libapparmor
141 cp -rf ${B}/libraries/libapparmor ${t}/libraries
142
143 install -d ${t}/common
144 cp -rf ${B}/common ${t}
145
146 install -d ${t}/binutils
147 cp -rf ${B}/binutils ${t}
148}
149
Brad Bishop49e29a12019-09-01 15:21:06 -0400150pkg_postinst_ontarget_${PN} () {
151if [ ! -d /etc/apparmor.d/cache ] ; then
152 mkdir /etc/apparmor.d/cache
153fi
154}
155
Brad Bishop19323692019-04-05 15:28:33 -0400156INITSCRIPT_PACKAGES = "${PN}"
157INITSCRIPT_NAME = "apparmor"
158INITSCRIPT_PARAMS = "start 16 2 3 4 5 . stop 35 0 1 6 ."
159
160SYSTEMD_PACKAGES = "${PN}"
161SYSTEMD_SERVICE_${PN} = "apparmor.service"
162SYSTEMD_AUTO_ENABLE = "disable"
163
164PACKAGES += "mod-${PN}"
165
166FILES_${PN} += "/lib/apparmor/ ${sysconfdir}/apparmor ${PYTHON_SITEPACKAGES_DIR}"
167FILES_mod-${PN} = "${libdir}/apache2/modules/*"
168
Brad Bishop49e29a12019-09-01 15:21:06 -0400169RDEPENDS_${PN} += "${@bb.utils.contains('PACKAGECONFIG','python','python3-core python3-modules','', d)}"
Brad Bishop19323692019-04-05 15:28:33 -0400170RDEPENDS_${PN}_remove += "${@bb.utils.contains('PACKAGECONFIG','perl','','perl', d)}"
171RDEPENDS_${PN}-ptest += "perl coreutils dbus-lib bash"
Brad Bishop64940c32019-10-15 07:47:39 -0400172
173PRIVATE_LIBS_${PN}-ptest = "libapparmor.so*"