diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-04 15:13:05 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-04 15:13:05 +0300 |
| commit | ade6c544dc474fd32378067b7b179580495fcb84 (patch) | |
| tree | 2ab500780a815daa7fd72f8670fe51c44018b3b0 | |
| parent | 688a2b313e6d20044e0d32c7fa6309d183f2400f (diff) | |
Enforce photoalbum generated script drift check (5j0)
| -rw-r--r-- | Justfile | 44 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | README.md | 7 |
3 files changed, 48 insertions, 7 deletions
@@ -15,16 +15,49 @@ all: build version: printf '%s\n' "{{VERSION}}" +[script] build: mkdir -p ./bin + generated=$(mktemp "./bin/.{{NAME}}.XXXXXX") + trap 'rm -f "$generated"' EXIT sed "s/PHOTOALBUMVERSION/{{VERSION}}/" \ - "src/{{NAME}}.sh" > "./bin/{{NAME}}" - chmod 0755 "./bin/{{NAME}}" + "src/{{NAME}}.sh" > "$generated" + chmod 0755 "$generated" + if [ -f "./bin/{{NAME}}" ] && cmp -s "$generated" "./bin/{{NAME}}"; then + chmod 0755 "./bin/{{NAME}}" + rm -f "$generated" + else + mv "$generated" "./bin/{{NAME}}" + fi -test: build +[script] +check-generated: + generated=$(mktemp) + trap 'rm -f "$generated"' EXIT + sed "s/PHOTOALBUMVERSION/{{VERSION}}/" \ + "src/{{NAME}}.sh" > "$generated" + chmod 0755 "$generated" + if [ ! -f "./bin/{{NAME}}" ]; then + printf '%s\n' \ + "ERROR: ./bin/{{NAME}} is missing; run 'just build'." >&2 + exit 1 + fi + if [ ! -x "./bin/{{NAME}}" ]; then + printf '%s\n' \ + "ERROR: ./bin/{{NAME}} is not executable; run 'just build'." >&2 + exit 1 + fi + if ! cmp -s "$generated" "./bin/{{NAME}}"; then + printf '%s\n' \ + "ERROR: ./bin/{{NAME}} is stale; run 'just build'." >&2 + diff -u "./bin/{{NAME}}" "$generated" || true + exit 1 + fi + +test: check-generated build bash ./tests/cli.sh -install: build +install: check-generated build install -d "{{DESTDIR}}{{BINDIR}}" install -m 0755 "./bin/{{NAME}}" "{{DESTDIR}}{{BINDIR}}/{{NAME}}" install -d "{{DESTDIR}}{{DATADIR}}/{{NAME}}" @@ -43,7 +76,8 @@ deinstall: uninstall: deinstall clean: - rm -rf ./bin + find ./bin -maxdepth 1 -type f -name '.{{NAME}}.*' -delete \ + 2>/dev/null || true shellcheck: # SC1090: ShellCheck can't follow non-constant source. @@ -1,4 +1,4 @@ -.PHONY: all build clean deinstall install shellcheck test uninstall version +.PHONY: all build check-generated clean deinstall install shellcheck test uninstall version -all build clean deinstall install shellcheck test uninstall version: +all build check-generated clean deinstall install shellcheck test uninstall version: just $@ @@ -13,6 +13,13 @@ just build sudo just install ``` +`bin/photoalbum` is a committed generated artifact for compatibility with +existing checkouts and packaging. Its source of truth is `src/photoalbum.sh` +rendered through the `VERSION` value in `Justfile`. Run `just build` after +changing either file, and use `just check-generated` to verify that the tracked +script has not drifted. `just test` and `just install` run that drift check +before rebuilding so stale committed output is not hidden. + `just install` installs `photoalbum` to `/usr/bin`, templates to `/usr/share/photoalbum/templates`, and the default config to `/etc/default/photoalbum`. Override paths with `DESTDIR`, `PREFIX`, `BINDIR`, |
