build: better way to handle package build for development purpose.

This commit is contained in:
Alexandre Pujol 2023-04-16 21:25:52 +01:00
parent 2f455786e7
commit d717a24adc
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
2 changed files with 33 additions and 29 deletions

View File

@ -6,15 +6,22 @@
DESTDIR ?= / DESTDIR ?= /
BUILD := .build BUILD := .build
PKGNAME := apparmor.d PKGNAME := apparmor.d
DISTRIBUTION := $(shell lsb_release --id --short)
VERSION := 0.$(shell git rev-list --count HEAD)-1 VERSION := 0.$(shell git rev-list --count HEAD)-1
P = $(notdir $(wildcard ${BUILD}/apparmor.d/*)) 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 @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") ROOT = $(shell find "${BUILD}/root" -type f -printf "%P\n")
PROFILES = $(shell find "${BUILD}/apparmor.d" -type f -printf "%P\n") PROFILES = $(shell find "${BUILD}/apparmor.d" -type f -printf "%P\n")
install: install:
@ -34,17 +41,6 @@ install:
install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/user/$${service}.d/apparmor.conf"; \ install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/user/$${service}.d/apparmor.conf"; \
done 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: local:
@./configure --complain @./configure --complain
@make @make
@ -69,23 +65,27 @@ $(P):
done; done;
@systemctl restart apparmor || systemctl status apparmor @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: lint:
@shellcheck --shell=bash \ @shellcheck --shell=bash \
PKGBUILD configure dists/build.sh \ PKGBUILD configure dists/build.sh \
debian/${PKGNAME}.postinst debian/${PKGNAME}.postrm 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: clean:
@rm -rf \ @rm -rf \
debian/.debhelper debian/debhelper* debian/*.debhelper debian/${PKGNAME} \ debian/.debhelper debian/debhelper* debian/*.debhelper debian/${PKGNAME} \

View File

@ -62,8 +62,7 @@ build_in_docker_makepkg() {
"$BASEIMAGE/$dist" "$BASEIMAGE/$dist"
fi fi
docker exec --workdir="$BUILDIR/" "$img" \ docker exec --workdir="$BUILDIR/" "$img" makepkg -sfC --noconfirm --noprogressbar
makepkg -sfC --noconfirm --noprogressbar
mv "$VOLUME/$PKGNAME"-*.pkg.* . mv "$VOLUME/$PKGNAME"-*.pkg.* .
} }
@ -95,7 +94,8 @@ build_in_docker_dpkg() {
main() { main() {
case "$COMMAND" in case "$COMMAND" in
archlinux) archlinux)
build_in_docker_makepkg "$COMMAND" # build_in_docker_makepkg "$COMMAND"
PKGDEST=. makepkg -Cf
;; ;;
debian | ubuntu | whonix) debian | ubuntu | whonix)
@ -103,6 +103,10 @@ main() {
build_in_docker_dpkg "$COMMAND" build_in_docker_dpkg "$COMMAND"
;; ;;
opensuse)
echo "Work in progress"
;;
*) ;; *) ;;
esac esac
} }