Files
apparmor/source.sh
T
2026-04-07 18:45:25 +03:00

56 lines
2.2 KiB
Bash

# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
# The prepare function is executed in the root of the temp directory
# This function is used for putting downloaded files to the correct location or applying patches
prepare() {
cd "$BPM_SOURCE"/libraries/libapparmor
autoreconf -fi
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
cd "$BPM_SOURCE"/libraries/libapparmor
./configure --prefix=/usr --with-perl --with-python --with-ruby
make
cd "$BPM_SOURCE"
make -C binutils
make -C parser
make -C profiles
make -C utils
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package() {
make -C libraries/libapparmor DESTDIR="$BPM_OUTPUT" install
make -C binutils DESTDIR="$BPM_OUTPUT" install
make -C parser -j1 DESTDIR="$BPM_OUTPUT" SBINDIR="$BPM_OUTPUT"/usr/sbin APPARMOR_BIN_PREFIX="$BPM_OUTPUT"/usr/lib/apparmor install install-systemd
make -C profiles DESTDIR="$BPM_OUTPUT" install
make -C utils DESTDIR="$BPM_OUTPUT" install
# Install esvm service
install -Dm644 "$BPM_WORKDIR"/apparmor.esv "$BPM_OUTPUT"/etc/esvm/services/apparmor.esv
# Remove systemd directory
rm -r "$BPM_OUTPUT"/usr/lib/systemd
# Set file mode to allow the perl library to be stripped:
# https://gitlab.com/apparmor/apparmor/issues/34
find "$BPM_OUTPUT"/usr/lib/perl/ -type f -iname "*.so" -exec chmod 755 {} \;
# Remove empty core_perl directory:
# https://gitlab.com/apparmor/apparmor/issues/40
rm -r "$BPM_OUTPUT"/usr/lib/perl/*/core_perl
# Move ruby bindings to vendor_ruby:
# https://gitlab.com/apparmor/apparmor/issues/35
mv "$BPM_OUTPUT"/usr/lib/ruby/{site,vendor}_ruby
# Install package license
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/apparmor/LICENSE
}