From d0ea790c6a934de508063d19ba3b615a8fc4cd69 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Fri, 26 Nov 2021 23:40:11 +0100 Subject: [PATCH] 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. --- Makefile | 10 +++++++--- README.md | 4 ++++ libkeyringctl/keyring.py | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index abb4e36..f60c5b7 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 446564d..cadd6fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/libkeyringctl/keyring.py b/libkeyringctl/keyring.py index d62576b..b7060b7 100644 --- a/libkeyringctl/keyring.py +++ b/libkeyringctl/keyring.py @@ -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)