# Copyright (C) 2023 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later # Entrypoint/config ############################################################ SHELL = bash -euE -o pipefail export osi_tools = $(CURDIR)/../notsystemd-tests PATH := $(osi_tools):$(PATH) all: $(patsubst %.sh,%.rootfs.img,$(wildcard images/*.sh)) .PHONY: all .SECONDARY: .DELETE_ON_ERROR: # Nothing here is parallel-unsafe, but it just makes the output (and # especially `sudo` prompts) hard to read. .NOTPARALLEL: define NL endef # Dependency magic ############################################################# # Files that modules depend on build-deps/modules/umorpha-bootstrap.sh = bin/umorpha-install build-deps/modules/umorpha-bootstrap.sh += bin/umorpha-mount secret-deps/modules/service-gitea.sh = secrets/gitea-infomaniak-clientid.txt secret-deps/modules/service-gitea.sh += secrets/gitea-infomaniak-clientsecret.txt secret-deps/modules/service-bookstack.sh = secrets/bookstack-app-key.txt secret-deps/modules/service-bookstack.sh += secrets/bookstack-mariadb-password.txt secret-deps/modules/service-bookstack.sh += secrets/bookstack-infomaniak-mailaddr.txt secret-deps/modules/service-bookstack.sh += secrets/bookstack-infomaniak-mailpassword.txt secret-deps/modules/service-bookstack.sh += secrets/bookstack-infomaniak-clientid.txt secret-deps/modules/service-bookstack.sh += secrets/bookstack-infomaniak-clientsecret.txt # Group that should own the secret group/gitea-infomaniak-clientid.txt = gitea group/gitea-infomaniak-clientsecret.txt = gitea group/bookstack-app-key.txt = bookstack group/bookstack-mariadb-password.txt = bookstack group/bookstack-infomaniak-mailaddr.txt = bookstack group/bookstack-infomaniak-mailpassword.txt = bookstack group/bookstack-infomaniak-clientid.txt = bookstack group/bookstack-infomaniak-clientsecret.txt = bookstack # Automatic dependencies deps.mk: images $(wildcard images/*.sh) $(wildcard modules/*.sh) Makefile { \ echo '# variables: module -> module'; \ grep -H load_module modules/*.sh|sed -E 's,(.*):.*/(.*)"$$,build-deps/\1 += modules/\2 $$(build-deps/modules/\2),'; \ echo '# variables: image -> module'; \ grep -H -o -e '--module=\S*' -- images/*.sh | sed -E 's,images/([^:]*).sh:--module=(.*),build-deps/images/\1.rootfs.img += \2 $$(build-deps/\2),'; \ echo '# concrete: image -> build-deps'; \ $(foreach f,$(patsubst %.sh,%.rootfs.img,$(filter-out %.secrets.sh,$(wildcard images/*.sh))),echo '$f: $$(build-deps/$f)'; \$(NL) ) \ echo '# concrete: secrets -> secret-deps'; \ $(foreach f,$(patsubst %.sh,%.rootfs.img,$(filter-out %.secrets.sh,$(wildcard images/*.sh))),echo '$(patsubst %.rootfs.img,%.secrets.sh,$f): $$(foreach d,$$(build-deps/$f),$$(secret-deps/$$d))'; \$(NL) ) \ echo '# concrete: image -> package'; \ grep -H -o -e '--package-file=\S*' -- images/*.sh | sed -E 's,images/([^:]*).sh:--package-file=(.*),build-deps/images/\1.rootfs.img: \2,'; \ } >$@ -include deps.mk # Generic pattern rules ######################################################## images/%.rootfs.img: images/%.sh rm -f $@ $< $@ chmod 444 $@ images/%.gpt.img: images/%.rootfs.img bin/umorpha-install rm -f $@ truncate --size=3G $@ sudo bin/umorpha-install images/$*.rootfs.img $@ images/%.bootstrap.iso: images/%.rootfs.img images/bootstrap.rootfs.img bin/mkbootstrapiso bin/mkbootstrapiso $< $@ images/%.secrets.sh: Makefile { \ echo '#!/bin/sh'; \ echo 'install -m755 -d /etc/umorpha-secrets'; \ $(foreach f,$(sort $(filter secrets/%,$^)),val=$$(cat $f); echo "install -m640 --group=$(group/$(notdir $f)) /dev/stdin /etc/umorpha-secrets/$(notdir $f) <<<$${val@Q}"; \$(NL) ) \ } >$@ pkg/%.pkg.tar.zst: pkg/%/PKGBUILD rm -rf -- $(