diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 55 |
1 files changed, 45 insertions, 10 deletions
@@ -34,9 +34,10 @@ ALL_EGG_INFOS = \ $(HYDRILLA_WEBSITE_INFO) \ $(HYDRILLA_INFO) -CONTAINER_PREREQUISITES = container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py +CONTAINER_PREREQUISITES = container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py \ + exim.conf -TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')"'!!test-root' +TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')"'!!test-root/current' all: | container-runner.touchfile log sample-malcontent @@ -59,7 +60,7 @@ hosts: hosts-extra /etc/hosts cat $^ > $@ log: - ln -sf $(TEST_ROOT_DIR)/var/log/guix-container $@ + ln -sf test-root/var/log/guix-container $@ sample-malcontent: mkdir $@ @@ -68,12 +69,31 @@ sample-malcontent: make -C subrepos/hydrilla shell-with-hydrilla-only LETSENCRYPT_ETC_DIR = $(TEST_ROOT_DIR)/etc/letsencrypt +EXIM_ETC_DIR = $(TEST_ROOT_DIR)/etc/exim HYDRILLA_WEBSITE_ETC_DIR = $(TEST_ROOT_DIR)/etc/guix-container/hydrilla-website MALCONTENT_DIR = $(TEST_ROOT_DIR)/var/lib/hydrilla/malcontent_dirs GITOLITE_DIR = $(TEST_ROOT_DIR)/var/lib/gitolite3 +EXIM_SPOOL_DIR = $(TEST_ROOT_DIR)/var/spool/exim + +test-root: sample-malcontent Makefile + rm -f $@ + ln -sf $(TEST_ROOT_DIR) $@ + $(MAKE) prepare-test-root + +.PHONY: ensure-test-root +ensure-test-root: + $(MAKE) test-root + if [ \! -e $(TEST_ROOT_DIR) ]; then \ + $(MAKE) prepare-test-root; \ + fi +.PHONY: prepare-test-root prepare-test-root: sample-malcontent - rm -rf $(TEST_ROOT_DIR) + @# Move the old test root + if [ -e $(TEST_ROOT_DIR) ]; then \ + mv $(TEST_ROOT_DIR) \ + $(TEST_ROOT_DIR)/../"old-$$(date --iso-8601=seconds)"; \ + fi @# Prepare replacement `/var/www` for WWW_SUBDIR in \ koszko.org/html \ @@ -92,6 +112,17 @@ prepare-test-root: sample-malcontent printf 'test secret\n' > $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt chmod 540 $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt chgrp 1001 $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt + @# Prepare replacement `/etc/exim` + mkdir --mode=755 -p $(EXIM_ETC_DIR) + guix shell openssl -- openssl genrsa -out $(EXIM_ETC_DIR)/dkim.pem 2048 + chmod 640 $(EXIM_ETC_DIR)/dkim.pem + chown 106:113 $(EXIM_ETC_DIR)/dkim.pem + printf koszko: > $(EXIM_ETC_DIR)/passwd + printf silnehaslo | guix shell whois -- mkpasswd --method=sha-256 -s \ + >> $(EXIM_ETC_DIR)/passwd + echo >> $(EXIM_ETC_DIR)/passwd + chmod 640 $(EXIM_ETC_DIR)/passwd + chown 106:113 $(EXIM_ETC_DIR)/passwd @# Prepare replacement `/etc` mkdir --mode=750 -p $(HYDRILLA_WEBSITE_ETC_DIR) printf 'test non-secret\n' > $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt @@ -108,18 +139,23 @@ prepare-test-root: sample-malcontent printf "sheets-websites.git\n" > $(GITOLITE_DIR)/projects.list chmod -R o-rwx,g-w $(GITOLITE_DIR) chgrp -R 118 $(GITOLITE_DIR) + @# Prepare replacement `/var/spool/exim` + mkdir -p $(EXIM_SPOOL_DIR) + chmod 750 $(EXIM_SPOOL_DIR) + chown 106:113 $(EXIM_SPOOL_DIR) -GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile -r $(TEST_ROOT_DIR) +GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile \ + -r "$$(realpath test-root)" -start-container: guix-container.sh container-runner.touchfile \ - prepare-test-root | log +start-container: guix-container.sh container-runner.touchfile ensure-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 + ensure-test-root | log ./$< restart $(GUIX_CONTAINER_FLAGS) enter-container: pidfile @@ -152,11 +188,10 @@ clean: clean-runner for SUBREPO in $(SUBREPOS_WITH_MAKEFILE); do \ $(MAKE) -C subrepos/"$$SUBREPO" clean; \ done - rm -rf log hosts schemas sample-malcontent + rm -rf log test-root hosts schemas sample-malcontent .PHONY: all \ clean-runner clean \ - prepare-test-root \ start-container stop-container restart-container \ enter-container fake-client \ install \ |