Last active
August 19, 2023 12:13
-
-
Save mikebeaton/50082c191c93dfa055d13f0a3be997d0 to your computer and use it in GitHub Desktop.
Make rhboot/shim inside Ubuntu multipass on macOS, targetting OpenCore.efi as bootloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# `./shim_make.sh install` within macOS, then `/Users/{macOS-user}/shim_root/shim_make.sh` within multipass | |
SHIM_ROOT="shim_root" | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
if [ "$1" = "install" ] ; then | |
# Install multipass, mount target folder and copy this script to it | |
echo | |
echo "Installing multipass..." | |
brew install --cask multipass | |
echo "" | |
echo "Launching primary..." | |
multipass launch -n primary | |
echo "" | |
echo "Adding and mounting ~/${SHIM_ROOT}..." | |
mkdir ~/${SHIM_ROOT} | |
multipass mount ~/${SHIM_ROOT} primary:/Users/$(whoami)/${SHIM_ROOT} | |
echo "" | |
echo "Copying script..." | |
sed "s/{macOS-user}/$(whoami)/g" $0 > ~/${SHIM_ROOT}/shim_make.sh | |
chmod +x ~/${SHIM_ROOT}/shim_make.sh | |
echo "" | |
echo "Run ${GREEN}/Users/$(whoami)/${SHIM_ROOT}/shim_make.sh${NC} within multipass..." | |
echo "" | |
multipass shell | |
exit | |
fi | |
# Install dependencies and make | |
echo "Installing dependencies..." | |
sudo apt-get update | |
sudo apt install -y gcc make git libelf-dev | |
echo "" | |
echo "Cloning shim..." | |
git clone https://github.com/rhboot/shim.git | |
cd shim | |
git submodule update --init | |
echo "" | |
echo "Making..." | |
DEFAULT_LOADER="\\\\\\\\OpenCore.efi" make | |
echo "" | |
echo "Installing..." | |
rm -rf /Users/{macOS-user}/${SHIM_ROOT}/usr | |
DESTDIR=/Users/{macOS-user}/${SHIM_ROOT} EFIDIR="OC" OSLABEL="OpenCore" make install | |
echo "" | |
echo "Exit to macOS then run ${GREEN}cp /Users/{macOS-user}/${SHIM_ROOT}/boot/efi/EFI/OC/* /Volumes/{ESP}/EFI/OC${NC} ..." | |
exit | |
## Re-make | |
make clean | |
rm -rf /Users/{macOS-user}/${SHIM_ROOT}/usr | |
make | |
DESTDIR=/Users/{macOS-user}/${SHIM_ROOT} EFIDIR=OC OSLABEL=OpenCore make install | |
## To debug shim (e.g. within OVMF) make with | |
OPTIMIZATIONS="-O0" make | |
## and set 605dab50-e046-4300-abb6-3dd810dd8b23:SHIM_DEBUG to (UINT8)1 (<data>AQ==</data>) in NVRAM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment