From a470063f0f995e0025aa27839566578151024731 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sat, 15 Oct 2022 23:11:31 +0100 Subject: [PATCH] build: move build logic in the Makefile. --- Makefile | 29 +++++++++++++++++++++++++---- PKGBUILD | 27 ++------------------------- debian/apparmor.d.install | 6 ------ debian/rules | 15 +-------------- 4 files changed, 28 insertions(+), 49 deletions(-) delete mode 100644 debian/apparmor.d.install diff --git a/Makefile b/Makefile index fdbfff7d..08896e04 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,35 @@ #!/usr/bin/make -f +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2022 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only +DESTDIR ?= / +BUILD := .build PKGNAME := apparmor.d -.PHONY: install lint archlinux debian ubuntu whonix clean +.PHONY: all install lint archlinux debian ubuntu whonix clean all: - @echo "Nothing to do." + @go build -o ${BUILD}/ ./cmd/aa-log +ROOT = $(shell find "${BUILD}/root" -type f -printf "%P\n") +PROFILES = $(shell find "${BUILD}/apparmor.d" -type f -printf "%P\n") install: - @echo "Nothing to do." + @install -Dm755 ${BUILD}/aa-log ${DESTDIR}/usr/bin/aa-log + @for file in ${ROOT}; do \ + install -Dm0644 "${BUILD}/root/$${file}" "${DESTDIR}/$${file}"; \ + done; + @for file in ${PROFILES}; do \ + install -Dm0644 "${BUILD}/apparmor.d/$${file}" "${DESTDIR}/etc/apparmor.d/$${file}"; \ + done; + @for file in systemd/system/*; do \ + service="$$(basename "$$file")"; \ + install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/system/$${service}.d/apparmor.conf"; \ + done; + @for file in systemd/user/*; do \ + service="$$(basename "$$file")"; \ + install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/user/$${service}.d/apparmor.conf"; \ + done lint: @shellcheck --shell=bash \ @@ -31,4 +52,4 @@ clean: @rm -rf \ debian/.debhelper debian/debhelper* debian/*.debhelper \ ${PKGNAME}-*.pkg.tar.zst.sig ${PKGNAME}-*.pkg.tar.zst \ - ${PKGNAME}_*.* .build + ${PKGNAME}_*.* ${BUILD} diff --git a/PKGBUILD b/PKGBUILD index 721374e2..6fd2ac4c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -23,7 +23,6 @@ pkgver() { prepare() { rsync -a --delete "$startdir" "$srcdir" cd "$srcdir/$pkgname" - ./configure --complain } @@ -34,32 +33,10 @@ build() { export CGO_CXXFLAGS="${CXXFLAGS}" export CGO_LDFLAGS="${LDFLAGS}" export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" - go build -o .build/ ./cmd/aa-log + make } package() { - local _build='.build' cd "$srcdir/$pkgname" - - # Install all system files - mapfile -t root < <(find "$_build/root" -type f -printf "%P\n") - for file in "${root[@]}"; do - install -Dm0644 "$_build/root/$file" "$pkgdir/$file" - done - - # Install all apparmor profiles - mapfile -t profiles < <(find "$_build/apparmor.d" -type f -printf "%P\n") - for file in "${profiles[@]}"; do - install -Dm0644 "$_build/apparmor.d/$file" "$pkgdir/etc/apparmor.d/$file" - done - - # Ensure some systemd services do not start before apparmor rules are loaded - for file in systemd/*; do - service=$(basename "$file") - install -Dm0644 "$file" \ - "$pkgdir/usr/lib/systemd/system/$service.d/apparmor.conf" - done - - # Internal tool - install -Dm755 .build/aa-log "$pkgdir"/usr/bin/aa-log + make install DESTDIR="$pkgdir" } diff --git a/debian/apparmor.d.install b/debian/apparmor.d.install deleted file mode 100644 index 43b5f89e..00000000 --- a/debian/apparmor.d.install +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (C) 2021 Alexandre Pujol -# SPDX-License-Identifier: GPL-2.0-only - -.build/apparmor.d/* etc/apparmor.d -.build/root/etc/* etc/ -.build/root/usr/* usr/ diff --git a/debian/rules b/debian/rules index a2bb88e4..9640ea08 100755 --- a/debian/rules +++ b/debian/rules @@ -4,20 +4,7 @@ # %: - dh $@ --with=config-package - export CGO_CPPFLAGS="${CPPFLAGS}" - export CGO_CFLAGS="${CFLAGS}" - export CGO_CXXFLAGS="${CXXFLAGS}" - export CGO_LDFLAGS="${LDFLAGS}" - export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" - go build ./cmd/aa-log + dh $@ override_dh_auto_configure: ./configure --complain - -override_dh_install: - mv systemd system - find system -type f -exec \ - install -Dm0644 {} $$(pwd)/debian/apparmor.d/usr/lib/systemd/{}.d/apparmor.conf \; - install -Dm755 aa-log $$(pwd)/debian/apparmor.d/usr/bin/aa-log - dh_install