-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
78 lines (61 loc) · 2.1 KB
/
Makefile
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
SURGE_SUBDOMAIN ?= awesome-name
# Force HTTP to redirect to HTTPS
# see https://surge.sh/help/using-https-by-default
SURGE_URL ?= https://${SURGE_SUBDOMAIN}.surge.sh
# Separate what will be published from the rest of the code
REPO_PREFIX = public/
# Your repository naming conventions are really up to you
REPO_PATH ?= qubes-os/r4.1/testing/
# The ID of you GPG key will likely be different
GPG_NAME ?= Packaging
# I use split-GPG on Qubes OS, replace this by "gpg" if needed
define GPG_CMD
qubes-gpg-client-wrapper
endef
# I don't usually install the Surge CLI globally, replace by "surge" if needed
define SURGE_CMD
surge
endef
# Default target, what I'd likely want to do most often
.PHONY: all
all: update sign index deploy
# Initialize your package repository
.PHONY: init
init: createrepo robots.txt 404.html
.PHONY: createrepo
createrepo:
mkdir -p ${REPO_PREFIX}${REPO_PATH}packages
createrepo ${REPO_PREFIX}${REPO_PATH}
robots.txt:
mkdir -p ${REPO_PREFIX}
# Surge kindly hosts us, let's save bandwidth where we can
printf 'User-agent: *\nDisallow: /\n' > ${REPO_PREFIX}robots.txt
# Humans may visit too!
404.html:
mkdir -p ${REPO_PREFIX}
cp src/404.html ${REPO_PREFIX}
# Update the repository metadata after adding packages
.PHONY: update
update:
createrepo --update ${REPO_PREFIX}${REPO_PATH}
# Sign the repository metadata with GPG
.PHONY: sign
sign:
${GPG_CMD} --local-user "${GPG_NAME}" --sign --detach --armor --output ${REPO_PREFIX}${REPO_PATH}repodata/repomd.xml.asc ${REPO_PREFIX}${REPO_PATH}repodata/repomd.xml
# Create some HTML pages to make the repository nice to humans
.PHONY: index
index:
cd ${REPO_PREFIX} && for d in $$(find -type d); do (cd $$d && tree -I index.html -H . -T '🌳 Directory Tree' --dirsfirst -r > index.html); done && cd -
# Deploy the repository to Surge
.PHONY: deploy
deploy:
${SURGE_CMD} ${REPO_PREFIX} ${SURGE_URL}
# Tear down the repository from Surge
.PHONY: teardown
teardown:
${SURGE_CMD} teardown ${SURGE_URL}
# Remove the repository entirely, including the packages
# This doesn't tear the repository down from Surge, though.
.PHONY: clean
clean:
-rm -r ${REPO_PREFIX}