summaryrefslogtreecommitdiff
path: root/site/personal/Makefile
blob: 4ee349231228d28a4a7129ea34828f6435cbfd48 (plain)
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
HOST ?= hwebs@marta

SOURCE = www-personal
DEPS = .local/src/www-personal
CADDY_SITE = /usr/local/etc/caddy/sites/personal.caddy
CRON = /usr/local/etc/cron.d/www-personal

COMMONMARK_REPO = https://codeberg.org/spritely/guile-commonmark.git
COMMONMARK_REV = ed3ce543ca2fbcf3312683aad66f19aa933468f6

HAUNT_REPO = https://git.dthompson.us/haunt.git
HAUNT_REV = v0.4.0

.PHONY: install deploy uninstall

install:
	ssh $(HOST) 'doas /usr/sbin/pkg install -y git guile3 guile-aclocal guile-lib-guile30 autoconf automake gmake pkgconf rsync'
	ssh $(HOST) 'set -e; \
		mkdir -p $(DEPS); \
		cd $(DEPS); \
		if [ ! -d guile-commonmark ]; then \
			git clone $(COMMONMARK_REPO); \
		fi; \
		cd guile-commonmark; \
		git fetch --tags origin; \
		git checkout --detach $(COMMONMARK_REV); \
		if [ ! -f .installed-$(COMMONMARK_REV) ]; then \
			./bootstrap; \
			./configure --prefix=/usr/local; \
			gmake; \
			doas gmake install; \
			touch .installed-$(COMMONMARK_REV); \
		fi'
	ssh $(HOST) 'set -e; \
		mkdir -p $(DEPS); \
		cd $(DEPS); \
		if [ ! -d haunt ]; then \
			git clone $(HAUNT_REPO); \
		fi; \
		cd haunt; \
		git fetch --tags origin; \
		git checkout --detach $(HAUNT_REV); \
		if [ ! -f .installed-$(HAUNT_REV) ]; then \
			./bootstrap; \
			./configure --prefix=/usr/local; \
			gmake; \
			doas gmake install; \
			touch .installed-$(HAUNT_REV); \
		fi'
	ssh $(HOST) 'doas mkdir -p /usr/local/etc/cron.d'
	ssh $(HOST) 'doas sh -c "cat > $(CRON)"' < cron

deploy:
	rsync -az --exclude=.git --exclude=Makefile --exclude=Caddyfile ./ $(HOST):$(SOURCE)/
	ssh $(HOST) 'cd $(SOURCE) && /usr/local/bin/haunt build && /usr/local/bin/haunt publish'
	ssh $(HOST) 'doas mkdir -p /usr/local/etc/caddy/sites'
	ssh $(HOST) 'doas sh -c "cat > $(CADDY_SITE)"' < Caddyfile

uninstall:
	ssh $(HOST) 'doas rm -f $(CADDY_SITE) $(CRON)'