From 419c4116cc34d7cd108bd4948cff3125fe07f05a Mon Sep 17 00:00:00 2001 From: Michal Opala Date: Sat, 10 Oct 2020 22:23:22 +0200 Subject: [PATCH 1/2] Introduce idempotent Makefile to run basic.sh in docker --- .gitignore | 1 + Makefile | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 876ddd4..9336d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ BaseSystem.img BaseSystem.dmg BaseSystem.chunklist +MyDisk.qcow2 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aa196f6 --- /dev/null +++ b/Makefile @@ -0,0 +1,80 @@ +SELF := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))) + +# Make sure fully-featured BASH shell is used by this Makefile +SHELL := $(shell which bash) + +IMAGE := macos-simple-kvm + +DISK_NAME ?= MyDisk +DISK_SIZE ?= 64G + +# Embed helper Dockerfile here for simplicity +define DOCKERFILE +FROM ubuntu:rolling + +ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get -q update -y \ + && apt-get -q install -y \ + qemu-system \ + qemu-utils \ + python3 \ + python3-pip \ + && apt-get -q autoremove -y \ + && apt-get -q clean -y \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR $(SELF)/ + +ENTRYPOINT [] +CMD /bin/bash +endef + +# Define helper docker-run macro to simplify rest of the Makefile +define RUN +docker run --rm \ + --network="host" \ + --privileged="true" \ + --device="/dev/dri/" \ + -e DISPLAY="$$DISPLAY" \ + -v $(SELF)/:$(SELF)/ \ + -i $(IMAGE) +endef + +# Append audio and hard disk device configuratiom +define BASIC_SH +$(file < $(SELF)/basic.sh) +-audiodev driver=pa,id=sound1,server=localhost \ +-drive id=SystemDisk,if=none,file=MyDisk.qcow2 \ +-device ide-hd,bus=sata.4,drive=SystemDisk +endef + +export + +.PHONY: all + +all: basic + +.PHONY: build + +build: + docker build -t $(IMAGE) - <<< "$$DOCKERFILE" + +.PHONY: jumpstart + +jumpstart-%: build + [[ -f $(SELF)/BaseSystem.img ]] || $(call RUN) ./jumpstart.sh --$* + +jumpstart: jumpstart-catalina + +.PHONY: basic + +basic: build $(SELF)/BaseSystem.img $(SELF)/MyDisk.qcow2 + $(call RUN) bash -s <<< "$$BASIC_SH" + +$(SELF)/BaseSystem.img: + @echo "Please run one of the 'jumpstart' variants first!" && exit 1 + +$(SELF)/$(DISK_NAME).qcow2: + $(call RUN) qemu-img create -f qcow2 $@ $(DISK_SIZE) From d3a340ea9c59b95e62b67e2d022b8977447ff323 Mon Sep 17 00:00:00 2001 From: Michal Opala Date: Sat, 10 Oct 2020 23:46:42 +0200 Subject: [PATCH 2/2] Fix typo in makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index aa196f6..0daba75 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ docker run --rm \ -i $(IMAGE) endef -# Append audio and hard disk device configuratiom +# Append audio and hard disk device configuration define BASIC_SH $(file < $(SELF)/basic.sh) -audiodev driver=pa,id=sound1,server=localhost \