Skip to content
Permalink
Browse files

[Experimental] Adopt modern methods

  • Loading branch information...
kholia committed May 1, 2019
1 parent 74d3768 commit dc01ccdc36d3499a439ae6225b791a6a43d232a5
@@ -4,3 +4,8 @@ pbzx-src/xz-5.2.2
pbzx-src/pbzx
mac_hdd.img
*.sha256sum
*.sucatalog
*.img
*.dist
*.smd
*.dmg
@@ -45,3 +45,7 @@
* Povilas Kanapickas (p12tic) - Flexible ISO generation

* Dick Marinus (meeuw) - Allow usage of latest Clover

* Foxlet (foxlet) - Allow installation without existing macOS

* Ralph Kühnert (redradrat) - Debug fetch-macOS.py script
@@ -0,0 +1,4 @@
clean:
rm -rf *.dist 2>/dev/null
rm -rf *.sucatalog 2>/dev/null
rm -rf *.smd 2>/dev/null
BIN +5.63 MB Mojave/CloverNG.qcow2
Binary file not shown.
@@ -7,8 +7,21 @@ sse4.2, and popcnt to avoid Illegal Instruction crashes in the graphics
subsystem after boot is complete (causing the top menu bar to flash on and off,
and Finder to crash on open).

Tested macOS Mojave 10.14.4 with Clover 4920 (from April, 2019).
Tested with macOS Mojave 10.14.4 with Clover 4920 (from May, 2019).

Note: Use `create_iso_mojave.sh` for generating a macOS Mojave based ISO image.

Note: Use 64-bit Ubuntu 18.04.2 LTS as the host for "best" results.

Old:

`rm -f Clover.qcow2; sudo ./clover-image.sh --iso Clover-v2.4k-4920-X64.iso --cfg clover/config.plist.stripped.qemu --img CloverNG.qcow2`

Modern:

`rm -f CloverNG.qcow2; sudo ./clover-image-ng.sh --iso Clover-v2.4k-4920-X64.iso --cfg clover/config.plist.stripped.qemu --img CloverNG.qcow2`

The `modern` installation method (borrowed from https://github.com/foxlet/macOS-Simple-KVM) requires an internet connection
(during macOS installation) to work.

As indicated in `ideas.md`, there is a way to overcome this (final) limitation.
@@ -0,0 +1,183 @@
#!/bin/bash

# https://github.com/kraxel/imagefish

######################################################################
# defaults

iso=""
img=""
cfg=""

######################################################################
# create work dir

function msg() {
local txt="$1"
local bold="\x1b[1m"
local normal="\x1b[0m"
echo -e "${bold}### ${txt}${normal}"
}

function do_cleanup() {
msg "cleaning up ..."
if test "$GUESTFISH_PID" != ""; then
guestfish --remote -- exit >/dev/null 2>&1 || true
fi
sudo rm -rf "$WORK"
}

WORK="${TMPDIR-/var/tmp}/${0##*/}-$$"
mkdir "$WORK" || exit 1
trap 'do_cleanup' EXIT

BASE="$(dirname $0)"

######################################################################
# parse args

function print_help() {
cat <<EOF
usage: $0 [ options ]
options:
--iso <iso-image>
--img <disk-image>
--cfg <clover-config>
EOF
}

while test "$1" != ""; do
case "$1" in
--iso)
iso="$2"
shift; shift
;;
--img)
img="$2"
shift; shift
;;
--cfg)
cfg="$2"
shift; shift
;;
esac
done

######################################################################
# guestfish script helpers

function fish() {
echo "#" "$@"
guestfish --remote -- "$@" || exit 1
}

function fish_init() {
local format

case "$img" in
*.raw) format="raw" ;;
*) format="qcow2";;
esac

msg "creating and adding disk image"
fish disk-create $img $format 256M
fish add $img
fish run
}

function fish_fini() {
fish umount-all
}

######################################################################
# sanity checks

if test ! -f "$iso"; then
echo "ERROR: iso not found: $iso"
exit 1
fi
if test ! -f "$cfg"; then
echo "ERROR: cfg not found: $cfg"
exit 1
fi
if test -f "$img"; then
if test "$allow_override" = "yes"; then
rm -f "$img"
else
echo "ERROR: image exists: $img"
exit 1
fi
fi

######################################################################
# go!

msg "copy files from iso"
guestfish -a "$iso" -m "/dev/sda:/:norock" <<EOF || exit 1
copy-out /EFI $WORK
EOF

#msg "[debug] list drivers in EFI/CLOVER"
#(cd $WORK/EFI/CLOVER; find driver* -print)

