1
0
mirror of https://github.com/foxlet/macOS-Simple-KVM.git synced 2024-06-02 06:03:31 +02:00
This commit is contained in:
Michał Opala 2020-10-10 15:48:37 -06:00 committed by GitHub
commit b2a4811ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
BaseSystem.img
BaseSystem.dmg
BaseSystem.chunklist
MyDisk.qcow2

80
Makefile Normal file
View File

@ -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 configuration
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)