From d717a24adc5441e9fb51eca3e33ecb002a613243 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 16 Apr 2023 21:25:52 +0100 Subject: [PATCH] build: better way to handle package build for development purpose. --- Makefile | 52 +++++++++++++++++++++++++------------------------- dists/build.sh | 10 +++++++--- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 8a3dcb9d..46706420 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,22 @@ DESTDIR ?= / BUILD := .build PKGNAME := apparmor.d -DISTRIBUTION := $(shell lsb_release --id --short) VERSION := 0.$(shell git rev-list --count HEAD)-1 P = $(notdir $(wildcard ${BUILD}/apparmor.d/*)) -.PHONY: all install auto local $(P) lint archlinux debian ubuntu whonix clean +.PHONY: all build enforce full install local $(P) pkg dpkg rpm lint clean -all: +all: build + +build: @go build -o ${BUILD}/ ./cmd/aa-log +enforce: build + @./${BUILD}/prebuild + +full: build + @./${BUILD}/prebuild --complain --full + ROOT = $(shell find "${BUILD}/root" -type f -printf "%P\n") PROFILES = $(shell find "${BUILD}/apparmor.d" -type f -printf "%P\n") install: @@ -34,17 +41,6 @@ install: install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/user/$${service}.d/apparmor.conf"; \ done -auto: - @[ ${DISTRIBUTION} = Arch ] || exit 0; \ - makepkg --syncdeps --install --cleanbuild --force --noconfirm - @[ ${DISTRIBUTION} = Ubuntu ] || exit 0; \ - dch --newversion="${VERSION}" --urgency=medium --distribution=stable --controlmaint "Release ${VERSION}"; \ - dpkg-buildpackage -b -d --no-sign; \ - sudo dpkg -i "../apparmor.d_${VERSION}_all.deb"; \ - make clean - @[ ${DISTRIBUTION} = openSUSE ] || exit 0; \ - make local - local: @./configure --complain @make @@ -69,23 +65,27 @@ $(P): done; @systemctl restart apparmor || systemctl status apparmor +dist ?= archlinux +package: + @bash dists/build.sh ${dist} + +pkg: + @makepkg --syncdeps --install --cleanbuild --force --noconfirm + +dpkg: + @dch --newversion="${VERSION}" --urgency=medium --distribution=stable --controlmaint "Release ${VERSION}" + @dpkg-buildpackage -b -d --no-sign + @sudo dpkg -i "../apparmor.d_${VERSION}_all.deb" + @make clean + +rpm: + @make local + lint: @shellcheck --shell=bash \ PKGBUILD configure dists/build.sh \ debian/${PKGNAME}.postinst debian/${PKGNAME}.postrm -archlinux: - @bash dists/build.sh archlinux - -debian: - @bash dists/build.sh debian - -ubuntu: - @bash dists/build.sh ubuntu - -whonix: - @bash dists/build.sh whonix - clean: @rm -rf \ debian/.debhelper debian/debhelper* debian/*.debhelper debian/${PKGNAME} \ diff --git a/dists/build.sh b/dists/build.sh index 5247f802..782d3f59 100644 --- a/dists/build.sh +++ b/dists/build.sh @@ -62,8 +62,7 @@ build_in_docker_makepkg() { "$BASEIMAGE/$dist" fi - docker exec --workdir="$BUILDIR/" "$img" \ - makepkg -sfC --noconfirm --noprogressbar + docker exec --workdir="$BUILDIR/" "$img" makepkg -sfC --noconfirm --noprogressbar mv "$VOLUME/$PKGNAME"-*.pkg.* . } @@ -95,7 +94,8 @@ build_in_docker_dpkg() { main() { case "$COMMAND" in archlinux) - build_in_docker_makepkg "$COMMAND" + # build_in_docker_makepkg "$COMMAND" + PKGDEST=. makepkg -Cf ;; debian | ubuntu | whonix) @@ -103,6 +103,10 @@ main() { build_in_docker_dpkg "$COMMAND" ;; + opensuse) + echo "Work in progress" + ;; + *) ;; esac }