From 6ea4fa812f6758d72eea2b994ee19dc8ed4d42c9 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Thu, 30 Sep 2021 18:59:00 +0100 Subject: [PATCH] Don't download macOS firmware/bootloader at runtime quickget it the tool to acquire macOS with compatible firmware and bootloader. quickemu is backwards compatible with Clover. --- quickemu | 46 ++++++++++++++++++++++++++-------------------- quickget | 7 +++++++ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/quickemu b/quickemu index 50c85f8..37e3cdc 100755 --- a/quickemu +++ b/quickemu @@ -1,17 +1,6 @@ #!/usr/bin/env bash export LC_ALL=C -function web_get() { - local URL="${1}" - local FILE="" - FILE="${URL##*/}" - mkdir -p "${VMDIR}" 2>/dev/null - if ! wget --quiet --continue --show-progress --progress=bar:force:noscroll "${URL}" -O "${VMDIR}/${FILE}"; then - echo "ERROR! Failed to download ${URL}" - exit 1 - fi -} - function disk_delete() { if [ -e "${disk_img}" ]; then rm "${disk_img}" @@ -147,6 +136,7 @@ function vm_boot() { local GL="on" local GUEST_TWEAKS="" local HOST_CPU="" + local MAC_MISSING="" local NET_DEVICE="virtio-net" local OSK="" local QEMU_VER="" @@ -162,21 +152,37 @@ function vm_boot() { # Always Boot macOS using EFI if [ "${guest_os}" == "macos" ]; then boot="efi" - fi - - if [ "${guest_os}" == "macos" ]; then echo " - BOOT: EFI" - web_get "https://github.com/kholia/OSX-KVM/raw/master/OpenCore-Catalina/OpenCore.qcow2" - web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_CODE.fd" - web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_VARS-1024x768.fd" - local EFI_CODE="${VMDIR}/OVMF_CODE.fd" - local EFI_VARS="${VMDIR}/OVMF_VARS-1024x768.fd" + if [ -e "${VMDIR}/OVMF_CODE.fd" ] && [ -e "${VMDIR}/OVMF_VARS-1024x768.fd" ]; then + local EFI_CODE="${VMDIR}/OVMF_CODE.fd" + local EFI_VARS="${VMDIR}/OVMF_VARS-1024x768.fd" + else + MAC_MISSING="Firmware" + fi + + if [ -e "${VMDIR}/OpenCore.qcow2" ]; then + local MAC_BOOTLOADER="${VMDIR}/OpenCore.qcow2" + elif [ -e "${VMDIR}/ESP.qcow2" ]; then + # Backwards compatibility for Clover + local MAC_BOOTLOADER="${VMDIR}/ESP.qcow2" + else + MAC_MISSING="Bootloader" + fi + + if [ -n "${MAC_MISSING}" ]; then + echo "ERROR! macOS ${MAC_MISSING} was not found." + echo " Use 'quickget' to download the required files." + exit 1 + fi elif [[ "${boot}" == *"efi"* ]]; then if [ -e "/usr/share/OVMF/OVMF_CODE_4M.fd" ]; then echo " - BOOT: EFI" local EFI_CODE="/usr/share/OVMF/OVMF_CODE_4M.fd" local EFI_VARS="${VMDIR}/OVMF_VARS_4M.fd" - if [ ! -e "${EFI_VARS}" ]; then + if [ -e "${VMDIR}/${VMNAME}-vars.fd" ]; then + # Preserve backward compatibility + mv "${VMDIR}/${VMNAME}-vars.fd" "${EFI_VARS}" + elif [ ! -e "${EFI_VARS}" ]; then cp "/usr/share/OVMF/OVMF_VARS_4M.fd" "${EFI_VARS}" fi else diff --git a/quickget b/quickget index 7f2310d..b08904f 100755 --- a/quickget +++ b/quickget @@ -205,6 +205,13 @@ function get_macos() { make_vm_dir + # Get firmware + web_get "https://github.com/kholia/OSX-KVM/raw/master/OpenCore-Catalina/OpenCore.qcow2" "${VM_PATH}" + web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_CODE.fd" "${VM_PATH}" + if [ ! -e "${VM_PATH}/OVMF_VARS-1024x768.fd" ]; then + web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_VARS-1024x768.fd" "${VM_PATH}" + fi + if [ ! -e "${VM_PATH}/RecoveryImage.chunklist" ]; then echo "Downloading ${RELEASE}..." ${MACRECOVERY} \