chore: cosmetic.

This commit is contained in:
Alexandre Pujol 2025-09-02 00:06:57 +02:00
parent 4c84b572cd
commit e43d907808
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC

View file

@ -49,44 +49,44 @@ c := "--connect=qemu:///system"
# VM prefix # VM prefix
prefix := "aa-" prefix := "aa-"
[doc('Show this help message')] # Show this help message
help: help:
@just --list --unsorted @just --list --unsorted
@printf "\n%s\n" "See https://apparmor.pujol.io/development/ for more information." @printf "\n%s\n" "See https://apparmor.pujol.io/development/ for more information."
# Build the go programs
[group('build')] [group('build')]
[doc('Build the go programs')]
build: build:
@go build -o {{build}}/ ./cmd/aa-log @go build -o {{build}}/ ./cmd/aa-log
@go build -o {{build}}/ ./cmd/prebuild @go build -o {{build}}/ ./cmd/prebuild
# Prebuild the profiles in enforced mode
[group('build')] [group('build')]
[doc('Prebuild the profiles in enforced mode')]
enforce: build enforce: build
@./{{build}}/prebuild --buildir {{build}} @./{{build}}/prebuild --buildir {{build}}
# Prebuild the profiles in complain mode
[group('build')] [group('build')]
[doc('Prebuild the profiles in complain mode')]
complain: build complain: build
./{{build}}/prebuild --buildir {{build}} --complain ./{{build}}/prebuild --buildir {{build}} --complain
# Prebuild the profiles in FSP mode
[group('build')] [group('build')]
[doc('Prebuild the profiles in FSP mode')]
fsp: build fsp: build
@./{{build}}/prebuild --buildir {{build}} --full @./{{build}}/prebuild --buildir {{build}} --full
# Prebuild the profiles in FSP mode (complain)
[group('build')] [group('build')]
[doc('Prebuild the profiles in FSP mode (complain)')]
fsp-complain: build fsp-complain: build
@./{{build}}/prebuild --buildir {{build}} --complain --full @./{{build}}/prebuild --buildir {{build}} --complain --full
# Prebuild the profiles in FSP mode (debug)
[group('build')] [group('build')]
[doc('Prebuild the profiles in FSP mode (debug)')]
fsp-debug: build fsp-debug: build
@./{{build}}/prebuild --buildir {{build}} --complain --full --debug @./{{build}}/prebuild --buildir {{build}} --complain --full --debug
# Install prebuild profiles
[group('install')] [group('install')]
[doc('Install prebuild profiles')]
install: install:
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
@ -113,8 +113,8 @@ 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
# Locally install prebuild profiles
[group('install')] [group('install')]
[doc('Locally install prebuild profiles')]
local +names: local +names:
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
@ -135,39 +135,39 @@ local +names:
done; done;
systemctl restart apparmor || sudo journalctl -xeu apparmor.service systemctl restart apparmor || sudo journalctl -xeu apparmor.service
# Prebuild, install, and load a dev profile
[group('install')] [group('install')]
[doc('Prebuild, install, and load a dev profile')]
dev name: dev name:
go run ./cmd/prebuild --complain --file `find apparmor.d -iname {{name}}` go run ./cmd/prebuild --complain --file `find apparmor.d -iname {{name}}`
sudo install -Dm644 {{build}}/apparmor.d/{{name}} /etc/apparmor.d/{{name}} sudo install -Dm644 {{build}}/apparmor.d/{{name}} /etc/apparmor.d/{{name}}
sudo systemctl restart apparmor || sudo journalctl -xeu apparmor.service sudo systemctl restart apparmor || sudo journalctl -xeu apparmor.service
# Build & install apparmor.d on Arch based systems
[group('packages')] [group('packages')]
[doc('Build & install apparmor.d on Arch based systems')]
pkg: pkg:
@makepkg --syncdeps --install --cleanbuild --force --noconfirm @makepkg --syncdeps --install --cleanbuild --force --noconfirm
# Build & install apparmor.d on Debian based systems
[group('packages')] [group('packages')]
[doc('Build & install apparmor.d on Debian based systems')]
dpkg: dpkg:
@bash dists/build.sh dpkg @bash dists/build.sh dpkg
@sudo dpkg -i {{pkgdest}}/{{pkgname}}_*.deb @sudo dpkg -i {{pkgdest}}/{{pkgname}}_*.deb
# Build & install apparmor.d on OpenSUSE based systems
[group('packages')] [group('packages')]
[doc('Build & install apparmor.d on OpenSUSE based systems')]
rpm: rpm:
@bash dists/build.sh rpm @bash dists/build.sh rpm
@sudo rpm -ivh --force {{pkgdest}}/{{pkgname}}-*.rpm @sudo rpm -ivh --force {{pkgdest}}/{{pkgname}}-*.rpm
# Run the unit tests
[group('tests')] [group('tests')]
[doc('Run the unit tests')]
tests: tests:
@go test ./cmd/... -v -cover -coverprofile=coverage.out @go test ./cmd/... -v -cover -coverprofile=coverage.out
@go test ./pkg/... -v -cover -coverprofile=coverage.out @go test ./pkg/... -v -cover -coverprofile=coverage.out
@go tool cover -func=coverage.out @go tool cover -func=coverage.out
# Run the linters
[group('linter')] [group('linter')]
[doc('Run the linters')]
lint: lint:
golangci-lint run golangci-lint run
packer fmt tests/packer/ packer fmt tests/packer/
@ -177,34 +177,34 @@ lint:
tests/packer/init.sh tests/packer/src/aa-update tests/packer/clean.sh \ tests/packer/init.sh tests/packer/src/aa-update tests/packer/clean.sh \
debian/{{pkgname}}.postinst debian/{{pkgname}}.postrm debian/{{pkgname}}.postinst debian/{{pkgname}}.postrm
# Run style checks on the profiles
[group('linter')] [group('linter')]
[doc('Run style checks on the profiles')]
check: check:
@bash tests/check.sh @bash tests/check.sh
# Generate the man pages
[group('docs')] [group('docs')]
[doc('Generate the man pages')]
man: man:
@pandoc -t man -s -o share/man/man8/aa-log.8 share/man/man8/aa-log.md @pandoc -t man -s -o share/man/man8/aa-log.8 share/man/man8/aa-log.md
# Build the documentation
[group('docs')] [group('docs')]
[doc('Build the documentation')]
docs: docs:
@ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=true mkdocs build --strict @ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=true mkdocs build --strict
# Serve the documentation
[group('docs')] [group('docs')]
[doc('Serve the documentation')]
serve: serve:
@ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=false mkdocs serve @ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=false mkdocs serve
[doc('Remove all build artifacts')] # Remove all build artifacts
clean: clean:
@rm -rf \ @rm -rf \
debian/.debhelper debian/debhelper* debian/*.debhelper debian/{{pkgname}} \ debian/.debhelper debian/debhelper* debian/*.debhelper debian/{{pkgname}} \
{{pkgdest}}/{{pkgname}}* {{build}} coverage.out {{pkgdest}}/{{pkgname}}* {{build}} coverage.out
# Build the package in a clean OCI container
[group('packages')] [group('packages')]
[doc('Build the package in a clean OCI container')]
package dist: package dist:
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
@ -219,8 +219,8 @@ package dist:
fi fi
bash dists/docker.sh $dist $version bash dists/docker.sh $dist $version
# Build the VM image
[group('vm')] [group('vm')]
[doc('Build the VM image')]
img dist flavor: (package dist) img dist flavor: (package dist)
@mkdir -p {{base_dir}} @mkdir -p {{base_dir}}
packer build -force \ packer build -force \
@ -237,8 +237,8 @@ img dist flavor: (package dist)
-var output_dir={{output_dir}} \ -var output_dir={{output_dir}} \
tests/packer/ tests/packer/
# Create the machine
[group('vm')] [group('vm')]
[doc('Create the machine')]
create dist flavor: create dist flavor:
@cp -f {{base_dir}}/{{prefix}}{{dist}}-{{flavor}}.qcow2 {{vm}}/{{prefix}}{{dist}}-{{flavor}}.qcow2 @cp -f {{base_dir}}/{{prefix}}{{dist}}-{{flavor}}.qcow2 {{vm}}/{{prefix}}{{dist}}-{{flavor}}.qcow2
@virt-install {{c}} \ @virt-install {{c}} \
@ -257,53 +257,53 @@ create dist flavor:
--sound model=ich9 \ --sound model=ich9 \
--noautoconsole --noautoconsole
# Start a machine
[group('vm')] [group('vm')]
[doc('Start a machine')]
up dist flavor: up dist flavor:
@virsh {{c}} start {{prefix}}{{dist}}-{{flavor}} @virsh {{c}} start {{prefix}}{{dist}}-{{flavor}}
# Stops the machine
[group('vm')] [group('vm')]
[doc('Stops the machine')]
halt dist flavor: halt dist flavor:
@virsh {{c}} shutdown {{prefix}}{{dist}}-{{flavor}} @virsh {{c}} shutdown {{prefix}}{{dist}}-{{flavor}}
# Reboot the machine
[group('vm')] [group('vm')]
[doc('Reboot the machine')]
reboot dist flavor: reboot dist flavor:
@virsh {{c}} reboot {{prefix}}{{dist}}-{{flavor}} @virsh {{c}} reboot {{prefix}}{{dist}}-{{flavor}}
# Destroy the machine
[group('vm')] [group('vm')]
[doc('Destroy the machine')]
destroy dist flavor: destroy dist flavor:
@virsh {{c}} destroy {{prefix}}{{dist}}-{{flavor}} || true @virsh {{c}} destroy {{prefix}}{{dist}}-{{flavor}} || true
@virsh {{c}} undefine {{prefix}}{{dist}}-{{flavor}} --nvram @virsh {{c}} undefine {{prefix}}{{dist}}-{{flavor}} --nvram
@rm -fv {{vm}}/{{prefix}}{{dist}}-{{flavor}}.qcow2 @rm -fv {{vm}}/{{prefix}}{{dist}}-{{flavor}}.qcow2
# Connect to the machine
[group('vm')] [group('vm')]
[doc('Connect to the machine')]
ssh dist flavor: ssh dist flavor:
@ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` @ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}`
# Mount the shared directory on the machine
[group('vm')] [group('vm')]
[doc('Mount the shared directory on the machine')]
mount dist flavor: mount dist flavor:
@ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \ @ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \
sh -c 'mount | grep 0a31bc478ef8e2461a4b1cc10a24cc4 || sudo mount 0a31bc478ef8e2461a4b1cc10a24cc4' sh -c 'mount | grep 0a31bc478ef8e2461a4b1cc10a24cc4 || sudo mount 0a31bc478ef8e2461a4b1cc10a24cc4'
# Unmout the shared directory on the machine
[group('vm')] [group('vm')]
[doc('Unmout the shared directory on the machine')]
umount dist flavor: umount dist flavor:
@ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \ @ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \
sh -c 'true; sudo umount /home/{{username}}/Projects/apparmor.d || true' sh -c 'true; sudo umount /home/{{username}}/Projects/apparmor.d || true'
# List the machines
[group('vm')] [group('vm')]
[doc('List the machines')]
list: list:
@printf "{{BOLD}} %-4s %-22s %s{{NORMAL}}\n" "Id" "Distribution-Flavor" "State" @printf "{{BOLD}} %-4s %-22s %s{{NORMAL}}\n" "Id" "Distribution-Flavor" "State"
@virsh {{c}} list --all | grep {{prefix}} | sed 's/{{prefix}}//g' @virsh {{c}} list --all | grep {{prefix}} | sed 's/{{prefix}}//g'
# List the VM images
[group('vm')] [group('vm')]
[doc('List the VM images')]
images: images:
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
@ -320,8 +320,8 @@ images:
} }
' '
# List the VM images that can be created
[group('vm')] [group('vm')]
[doc('List the VM images that can be created')]
available: available:
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu -o pipefail set -eu -o pipefail
@ -337,36 +337,36 @@ available:
} }
' '
# Install dependencies for the integration tests
[group('tests')] [group('tests')]
[doc('Install dependencies for the integration tests')]
init: init:
@bash tests/requirements.sh @bash tests/requirements.sh
# Run the integration tests
[group('tests')] [group('tests')]
[doc('Run the integration tests')]
integration name="": integration name="":
bats --recursive --timing --print-output-on-failure tests/integration/{{name}} bats --recursive --timing --print-output-on-failure tests/integration/{{name}}
# Install dependencies for the integration tests (machine)
[group('tests')] [group('tests')]
[doc('Install dependencies for the integration tests (machine)')]
tests-init dist flavor: tests-init dist flavor:
@ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \ @ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \
just --justfile /home/{{username}}/Projects/apparmor.d/Justfile init just --justfile /home/{{username}}/Projects/apparmor.d/Justfile init
# Synchronize the integration tests (machine)
[group('tests')] [group('tests')]
[doc('Synchronize the integration tests (machine)')]
tests-sync dist flavor: tests-sync dist flavor:
@ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \ @ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \
rsync -a --delete /home/{{username}}/Projects/apparmor.d/tests/ /home/{{username}}/Projects/tests/ rsync -a --delete /home/{{username}}/Projects/apparmor.d/tests/ /home/{{username}}/Projects/tests/
# Re-synchronize the integration tests (machine)
[group('tests')] [group('tests')]
[doc('Re-synchronize the integration tests (machine)')]
tests-resync dist flavor: (mount dist flavor) \ tests-resync dist flavor: (mount dist flavor) \
(tests-sync dist flavor) \ (tests-sync dist flavor) \
(umount dist flavor) (umount dist flavor)
# Run the integration tests (machine)
[group('tests')] [group('tests')]
[doc('Run the integration tests (machine)')]
tests-run dist flavor name="": (tests-resync dist flavor) tests-run dist flavor name="": (tests-resync dist flavor)
ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \ ssh {{sshopt}} {{username}}@`just _get_ip {{dist}} {{flavor}}` \
bats --recursive --pretty --timing --print-output-on-failure \ bats --recursive --pretty --timing --print-output-on-failure \