blob: 1486e8eed9445771cd698eba35079cf069cc6eb4 (
about) (
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
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
|
# SPDX-License-Identifier: CC0-1.0
# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
#
# Available under the terms of Creative Commons Zero v1.0 Universal.
GUIX := guix
# Almost all commands in this Makefilo are run through `guix time-machine` with
# Guix revision fixed to the one from the commit below. This ensures that the
# same working environment is always used.
GUIX_COMMIT := a86979b41a49a8fcdaa887970ba594dbba701226
GUIX_TM = $(GUIX) time-machine --commit=$(GUIX_COMMIT) --
GUIX_LOAD_PATHS = $$( \
find subrepos/ -mindepth 1 -maxdepth 1 \
-exec printf ' -L %s/guix-module-dir/' {} ';' \
) \
-L ./guix-module-dir/
GUIX_SYS_CONTAINER = $(GUIX_TM) system container $(GUIX_LOAD_PATHS)
GUIX_SHELL = $(GUIX_TM) shell
KOSZKO_ORG_WEBSITE_INFO = \
subrepos/koszko-org-website/src/koszko_org_website.egg-info/PKG-INFO
HYDRILLA_WEBSITE_INFO = \
subrepos/hydrilla-website/src/hydrilla_website.egg-info/PKG-INFO
HYDRILLA_INFO = subrepos/hydrilla/src/hydrilla.egg-info/PKG-INFO
ALL_EGG_INFOS = \
$(KOSZKO_ORG_WEBSITE_INFO) \
$(HYDRILLA_WEBSITE_INFO) \
$(HYDRILLA_INFO)
TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')"'!!test-root'
all: | container-runner.touchfile log sample-malcontent
$(KOSZKO_ORG_WEBSITE_INFO):
$(MAKE) -C subrepos/koszko-org-website dist
$(HYDRILLA_WEBSITE_INFO):
$(MAKE) -C subrepos/hydrilla-website dist
$(HYDRILLA_INFO):
$(MAKE) -C subrepos/hydrilla dist
container-runner: | container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py
container-runner.touchfile: container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py
container-runner container-runner.touchfile:
$(MAKE) clean-runner
$(GUIX_SYS_CONTAINER) container.scm -r container-runner
touch container-runner.touchfile
hosts: hosts-extra /etc/hosts
cat $^ > $@
log:
ln -sf $(TEST_ROOT_DIR)/var/log/guix-container $@
sample-malcontent:
mkdir $@
printf 'hydrilla-builder -s tests/source-package-example/ -d %s' \
"$$(realpath $@)" | \
make -C subrepos/hydrilla shell-with-haketilo
HYDRILLA_WEBSITE_ETC_DIR = $(TEST_ROOT_DIR)/etc/guix-container/hydrilla-website
MALCONTENT_DIR = $(TEST_ROOT_DIR)/var/lib/hydrilla/malcontent_dirs
prepare-test-root: sample-malcontent
rm -rf $(TEST_ROOT_DIR)
@# Prepare replacement `/var/www`
for SITE in koszko.org hydrillarepos.koszko.org; do \
mkdir -p $(TEST_ROOT_DIR)/var/www/"$$SITE"/html; \
printf 'This is dummy file for %s :D\n' "$$SITE" \
> $(TEST_ROOT_DIR)/var/www/"$$SITE"/html/index.html; \
done
@# Prepare replacement `/var/log`
mkdir -p $(TEST_ROOT_DIR)/var/log
@# Prepare replacement `/etc`
mkdir --mode=750 -p $(HYDRILLA_WEBSITE_ETC_DIR)
printf 'test non-secret\n' > $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt
chgrp -R 133 $(HYDRILLA_WEBSITE_ETC_DIR)
chmod 640 $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt
@# Prepare replacement `/var/lib/hydrilla`
mkdir -p $(MALCONTENT_DIR)/api_v2
ln -sf api_v2 $(MALCONTENT_DIR)/api_v1
cp -r $</* $(MALCONTENT_DIR)/api_v2/
GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile -r $(TEST_ROOT_DIR)
start-container: guix-container.sh container-runner.touchfile \
prepare-test-root | log
./$< start $(GUIX_CONTAINER_FLAGS)
stop-container: guix-container.sh
./$< stop $(GUIX_CONTAINER_FLAGS)
restart-container: guix-container.sh container-runner.touchfile \
prepare-test-root | log
./$< restart $(GUIX_CONTAINER_FLAGS)
enter-container: pidfile
nsenter -a -t "$$(cat pidfile)" \
/run/current-system/profile/bin/bash --login
fake-client: fake-client-setup-mounts.sh hosts
unshare --map-root-user --mount ./$< "$${SHELL:-/bin/sh}"
install: container.scm sdists
cp guix-container.sh /etc/init.d/guix-container
mkdir -p /usr/local/bin
if [ -e /usr/local/bin/guix-container ]; then \
rm /usr/local/bin/guix-container; \
fi
$(GUIX_SYS_CONTAINER) container.scm -r /usr/local/bin/guix-container
reinstall:
rm -rf /usr/local/bin/guix-container
$(MAKE) install
build-hydrilla-json-schemas:
$(GUIX_TM) build -L ./guix-module-dir/ hydrilla-json-schemas
clean-runner:
rm -rf container-runner container-runner.touchfile
clean: clean-runner
$(MAKE) -C subrepos/koszko-org-website clean
rm -rf log hosts schemas sample-malcontent
.PHONY: all \
clean-runner clean \
prepare-test-root \
start-container stop-container restart-container \
enter-container fake-client \
install reinstall \
build-hydrilla-json-schemas
|