2023-10-28 20:37:09 +00:00
|
|
|
# Copyright (C) 2023 Umorpha Systems
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2023-12-06 23:46:11 +00:00
|
|
|
# Entrypoint/config ############################################################
|
|
|
|
|
2023-11-08 05:07:45 +00:00
|
|
|
SHELL = bash
|
2023-10-28 20:37:09 +00:00
|
|
|
export osi_tools = $(CURDIR)/../notsystemd-tests
|
|
|
|
PATH := $(osi_tools):$(PATH)
|
|
|
|
|
2023-10-31 23:18:47 +00:00
|
|
|
all: $(patsubst %.sh,%.rootfs.img,$(wildcard images/*.sh))
|
2023-10-28 20:37:09 +00:00
|
|
|
.PHONY: all
|
|
|
|
|
2023-10-31 23:18:47 +00:00
|
|
|
.SECONDARY:
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
|
2023-11-10 06:39:29 +00:00
|
|
|
# Nothing here is parallel-unsafe, but it just makes the output (and
|
|
|
|
# especially `sudo` prompts) hard to read.
|
|
|
|
.NOTPARALLEL:
|
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
define NL
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2023-12-06 23:46:11 +00:00
|
|
|
# Dependency magic #############################################################
|
|
|
|
|
|
|
|
# Files that modules depend on
|
2023-12-11 20:14:08 +00:00
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
build-deps/modules/umorpha-bootstrap.sh = bin/umorpha-install
|
|
|
|
build-deps/modules/umorpha-bootstrap.sh += bin/umorpha-mount
|
2023-12-11 20:14:08 +00:00
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
secret-deps/modules/service-gitea.sh = secrets/gitea-infomaniak-clientid.txt
|
|
|
|
secret-deps/modules/service-gitea.sh += secrets/gitea-infomaniak-clientsecret.txt
|
|
|
|
|
2023-12-11 20:14:08 +00:00
|
|
|
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
|
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
# Group that should own the secret
|
2023-12-11 20:14:08 +00:00
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
group/gitea-infomaniak-clientid.txt = gitea
|
|
|
|
group/gitea-infomaniak-clientsecret.txt = gitea
|
2023-10-31 23:18:47 +00:00
|
|
|
|
2023-12-11 20:14:08 +00:00
|
|
|
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
|
|
|
|
|
2023-12-06 23:46:11 +00:00
|
|
|
# Automatic dependencies
|
2023-10-31 23:18:47 +00:00
|
|
|
deps.mk: images $(wildcard images/*.sh)
|
2023-12-08 03:37:52 +00:00
|
|
|
grep -H -o -e '--module=\S*' -e '--package-file=\S*' -- images/*.sh | sed -E 's,images/([^:]*).sh:--(module|package-file)=(.*),images/\1.rootfs.img: \3 $$(build-deps/\3)\nimages/\1.secrets.sh: $$(secret-deps/\3),' >$@
|
2023-10-28 20:37:09 +00:00
|
|
|
-include deps.mk
|
|
|
|
|
2023-12-06 23:46:11 +00:00
|
|
|
# Generic pattern rules ########################################################
|
|
|
|
|
2023-10-31 23:18:47 +00:00
|
|
|
images/%.rootfs.img: images/%.sh
|
2023-10-28 20:37:09 +00:00
|
|
|
rm -f $@
|
|
|
|
$< $@
|
2023-10-28 22:12:25 +00:00
|
|
|
chmod 444 $@
|
|
|
|
|
2023-10-31 23:18:47 +00:00
|
|
|
images/%.gpt.img: images/%.rootfs.img bin/umorpha-install
|
|
|
|
rm -f $@
|
|
|
|
truncate --size=3G $@
|
2023-11-09 21:55:25 +00:00
|
|
|
sudo bin/umorpha-install images/$*.rootfs.img $@
|
2023-10-31 23:18:47 +00:00
|
|
|
|
2023-11-08 05:07:45 +00:00
|
|
|
images/%.bootstrap.iso: images/%.rootfs.img images/bootstrap.rootfs.img bin/mkbootstrapiso
|
|
|
|
bin/mkbootstrapiso $< $@
|
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
images/%.secrets.sh:
|
|
|
|
{ \
|
|
|
|
echo '#!/bin/sh'; \
|
|
|
|
echo 'install -m755 -d /etc/umorpha-secrets'; \
|
|
|
|
$(foreach f,$(sort $^),val=$$(cat $f); echo "install -m640 --group=$(group/$(notdir $f)) /dev/stdin /etc/umorpha-secrets/$(notdir $f) <<<$${val@Q}"; \$(NL) ) \
|
|
|
|
} >$@
|
|
|
|
|
2023-11-14 02:07:10 +00:00
|
|
|
pkg/%.pkg.tar.zst: pkg/%/PKGBUILD
|
|
|
|
cd $(<D) && PKGDEST=$(abspath $(@D)) makepkg --syncdeps --rmdeps
|
|
|
|
ln -sf $*-$$(cd $(<D) && makepkg --printsrcinfo|awk 'BEGIN{arch=x86_64} /pkgver =/{pkgver=$$3} /pkgrel =/{pkgrel=$$3} /arch = any/{arch=$$3} END{print pkgver "-" pkgrel "-" arch}').pkg.tar.zst $@
|
|
|
|
|
2023-11-13 04:52:10 +00:00
|
|
|
qemu-bios = qemu-system-x86_64
|
|
|
|
qemu-bios += -accel kvm
|
|
|
|
qemu-bios += -m 2G
|
|
|
|
qemu-bios += -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::8080-:80 -net nic
|
|
|
|
|
|
|
|
qemu-uefi = $(qemu-bios) -drive if=pflash,format=raw,readonly=on,file=/usr/share/ovmf/x64/OVMF.fd
|
|
|
|
|
|
|
|
run-bios/%.img: images/%.img
|
|
|
|
cp --reflink -- $< $<.tmp
|
|
|
|
chmod 644 $<.tmp
|
|
|
|
$(qemu-bios) -drive media=disk,if=virtio,format=raw,file=$<.tmp
|
|
|
|
run-bios/%.iso: images/%.iso
|
|
|
|
truncate --size=3G $<.tmp
|
|
|
|
$(qemu-bios) -drive media=disk,if=virtio,format=raw,file=$<.tmp -cdrom $<
|
|
|
|
.PHONY: run-bios/%
|
|
|
|
|
|
|
|
run-uefi/%.img: images/%.img
|
|
|
|
cp --reflink -- $< $<.tmp
|
|
|
|
chmod 644 $<.tmp
|
|
|
|
$(qemu-uefi) -drive media=disk,if=virtio,format=raw,file=$<.tmp
|
|
|
|
.PHONY: run-ueif/%
|
2023-10-28 20:37:09 +00:00
|
|
|
|
2023-12-08 03:37:52 +00:00
|
|
|
deploy/%: images/%.bootstrap.iso images/%.secrets.sh vultr/%.sh
|
2023-11-04 02:28:14 +00:00
|
|
|
vultr/$*.sh
|
|
|
|
.PHONY: deploy/%
|
|
|
|
|
2023-12-06 23:46:11 +00:00
|
|
|
# Specific rules ###############################################################
|
2023-10-31 23:18:47 +00:00
|
|
|
|
2023-11-14 02:07:10 +00:00
|
|
|
pkg/grub-2_2.12rc1-5-x86_64.pkg.tar.zst:
|
2023-11-13 04:52:10 +00:00
|
|
|
wget -O $@ https://archlinux.org/packages/core/x86_64/grub/download/
|