#!make # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2026 Bryan Joshua Pedini # makefile for skeptical-updater: install, lint and test targets. # Plain GNU make + bash + Docker (+ curl once, for `make vendor`); no other tooling. # `make` or `make help` lists the targets. Tests run entirely in Docker containers. SHELL := /bin/bash .SHELLFLAGS := -eu -o pipefail -c .ONESHELL: .NOTPARALLEL: .DEFAULT_GOAL := help MAKEFLAGS += --no-print-directory APPLET := skeptical-updater PREFIX ?= /usr/local DESTDIR ?= # ---- vendored test tooling, pinned -------------------------------------------- # To bump: set the new tag and the sha256sum of its GitHub tag tarball # (https://github.com/bats-core//archive/refs/tags/v.tar.gz), # then `rm -rf tests/vendor && make vendor`. BATS_VERSION := 1.14.0 BATS_SHA256 := bb537b70b15b732f6d8827dd6578e3d8ce166636ce1f18ea9a074184fcce9177 BATS_SUPPORT_VERSION := 0.3.0 BATS_SUPPORT_SHA256 := 7815237aafeb42ddcc1b8c698fc5808026d33317d8701d5ec2396e9634e2918f BATS_ASSERT_VERSION := 2.2.4 BATS_ASSERT_SHA256 := e305df20c4c36cba4570e10f1cd824efb1ae71d88b5ef474550781ebee04192f BATS_GITHUB := https://github.com/bats-core VENDOR := tests/vendor BATS := $(VENDOR)/bats-core/bin/bats # ---- tests ---------------------------------------------------------------------- SHELLCHECK_IMAGE ?= koalaman/shellcheck:stable UNIT_IMAGE ?= debian:12 E2E_IMAGES ?= tests/docker/images.txt E2E_ONLY ?= E2E_FAIL_FAST ?= 0 # discovery/ is frozen reference material (not shellcheck-clean, never edited): not linted. LINT_FILES := $(wildcard $(APPLET) tests/docker/*.sh tests/e2e/*.sh tests/e2e/fixtures/*.sh \ tests/e2e/*.bash tests/e2e/*.bats tests/unit/*.bash tests/unit/*.bats \ tests/unit/fakes/*.bash tests/unit/fakes/*/* tests/unit/data/rpm/db.bash) # $(call fetch,,,,) # Download github.com/bats-core/ tag v with curl into a temp dir, # verify its sha256 and that was extracted, then move it to tests/vendor/. define fetch tmp=$$(mktemp -d "$${TMPDIR:-/tmp}/skeptical-updater-vendor.XXXXXX") trap 'rm -rf -- "$$tmp"' EXIT url="$(BATS_GITHUB)/$(1)/archive/refs/tags/v$(2).tar.gz" echo "vendor: $(1) v$(2) <- $$url" curl -fsSL --retry 3 --proto '=https' -o "$$tmp/src.tar.gz" "$$url" if ! echo "$(3) $$tmp/src.tar.gz" | sha256sum -c --status -; then echo "vendor: $(1) v$(2): sha256 mismatch (expected $(3))" >&2; exit 1; fi mkdir -- "$$tmp/src" tar -xzf "$$tmp/src.tar.gz" -C "$$tmp/src" if [[ ! -f "$$tmp/src/$(1)-$(2)/$(4)" ]]; then echo "vendor: $(1) v$(2): $(4) not found in the tarball" >&2; exit 1; fi mkdir -p -- "$(VENDOR)" rm -rf -- "$(VENDOR)/$(1)" mv -- "$$tmp/src/$(1)-$(2)" "$(VENDOR)/$(1)" echo "$(1) v$(2) sha256:$(3) $$url" >"$(VENDOR)/$(1)/.vendored" echo "vendor: $(1) v$(2) -> $(VENDOR)/$(1)" endef .PHONY: help install uninstall lint vendor docker-snapshot docker-cleanup docker-cleanup-dry-run \ test test-no-cleanup test-unit test-e2e clean help: ## show this help (default target) @echo "usage: make [VAR=value ...]" echo echo "targets:" grep -hE '^[A-Za-z0-9_.-]+:.*## ' $(MAKEFILE_LIST) | awk -F ':.*## ' '{ printf " %-24s %s\n", $$1, $$2 }' echo echo "variables:" echo " PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) install location" echo " E2E_ONLY=