aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 47fb4d64debb50188b15e2794a56ff1020751032 (plain) (blame)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
.POSIX:


pod2man = \
	share/man/man1/x.1 \
	share/man/man1/z.1 \


derived-assets = \
	var/respiro                                       \
	var/result-home                                   \
	var/result-system                                 \
	$(pod2man)                                        \
	$(XDG_STATE_HOME)/ssh/conn                        \
	$(XDG_CONFIG_HOME)/ssh/id_rsa.pub                 \
	$(XDG_CONFIG_HOME)/ssh/config                     \
	$(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf           \
	$(XDG_CONFIG_HOME)/xmobar/xmobarrc                \
	$(XDG_DATA_HOME)/euandreh/e.list.txt              \
	$(HOME)/.ssh                                      \


all: $(derived-assets) tilde

mnt: $(HOME)/mnt/suyin/enc $(HOME)/mnt/crypt/.keep

umnt:
	cryfs-unmount $(HOME)/mnt/crypt
	fusermount -u $(HOME)/mnt/suyin

tilde:
	@cd $(PRIV_CONFIG) && $(MAKE)


var/respiro:
	fallocate -l 8G $@

var/result-home:
	guix build -r $@ -v3 -f etc/guix/home.scm

var/result-system:
	guix build -r $@ -v3 -f etc/guix/system.scm

share/man/man1/x.1 share/man/man1/z.1:
	pod2man bin/`basename $@ .1` > $@

share/man/man1/x.1: bin/x
share/man/man1/z.1: bin/z

$(XDG_STATE_HOME)/ssh/conn:
	mkdir -p $@

$(XDG_CONFIG_HOME)/ssh/id_rsa.pub:
	gpg --export-ssh-key eu@euandre.org > $@
	chmod 600 $@

$(XDG_CONFIG_HOME)/ssh/config: $(XDG_CONFIG_HOME)/ssh/config.tmpl
	envsubst < $(XDG_CONFIG_HOME)/ssh/config.tmpl > $@

$(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf: $(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf.tmpl
	cp $(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf.tmpl $@
	printf 'pinentry-program ' >> $@
	command -v pinentry-gtk-2  >> $@

$(XDG_CONFIG_HOME)/xmobar/xmobarrc:
	cd $(@D) && ln -s `hostname` xmobarrc

$(HOME)/.ssh:
	ln -s $(XDG_CONFIG_HOME)/ssh $@

$(HOME)/mnt/suyin/enc:
	if [ ! -e $(@D) ]; then mkdir -p $(@D); fi
	sshfs suyin: $(@D)

$(HOME)/mnt/crypt/.keep: $(HOME)/mnt/suyin/enc
	if [ ! -e $(@D) ]; then mkdir -p $(@D); fi
	if [ ! -e $@    ]; then cryfs $? $(@D); fi
	touch $@

$(HOME)/txt/TODOs.adoc:
	mkdir -p $(@D)
	touch $@

$(HOME)/txt/scratch.txt:
	mkdir -p $(@D)
	touch $@

$(XDG_DATA_HOME)/euandreh/e.list.txt: opt/aux/gen-e-list.sh \
		$(HOME)/txt/TODOs.adoc $(HOME)/txt/scratch.txt
	sh opt/aux/gen-e-list.sh > $@



check-shellcheck:
	git ls-files | \
		grep -v '^share/aux/' | \
		sor 'test -f' | \
		xargs awk '/^#!\/bin\/sh$$/ { print FILENAME } { nextfile }' | \
		xargs shellcheck -x

check-perlcritic:
	git ls-files | \
		sor 'test -f' | \
		xargs awk '/^#!\/usr\/bin\/env perl$$/ { print FILENAME } { nextfile }' | \
		xargs perlcritic --exclude=subroutine ||:

FIXME-excludes = \
	':(exclude)Makefile' \
	':(exclude)bin/aux' \
	':(exclude)etc/git/ignore' \
	':(exclude)opt/aux/gen-e-list.sh'
check-fixme:
	if git grep FIXME -- $(FIXME-excludes); then \
		printf 'Leftover FIXME markers.\n' >&2; \
		exit 1; \
	fi

check-dirty-public:
	if ! git diff --quiet || ! git diff --quiet --staged; then \
		printf 'Dirty ~/.usr/ repository.\n' >&2; \
		exit 1; \
	fi
	if git status --short --branch --porcelain | \
			head -n1 | grep -E '(ahead|behind)'; then \
		printf '~/.usr/ of sync with origin.\n' >&2; \
		exit 1; \
	fi

check-dirty-private:
	if ! git -C $(PRIV_CONFIG) diff --quiet || \
			! git -C $(PRIV_CONFIG) diff --quiet --staged; then \
		printf 'Dirty private tilde repository.\n' >&2; \
		exit 1; \
	fi
	if git -C $(PRIV_CONFIG) status --short --branch --porcelain | \
			head -n1 | grep -E '(ahead|behind)'; then \
		printf 'Private of sync with origin.\n' >&2; \
		exit 1; \
	fi

check-dirty-pass:
	if ! git -C $(PASSWORD_STORE_DIR) diff --quiet || \
			! git -C $(PASSWORD_STORE_DIR) diff --quiet --staged; then \
		printf 'Dirty password store repository.\n' >&2; \
		exit 1; \
	fi
	if git -C $(PASSWORD_STORE_DIR) status --short --branch --porcelain | \
			head -n1 | grep -E '(ahead|behind)'; then \
		printf 'Password store rut of sync with origin.\n' >&2; \
		exit 1; \
	fi

check-opt:
	find opt/tests/ -name '*.sh' -exec sh {} ';'

check-pod:
	podchecker bin/z

check-aliases:
	for alias in abuse admin hostmaster postmaster; do \
		uuid | email -s "\"$$alias\" alias test from $$(id -un)@$$(hostname)" "$$alias@euandre.org"; \
	done
	uuid | email -s "lawtech->toph" -f andre@pilotis.net
	uuid | email -s "toph->lawtech"    andre@pilotis.net

check: check-fixme              \
                check-dirty-public check-dirty-private check-dirty-pass        \
		check-opt check-pod check-aliases
	@cd $(PRIV_CONFIG) && $(MAKE) $@

clean:
	rm -rf $(derived-assets)
	@cd $(PRIV_CONFIG) && $(MAKE) $@

VM-DIR = /srv/www/s/vm
upload:
	rsync \
		--rsync-path='sudo -u deployer rsync' \
		-avP \
		--exclude mint-x86_64-cinnamon.qcow2 \
		 $(XDG_STATE_HOME)/vm/qemu/ euandre.org:$(VM-DIR)/qemu/
	ssh euandre.org find $(VM-DIR)/qemu/ -type f | \
		sed 's|^$(VM-DIR)/qemu/||' | \
		sed 's|\.qcow2$$||'        | \
		ssh euandre.org sudo -u deployer dd of=$(VM-DIR)/vms.txt