aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-11-16 18:52:53 +0100
committerWojtek Kosior <koszko@koszko.org>2022-11-16 21:43:50 +0100
commit08f4d63f450ccd96f5077bc60774d8f1fecec92c (patch)
tree7f09941d62ca23737bc0b1f616d2d50eb7dd14af /Makefile
downloadkoszko-org-website-08f4d63f450ccd96f5077bc60774d8f1fecec92c.tar.gz
koszko-org-website-08f4d63f450ccd96f5077bc60774d8f1fecec92c.zip
initial commitv2022.11.16
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile101
1 files changed, 101 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..5498207
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,101 @@
+# 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_DEVSHELL = $(GUIX_TM) shell -Df guix.scm --
+
+GET_VER = $$(grep '^Version:' src/koszko_org_website.egg-info/PKG-INFO | \
+ cut -d' ' -f2)
+RECORD_VER = VER="$(GET_VER)"
+
+DETERMINISTIC_TAR = $(GUIX_TM) shell tar -- tar \
+ --mtime='1970-01-01 00:00Z' \
+ --sort=name \
+ --owner=0 --group=0 --numeric-owner \
+ --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
+
+DETERMINE_USER_SHELL_TO_USE = \
+ case "$$SHELL" in \
+ ?*) \
+ SHELL_TO_USE="$$SHELL";; \
+ *) \
+ SHELL_TO_USE="/bin/sh";; \
+ esac
+
+wheel:
+ $(GUIX_DEVSHELL) python3 -m build
+
+# Make a source tarball and repack in a deterministic way so that its
+# reproducible.
+dist src/koszko_org_website/_version.py:
+ $(GUIX_DEVSHELL) python3 -m build -s
+ $(RECORD_VER) && \
+ RELNAME=koszko_org_website-"$$VER" && \
+ DISTFILE=dist/"$$RELNAME".tar.gz && \
+ $(MAKE) clean-source-tarball-repack && \
+ mkdir source-tarball-repack/ && \
+ tar -C source-tarball-repack/ -xf "$$DISTFILE" && \
+ $(DETERMINISTIC_TAR) -C source-tarball-repack/ \
+ -cf "$$DISTFILE" "$$RELNAME"
+ @printf "Generated source tarball in:\n"
+ @printf "./dist/koszko_org_website-$(GET_VER).tar.gz\n"
+
+# If using bash, modify the prompt to indicate the environment is active.
+shell:
+ $(DETERMINE_USER_SHELL_TO_USE); \
+ case "$$SHELL_TO_USE" in \
+ *bash*) \
+ WEBSITE_SHELL_NAME=koszko.org-website-dev \
+ $(GUIX_DEVSHELL) "$$SHELL_TO_USE" \
+ --rcfile ./bashrc || true;; \
+ *) \
+ $(GUIX_DEVSHELL) "$$SHELL_TO_USE" || true;; \
+ esac
+
+catalogs:
+ $(GUIX_DEVSHELL) python3 setup.py compile_catalog
+
+refresh-catalogs:
+ $(GUIX_DEVSHELL) sh -c \
+ "python3 setup.py extract_messages && python3 setup.py update_catalog && python3 setup.py compile_catalog"
+
+copied_license_files:
+ $(GUIX_DEVSHELL) python3 setup.py copy_licenses
+
+run-website: src/koszko_org_website/_version.py catalogs copied_license_files
+ PYTHONPATH=./src $(GUIX_DEVSHELL) python3 -m koszko_org_website
+
+reuse-lint:
+ $(GUIX_DEVSHELL) reuse lint
+
+mypy-lint: src/koszko_org_website/_version.py
+ PYTHONPATH=./src/ $(GUIX_DEVSHELL) mypy -p koszko_org_website
+
+clean-source-tarball-repack:
+ rm -rf source-tarball-repack/
+
+clean: clean-source-tarball-repack
+ rm -rf build/ dist/ src/koszko_org_website.egg-info/ \
+ src/koszko_org_website/_version.py \
+ src/koszko_org_website/locales/messages.pot \
+ $$(grep src/koszko_org_website/static/ .gitignore) \
+ .mypy_cache/
+ find src/koszko_org_website/locales/ -name "messages.mo" -delete
+ rm -rf $$(find -name "__pycache__")
+
+.PHONY: shell \
+ wheel dist catalogs copied_license_files \
+ run-website refresh-catalogs \
+ reuse-lint mypy-lint \
+ clean-source-tarball-repack clean