Add install/uninstall safety check via --signature flag

Automated-By: Claude Sonnet 4.6
This commit is contained in:
2026-05-28 22:24:48 -04:00
parent 3fa83858e4
commit f0bd10ef66
2 changed files with 30 additions and 7 deletions
+21 -7
View File
@@ -1,13 +1,27 @@
PREFIX ?= $(HOME)/.local/bin
PREFIX ?= $(HOME)/.local/bin
TARGET := $(PREFIX)/CodeMapper
SIG := CODEMAPPER-SIGNATURE-izackp
.PHONY: build install uninstall
.PHONY: build install uninstall _check_existing
build:
swift build -c release
install: build
install -d $(PREFIX)
install .build/release/CodeMapper $(PREFIX)/CodeMapper
_check_existing:
@if [ -f "$(TARGET)" ]; then \
GOT=$$("$(TARGET)" --signature 2>/dev/null || true); \
if [ "$$GOT" != "$(SIG)" ]; then \
if [ "$(FORCE)" != "1" ]; then \
echo "ERROR: $(TARGET) exists but is not this CodeMapper build."; \
echo " Pass FORCE=1 to override."; \
exit 1; \
fi; \
fi \
fi
uninstall:
rm -f $(PREFIX)/CodeMapper
install: build _check_existing
install -d $(PREFIX)
install .build/release/CodeMapper $(TARGET)
uninstall: _check_existing
rm -f $(TARGET)