Files
BMLFS/build-scripts/apparmor.build
2025-09-25 13:05:46 -05:00

92 lines
3.0 KiB
Bash

#! /bin/bash
# AppArmor
# Source: https://gitlab.com/apparmor/apparmor/-/archive/v4.1.2/apparmor-v4.1.2.tar.bz2
#
# $BUILD = Directory to temporarily install
# $PKGS = Directory to store built packages
#
# DEPS
# Required: linux-pam swig autoconf-archive
# Recommended: NONE
# Optional: NONE
# Apply patches from Alpine Linux
patch -Np1 -i ../patches/apparmor-alpine/0001-Fix-linking-against-gettext-on-musl-libc.patch
patch -Np1 -i ../patches/apparmor-alpine/0006-utils-adjust-rc-functions-for-aa-remove-unknown.patch
patch -Np1 -i ../patches/apparmor-alpine/fix-dnsmasq-profile.patch
# Set environment
export PVER="4.1.2"
export PYTHON=/usr/bin/python3
export PYTHON_VERSION=3
export PYTHON_VERSIONS=python3
common/list_af_names.sh > parser/base_af_names.h
# Build the libraries
cd libraries/libapparmor
./autogen.sh
./configure --prefix=/usr --with-python --with-perl
make -j2
cd ../..
# Build binary utilities
make -C binutils -j2
# Build the parser
make -C parser -j2
# Build the utilities
make -C utils -j2
# Build the profiles
make -C profiles
# Build apparmor-pam
make -C changehat/pam_apparmor -j2
# Build apparmor-vim
make -C utils/vim -j2
# Install
sudo -S make -C libraries/libapparmor install DESTDIR=$BUILD && \
sudo -S make -C changehat/pam_apparmor install DESTDIR=$BUILD/usr && \
sudo -S make -C binutils install DESTDIR=$BUILD BINDIR=$BUILD/usr/bin && \
sudo -S make -C parser install DESTDIR=$BUILD BINDIR=$BUILD/usr/bin && \
sudo -S make -C profiles install DESTDIR=$BUILD
sudo -S make -C utils install DESTDIR=$BUILD DINDIR=$BUILD/usr/bin \
VIM_INSTALL_PATH=$BUILD/usr/share/vim/vimfiles/syntax
# Fix directories & paths
sudo -S mv $BUILD/lib $BUILD/usr/lib/
sudo -S mkdir -pv $BUILD/usr/libexec/apparmor
sudo -S mv $BUILD/usr/lib/lib/apparmor/rc.apparmor.functions \
$BUILD/usr/libexec/apparmor/
sudo -S rm -rv $BUILD/usr/lib/lib
cd $BUILD && sudo -S mkdir -v ${BUILD}/install &&
cat > /tmp/slack-desc << "EOF"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
apparmor: apparmor (Mandatory Access Control mechanism)
apparmor:
apparmor: AppArmor protects systems from insecure or untrusted processes by
apparmor: running them in restricted confinement, while still allowing
apparmor: processes to share files, exercise privilege and communicate with
apparmor: other processes. AppArmor is a Mandatory Access Control (MAC)
apparmor: mechanism which uses the Linux Security Module (LSM) framework.
apparmor:
apparmor:
apparmor: Homepage: https://gitlab.com/apparmor/
apparmor:
EOF
sudo -S mv -v /tmp/slack-desc install/ &&
sudo -S makepkg -l y -c n $PKGS/apparmor-$PVER-$PSUFFIX &&
sudo -S rm -rf ${BUILD}/*