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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#!gmake -f
SUBSTS_FILE=SUBSTS.local
# Files that need changes to work locally or that contain sensitive
# information
LOCAL_FILES = \
.imapfilter/config.lua \
.mutt/accounts.rc \
.netrc \
.offlineimaprc \
.xmonad/xmonad.hs \
# Files that are system independent.
# IMPORTANT: directories must have trailing slash
GLOBAL_FILES = \
.Xdefaults \
.config/nitrogen/ \
.dzen/ \
.imapfilter/ \
.inputrc \
.local/share/wallpapers/ \
.mailcheckrc \
.mutt/ \
.muttrc \
.notmuch-config \
.quiltrc-dpkg \
.screenrc \
.screenlayout/ \
.signature \
.vim/ \
.vimrc \
.xinitrc \
.xmobarrc \
.xmonad/ \
.zsh/ \
.zsh_logout \
.zshrc \
bin/ \
get-val = $(shell awk '{if (match($$0, /$1/)) { print $$2 } }' $(SUBSTS_FILE))
SHA256 = $(call get-val,SHA256)
LOCAL_PASS = $(call get-val,LOCAL_PASS)
GMAIL_PASS = $(call get-val,GMAIL_PASS)
QUEENSU_PASS = $(call get-val,QUEENSU_PASS)
PM_EMAIL = $(call get-val,PM_EMAIL)
SCREENLAYOUT = $(call get-val,SCREENLAYOUT)
XMONAD_DZEN_W = $(call get-val,XMONAD_DZEN_W)
XMONAD_DZEN_X = $(call get-val,XMONAD_DZEN_X)
XMONAD_DZEN_Y = $(call get-val,XMONAD_DZEN_Y)
# This target relies on GLOBAL_FILES being before LOCAL_FILES so that the
# build/LOCAL_FILES targets overwrite what was copied in GLOBAL_FILES.
BUILD = $(patsubst %,build/%,$(GLOBAL_FILES) $(LOCAL_FILES))
build: $(BUILD)
build/.offlineimaprc: .offlineimaprc $(SUBSTS_FILE)
[ -d build ] || mkdir build
sed -e 's/LOCAL_PASS/$(LOCAL_PASS)/g' \
-e 's/GMAIL_PASS/$(GMAIL_PASS)/g' \
-e 's/QUEENSU_PASS/$(QUEENSU_PASS)/g' $< > $@
build/.imapfilter/config.lua: .imapfilter/config.lua $(SUBSTS_FILE)
[ -d build/.imapfilter ] || mkdir -p build/.imapfilter
sed -e 's/LOCAL_PASS/$(LOCAL_PASS)/g' \
-e 's/PM_EMAIL/$(PM_EMAIL)/g' $< > $@
build/.netrc: .netrc $(SUBSTS_FILES)
[ -d build ] || mkdir build
sed -e 's/LOCAL_PASS/$(LOCAL_PASS)/g' $< > $@
build/.mutt/accounts.rc: .mutt/accounts.rc $(SUBSTS_FILE)
[ -d build/.mutt ] || mkdir -p build/.mutt
sed -e 's/LOCAL_PASS/$(LOCAL_PASS)/g' \
-e 's/GMAIL_PASS/$(GMAIL_PASS)/g' \
-e 's/QUEENSU_PASS/$(QUEENSU_PASS)/g' $< > $@
build/.xinitrc: .xinitrc $(SUBSTS_FILE)
[ -d build ] || mkdir build
sed -e 's/SCREENLAYOUT/$(SCREENLAYOUT)/g' $< > $@
build/.xmonad/xmonad.hs: .xmonad/xmonad.hs $(SUBSTS_FILE)
[ -d build/.xmonad ] || mkdir -p build/.xmonad
sed -e 's/XMONAD_DZEN_W/$(XMONAD_DZEN_W)/g' \
-e 's/XMONAD_DZEN_X/$(XMONAD_DZEN_X)/g' \
-e 's/XMONAD_DZEN_y/$(XMONAD_DZEN_Y)/g' $< > $@
build/%: %
[ -d $(dir $@) ] || mkdir -p $(dir $@)
rsync -a $< $@
install: $(BUILD)
rsync -a build/ ~/
sha256sums: $(LOCAL_FILES) $(GLOBAL_FILES) Makefile
$(SHA256) `git ls-files | grep -v $@` > $@
sha256sums.asc: sha256sums
rm -f $@
gpg --clearsign --detach-sign $<
verify:
# BSD sha256 sum command doesn't have a -c option.
# BSD and coreutils sha256 commands have different outputs, however, the
# sum is always the last field.
awk 'BEGIN {\
mismatch_count = 0; \
match_count = 0; \
} { \
file = $$2; \
sub(/^\(/, "", file); \
sub(/\)$$/, "", file); \
cmd = "$(SHA256) " file; \
cmd | getline sum; \
close(cmd); \
sum = split(sum, fields); \
if (fields[sum] == $$NF) { \
print "Match: " file; \
match_count += 1; \
} else { \
print "Mismatch: " file; \
mismatch_count += 1; \
} \
} END { \
print match_count, "matches, ", mismatch_count, "mismatches." \
}' sha256sums
gpg --verify sha256sums.asc
clean:
rm -fr build
.PHONY: build install clean verify
|