97 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Makefile
		
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Makefile
		
	
	
	
| # Copyright (C) 2023  Umorpha Systems
 | |
| # SPDX-License-Identifier: AGPL-3.0-or-later
 | |
| 
 | |
| SHELL = bash
 | |
| 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:
 | |
| 
 | |
| ################################################################################
 | |
| 
 | |
| deps.mk: images $(wildcard images/*.sh)
 | |
| 	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,' >$@
 | |
| -include deps.mk
 | |
| 
 | |
| 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 $< $@
 | |
| 
 | |
| 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 $@
 | |
| 
 | |
| 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/%
 | |
| 
 | |
| deploy/%: images/%.bootstrap.iso vultr/%.sh
 | |
| 	vultr/$*.sh
 | |
| .PHONY: deploy/%
 | |
| 
 | |
| ################################################################################
 | |
| 
 | |
| pkg/grub-2_2.12rc1-5-x86_64.pkg.tar.zst:
 | |
| 	wget -O $@ https://archlinux.org/packages/core/x86_64/grub/download/
 | |
| 
 | |
| modules/umorpha-bootstrap.sh: modules/umorpha-bootstrap.sh.in
 | |
| modules/umorpha-bootstrap.sh: bin/umorpha-install
 | |
| 	sed $$'/@UMORPHA_INSTALL_CONTENT@/{\nr bin/umorpha-install\nd\n}' <modules/umorpha-bootstrap.sh.in >$@
 | |
| 
 | |
| modules/service-gitea.sh: modules/service-gitea.sh.in
 | |
| modules/service-gitea.sh: secrets/gitea-infomaniak-clientid.txt
 | |
| modules/service-gitea.sh: secrets/gitea-infomaniak-clientsecret.txt
 | |
| 	sed \
 | |
| 	    -e "s,@CLIENT_ID@,$$(cat secrets/gitea-infomaniak-clientid.txt),g" \
 | |
| 	    -e "s,@CLIENT_SECRET@,$$(cat secrets/gitea-infomaniak-clientsecret.txt),g" \
 | |
| 	    <modules/service-gitea.sh.in >$@
 | |
| 
 | |
| modules/service-bookstack.sh: modules/service-bookstack.sh.in
 | |
| modules/service-bookstack.sh: secrets/bookstack-app-key.txt
 | |
| modules/service-bookstack.sh: secrets/bookstack-mariadb.txt
 | |
| modules/service-bookstack.sh: secrets/bookstack-infomaniak-mailpassword.txt
 | |
| modules/service-bookstack.sh: secrets/bookstack-infomaniak-clientid.txt
 | |
| modules/service-bookstack.sh: secrets/bookstack-infomaniak-clientsecret.txt
 | |
| 	sed \
 | |
| 	    -e "s,@APP_KEY@,$$(cat secrets/bookstack-app-key.txt),g" \
 | |
| 	    -e "s,@DB_PASSWORD@,$$(cat secrets/bookstack-mariadb.txt),g" \
 | |
| 	    -e "s,@MAIL_PASSWORD@,$$(cat secrets/bookstack-infomaniak-mailpassword.txt),g" \
 | |
| 	    -e "s,@CLIENT_ID@,$$(cat secrets/bookstack-infomaniak-clientid.txt),g" \
 | |
| 	    -e "s,@CLIENT_SECRET@,$$(cat secrets/bookstack-infomaniak-clientsecret.txt),g" \
 | |
| 	    <modules/service-bookstack.sh.in >$@
 |