mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-11 14:57:07 +01:00
build: move build logic in the Makefile.
This commit is contained in:
parent
62f2163875
commit
a470063f0f
4 changed files with 28 additions and 49 deletions
29
Makefile
29
Makefile
|
@ -1,14 +1,35 @@
|
||||||
#!/usr/bin/make -f
|
#!/usr/bin/make -f
|
||||||
|
# apparmor.d - Full set of apparmor profiles
|
||||||
|
# Copyright (C) 2022 Alexandre Pujol <alexandre@pujol.io>
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
DESTDIR ?= /
|
||||||
|
BUILD := .build
|
||||||
PKGNAME := apparmor.d
|
PKGNAME := apparmor.d
|
||||||
|
|
||||||
.PHONY: install lint archlinux debian ubuntu whonix clean
|
.PHONY: all install lint archlinux debian ubuntu whonix clean
|
||||||
|
|
||||||
all:
|
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:
|
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:
|
lint:
|
||||||
@shellcheck --shell=bash \
|
@shellcheck --shell=bash \
|
||||||
|
@ -31,4 +52,4 @@ clean:
|
||||||
@rm -rf \
|
@rm -rf \
|
||||||
debian/.debhelper debian/debhelper* debian/*.debhelper \
|
debian/.debhelper debian/debhelper* debian/*.debhelper \
|
||||||
${PKGNAME}-*.pkg.tar.zst.sig ${PKGNAME}-*.pkg.tar.zst \
|
${PKGNAME}-*.pkg.tar.zst.sig ${PKGNAME}-*.pkg.tar.zst \
|
||||||
${PKGNAME}_*.* .build
|
${PKGNAME}_*.* ${BUILD}
|
||||||
|
|
27
PKGBUILD
27
PKGBUILD
|
@ -23,7 +23,6 @@ pkgver() {
|
||||||
prepare() {
|
prepare() {
|
||||||
rsync -a --delete "$startdir" "$srcdir"
|
rsync -a --delete "$startdir" "$srcdir"
|
||||||
cd "$srcdir/$pkgname"
|
cd "$srcdir/$pkgname"
|
||||||
|
|
||||||
./configure --complain
|
./configure --complain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,32 +33,10 @@ build() {
|
||||||
export CGO_CXXFLAGS="${CXXFLAGS}"
|
export CGO_CXXFLAGS="${CXXFLAGS}"
|
||||||
export CGO_LDFLAGS="${LDFLAGS}"
|
export CGO_LDFLAGS="${LDFLAGS}"
|
||||||
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
|
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
|
||||||
go build -o .build/ ./cmd/aa-log
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
local _build='.build'
|
|
||||||
cd "$srcdir/$pkgname"
|
cd "$srcdir/$pkgname"
|
||||||
|
make install DESTDIR="$pkgdir"
|
||||||
# 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
|
|
||||||
}
|
}
|
||||||
|
|
6
debian/apparmor.d.install
vendored
6
debian/apparmor.d.install
vendored
|
@ -1,6 +0,0 @@
|
||||||
# Copyright (C) 2021 Alexandre Pujol <alexandre@pujol.io>
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
|
|
||||||
.build/apparmor.d/* etc/apparmor.d
|
|
||||||
.build/root/etc/* etc/
|
|
||||||
.build/root/usr/* usr/
|
|
15
debian/rules
vendored
15
debian/rules
vendored
|
@ -4,20 +4,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
%:
|
%:
|
||||||
dh $@ --with=config-package
|
dh $@
|
||||||
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
|
|
||||||
|
|
||||||
override_dh_auto_configure:
|
override_dh_auto_configure:
|
||||||
./configure --complain
|
./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
|
|
||||||
|
|
Loading…
Reference in a new issue