export LIBGUESTFS_BACKEND=direct
eval $(guestfish --listen)
if test "$GUESTFISH_PID" = ""; then
echo "ERROR: starting guestfish failed"
exit 1
fi

fish_init

msg "partition disk image"
fish part-init /dev/sda gpt
fish part-add /dev/sda p 2048 200000
fish part-add /dev/sda p 202048 -2048
fish part-set-gpt-type /dev/sda 1 C12A7328-F81F-11D2-BA4B-00A0C93EC93B
fish part-set-bootable /dev/sda 1 true
fish mkfs vfat /dev/sda1 label:EFI
fish mkfs vfat /dev/sda2 label:clover
fish mount /dev/sda2 /
fish mkdir /ESP
fish mount /dev/sda1 /ESP

msg "copy files to disk image"
cp -v "$cfg" $WORK/config.plist
fish mkdir /ESP/EFI
fish mkdir /ESP/EFI/CLOVER
fish copy-in $WORK/EFI/BOOT /ESP/EFI
fish copy-in $WORK/EFI/CLOVER/CLOVERX64.efi /ESP/EFI/CLOVER


# With the inclusion of PartitionDxe-64.efi and ApfsDriverLoader-64.efi in your
# drivers64UEFI folder there will no longer be a need to add apfs.efi manually.
# - Borrowed from https://hackintosher.com/ forums.
fish copy-in $WORK/EFI/CLOVER/drivers64UEFI /ESP/EFI/CLOVER
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/PartitionDxe-64.efi \
/ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/ApfsDriverLoader-64.efi \
/ESP/EFI/CLOVER/drivers64UEFI

# Reversed from https://github.com/foxlet/macOS-Simple-KVM/blob/master/ESP.qcow2. Thanks!
fish copy-in startup.nsh /
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/OsxAptioFix3Drv-64.efi /ESP/EFI/CLOVER/drivers64UEFI
# FileVault2
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/FileVault2/AppleImageCodec-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/FileVault2/FirmwareVolume-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/FileVault2/AppleKeyAggregator-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/FileVault2/AppleUITheme-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers-Off/drivers64UEFI/FileVault2/AppleKeyFeeder-64.efi /ESP/EFI/CLOVER/drivers64UEFI

fish copy-in $WORK/EFI/CLOVER/drivers64UEFI/VBoxHfs-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers64UEFI/FSInject-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers64UEFI/SMCHelper-64.efi /ESP/EFI/CLOVER/drivers64UEFI
fish copy-in $WORK/EFI/CLOVER/drivers64UEFI/DataHubDxe-64.efi /ESP/EFI/CLOVER/drivers64UEFI

fish copy-in $WORK/EFI/CLOVER/tools /ESP/EFI/CLOVER
fish copy-in $WORK/config.plist /ESP/EFI/CLOVER
# AudioDxe introduced since Clover-v2.4k-4844-X64.iso hangs on boot
fish rm /ESP/EFI/CLOVER/drivers64UEFI/AudioDxe-64.efi

nodef="$WORK/EFI/CLOVER/drivers-Off/drivers64UEFI"
fish ls /ESP/EFI/CLOVER/drivers64UEFI
fish_fini
0 Mojave/clover-image.sh 100755 → 100644
No changes.
@@ -5,7 +5,7 @@
<key>Boot</key>
<dict>
<key>Arguments</key>
<string></string>
<string>-v</string>
<key>DefaultVolume</key>
<string>system</string>
<key>Log</key>
@@ -74,7 +74,7 @@
<key>SystemParameters</key>
<dict>
<key>InjectKexts</key>
<false/>
<true/>
<key>InjectSystemID</key>
<true/>
</dict>
@@ -5,15 +5,15 @@
<key>Boot</key>
<dict>
<key>Arguments</key>
<string></string>
<string>-v</string>
<key>DefaultVolume</key>
<string>clover</string>
<key>Log</key>
<true/>
<key>Secure</key>
<false/>
<key>Timeout</key>
<integer>3</integer>
<integer>5</integer>
</dict>
<key>GUI</key>
<dict>
@@ -44,7 +44,7 @@
<key>SystemParameters</key>
<dict>
<key>InjectKexts</key>
<false/>
<true/>
<key>InjectSystemID</key>
<true/>
</dict>
@@ -0,0 +1 @@
fs0:\EFI\CLOVER\CLOVERX64.efi

0 comments on commit dc01ccd

Please sign in to comment.
You can’t perform that action at this time.