fix(make): use proper dependency tracking for the build output

Declare the whole keyring data as well as the code as input dependency
for the build target. This way we can properly depend on the build
target for installation without forcing rebuilding on every invocation.

A rebuild will be triggered if either the keyring or the source code
creating the build output changes.

The directories are added to the source dependencies on purpose to
guarantee that changes like deleted files will result in a rebuild.

The mtime of the build directory is force updated on every run to allow
make to track the output artifacts mtime compared against the
dependencies.
This commit is contained in:
Levente Polyak 2021-11-26 23:40:11 +01:00
parent 0ceb6c743e
commit d0ea790c6a
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
3 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,7 @@
PREFIX ?= /usr/local
KEYRING_TARGET_DIR=$(DESTDIR)$(PREFIX)/share/pacman/keyrings/
KEYRING_FILES=$(wildcard build/*.gpg) $(wildcard build/*-revoked) $(wildcard build/*-trusted)
SOURCES := $(shell find keyring) $(shell find libkeyringctl -name '*.py' -or -type d) keyringctl
all: build
@ -22,14 +23,17 @@ test:
coverage xml
coverage report --fail-under=100.0
build:
build: $(SOURCES)
./keyringctl -v build
install:
clean:
rm -rf build
install: build
install -vDm 755 $(KEYRING_FILES) -t $(KEYRING_TARGET_DIR)
uninstall:
rm -f $(KEYRING_TARGET_DIR)/archlinux{.gpg,-trusted,-revoked}
rmdir -p --ignore-fail-on-non-empty $(KEYRING_TARGET_DIR)
.PHONY: all lint fmt test build install uninstall
.PHONY: all lint fmt check test clean install uninstall

View File

@ -14,7 +14,11 @@ The PGP packets describing the main signing keys can be found below the
The following packages need to be installed to be able to create a PGP keyring
from the provided data structure and to install it:
Build:
* make
* findutils
Runtime:
* python
* sequoia-sq

View File

@ -1089,6 +1089,7 @@ def build(
"""
target_dir.mkdir(parents=True, exist_ok=True)
target_dir.touch()
keyring: Path = target_dir / Path("archlinux.gpg")
export(working_dir=working_dir, keyring_root=keyring_root, output=keyring)