-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (88 loc) · 3.98 KB
/
Copy pathMakefile
File metadata and controls
101 lines (88 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Makefile for pa - a simple password manager
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
RELEASE_DATE=$(shell git log -1 --format=%cd --date=short)
GIT_TAG:=$(shell git describe --tags)
GIT_COMMIT:=$(shell git rev-parse --short HEAD)
GIT_STATUS:=$(shell git status --porcelain)
# Development version handling
ifneq ($(GIT_STATUS),)
VERSION_STRING=$(GIT_TAG)-dirty
RELEASE_DATE_STRING=development
else
VERSION_STRING=$(GIT_TAG)
RELEASE_DATE_STRING=$(RELEASE_DATE)
endif
.PHONY: install uninstall test clean install-user verify help test-vars
.DEFAULT_GOAL := help
help:
@echo "pa - a simple password manager"
@echo ""
@echo "Available targets:"
@echo " install - Install pa to $(BINDIR) (requires sudo)"
@echo " install-user - Install pa to ~/.local/bin"
@echo " uninstall - Remove pa from $(BINDIR)"
@echo " test - Run syntax and functionality tests"
@echo " test-vars - Show version variables and development status"
@echo " verify - Verify installation and dependencies"
@echo " clean - Clean up test files"
@echo " help - Show this help message"
install:
@echo "Installing pa to $(BINDIR)..."
@mkdir -p $(BINDIR)
@sed -e 's/PA_VERSION="__VERSION__"/PA_VERSION="$(VERSION_STRING)"/g' -e 's/PA_RELEASE_DATE="__RELEASE_DATE__"/PA_RELEASE_DATE="$(RELEASE_DATE_STRING)"/g' -e 's/PA_COMMIT="__COMMIT__"/PA_COMMIT="$(GIT_COMMIT)"/g' pa > pa.tmp
@install -m 755 pa.tmp $(BINDIR)/pa
@rm pa.tmp
@echo "pa installed successfully to $(BINDIR)/pa"
@echo ""
@echo "Make sure the following dependencies are installed:"
@echo " Platform-specific installation:"
@echo " macOS: brew install age fzf age-plugin-se"
@echo " Linux: apt install age fzf libsecret-tools"
@echo " Windows: choco install age fzf (or scoop install age fzf)"
@echo " Optional: age-plugin-yubikey (YubiKey support on all platforms)"
uninstall:
@echo "Removing pa from $(BINDIR)..."
@rm -f $(BINDIR)/pa
@echo "pa uninstalled successfully"
test:
@echo "Running syntax check..."
@sh -n pa
@echo "Syntax check passed!"
@echo ""
@echo "Testing help output..."
@./pa
@echo ""
@echo "All tests passed!"
clean:
@echo "Cleaning up test files..."
@rm -rf /tmp/pa-*
@echo "Clean complete!"
# Install to user's local bin directory
install-user:
@echo "Installing pa to ~/.local/bin..."
@mkdir -p ~/.local/bin
@sed -e 's/PA_VERSION="__VERSION__"/PA_VERSION="$(VERSION_STRING)"/g' -e 's/PA_RELEASE_DATE="__RELEASE_DATE__"/PA_RELEASE_DATE="$(RELEASE_DATE_STRING)"/g' -e 's/PA_COMMIT="__COMMIT__"/PA_COMMIT="$(GIT_COMMIT)"/g' pa > ~/.local/bin/pa
@chmod +x ~/.local/bin/pa
@echo "pa installed successfully to ~/.local/bin/pa"
@echo ""
@echo "Make sure ~/.local/bin is in your PATH:"
@echo " echo 'export PATH=\"\$$HOME/.local/bin:\$$PATH\"' >> ~/.bashrc"
@echo " echo 'export PATH=\"\$$HOME/.local/bin:\$$PATH\"' >> ~/.zshrc"
# Verify installation
verify:
@echo "Verifying pa installation..."
@which pa >/dev/null 2>&1 && echo "✓ pa found in PATH" || echo "✗ pa not found in PATH"
@command -v age >/dev/null 2>&1 && echo "✓ age found" || echo "✗ age not found - see README for platform-specific installation"
@command -v fzf >/dev/null 2>&1 && echo "✓ fzf found" || echo "✗ fzf not found - see README for platform-specific installation"
@command -v age-plugin-se >/dev/null 2>&1 && echo "✓ age-plugin-se found (macOS)" || echo "ℹ age-plugin-se not found (macOS only)"
@command -v secret-tool >/dev/null 2>&1 && echo "✓ secret-tool found (Linux)" || echo "ℹ secret-tool not found (Linux only)"
@command -v powershell.exe >/dev/null 2>&1 && echo "✓ PowerShell found (Windows)" || echo "ℹ PowerShell not found (Windows only)"
@command -v git >/dev/null 2>&1 && echo "✓ git found" || echo "✗ git not found"
test-vars:
@echo "RELEASE_DATE: $(RELEASE_DATE)"
@echo "GIT_TAG: $(GIT_TAG)"
@echo "GIT_COMMIT: $(GIT_COMMIT)"
@echo "GIT_STATUS: '$(GIT_STATUS)'"
@echo "VERSION_STRING: $(VERSION_STRING)"
@echo "RELEASE_DATE_STRING: $(RELEASE_DATE_STRING)"