umorpha-boxes/Makefile

31 lines
763 B
Makefile

# Copyright (C) 2023 Umorpha Systems
# SPDX-License-Identifier: AGPL-3.0-or-later
export osi_tools = $(CURDIR)/../notsystemd-tests
PATH := $(osi_tools):$(PATH)
all: $(patsubst boxes/%.sh,out/%.img,$(wildcard boxes/*.sh))
.PHONY: all
deps.mk: boxes $(wildcard boxes/*.sh) | out
grep -H -o -e '--module=\S*' boxes/*.sh | sed -E 's,boxes/([^:]*).sh:--module=(.*),out/\1.img: \2,' >$@
-include deps.mk
out:
mkdir $@
out/%.img: boxes/%.sh | out
rm -f $@
$< $@
chmod 444 $@
run/%: out/%.img
rm -f out/$*.tmp.img
cp --reflink $< out/$*.tmp.img
chmod 600 out/$*.tmp.img
qemu-system-x86_64 -accel kvm -m 2G -hda out/$*.tmp.img -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::8080-:80 -net nic
rm -f out/$*.tmp.img
.PHONY: run/%
.SECONDARY:
.DELETE_ON_ERROR: