From 0ade12baf06664cf776e6ef75073c16ff0580884 Mon Sep 17 00:00:00 2001 From: Droga Date: Wed, 25 Nov 2026 21:32:24 -0300 Subject: [PATCH] Ship Apple's HfsPlus.efi in the zip, keep OpenHfsPlus.efi as the fallback Docs/Sample.plist already loads HfsPlus.efi and OpenCore's docs recommend it, but the zip only had OpenHfsPlus.efi. On a Gigabyte Z790 (i9-12900KF) OpenHfsPlus.efi froze the machine before the picker with the keyboard dead, with this fork and with official 1.0.8; Apple's HfsPlus.efi booted fine. DrogaBox/hfsplus.sh downloads HfsPlus.efi (X64) and HfsPlus32.efi (IA32) from OcBinaryData at c2a98980 and checks their sha256; the binaries are never committed. HFSPLUS_DIR takes them from a local OcBinaryData/Drivers instead. If they can't be had, the zip keeps only OpenHfsPlus.efi, its sample configs are switched to it, and the build prints FALLING BACK TO OpenHfsPlus.efi. REQUIRE_HFSPLUS=1 makes that an error, for releases. --- .github/README.md | 11 +++++ DrogaBox/BASE.md | 8 +++ DrogaBox/hfsplus.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++ build_oc.tool | 5 ++ 4 files changed, 141 insertions(+) create mode 100644 DrogaBox/hfsplus.sh diff --git a/.github/README.md b/.github/README.md index 3fe32759..1a690b53 100644 --- a/.github/README.md +++ b/.github/README.md @@ -115,6 +115,10 @@ Every change is a commit on top of the official base (`git log ebea824..main`). - `DrogaBox/Theme/AETHER`: GoldenGate icons plus my background. `build_oc.tool` puts it in the zip under `Resources/Image/DrogaBox/AETHER`. - `Docs/Configuration.tex`: `AllowPickerEdit`, the editor, bit `0x0400` and AETHER with `Auto`. +- `DrogaBox/hfsplus.sh`: the zip carries Apple's `HfsPlus.efi`, which `Sample.plist` already loads and + OpenCore's docs recommend. It's downloaded from OcBinaryData at a fixed commit and its sha256 checked, + never kept in this repo. `OpenHfsPlus.efi` stays in the zip too. Stock zips only have `OpenHfsPlus.efi`, + and on a Z790 board it froze the machine before the picker, keyboard dead; `HfsPlus.efi` booted fine. **Tests and tools** - `Utilities/TestCanopy` (new): runs the real OpenCanopy on a Mac with a fake 1920×1080 screen and @@ -142,6 +146,8 @@ usual way. `OC/Resources/Image/DrogaBox` and set `PickerMode` to `External`. The zip has no font, same as stock OpenCore: OpenCanopy needs `Resources/Font` from [OcBinaryData](https://github.com/acidanthera/OcBinaryData), so copy it if you don't have it yet. + If your config loads `OpenHfsPlus.efi` under `UEFI > Drivers`, copy `OC/Drivers/HfsPlus.efi` from the + zip and change that entry's `Path` to `HfsPlus.efi`, the way `Docs/Sample.plist` has it. 4. In `config.plist`, under `Misc > Security`, add: ```xml AllowPickerEdit @@ -171,6 +177,11 @@ ARCHS=X64 TARGETS=RELEASE,DEBUG TOOLCHAINS=XCODE5 ./build_oc.tool The zips end up in `Binaries/`. The first run downloads the UDK into `UDK/`. +Packaging downloads Apple's `HfsPlus.efi` from OcBinaryData (see `DrogaBox/hfsplus.sh` for the commit and +sha256). Offline, point `HFSPLUS_DIR` at a copy of OcBinaryData's `Drivers` folder. If neither works, the +build says `FALLING BACK TO OpenHfsPlus.efi`: that zip has no `HfsPlus.efi` and its sample configs load +`OpenHfsPlus.efi` instead. `REQUIRE_HFSPLUS=1` makes that an error, which is how releases are built. + Tests (the editor, the plist writer, and the picker and sheet drawn on the host, plain and with ASan/UBSan): diff --git a/DrogaBox/BASE.md b/DrogaBox/BASE.md index d41c909c..eff2d31e 100644 --- a/DrogaBox/BASE.md +++ b/DrogaBox/BASE.md @@ -37,6 +37,7 @@ pinned_on: 2026-11-24 | `EDITOR.md` | The user guide of the `F2` editor | | `screenshots/` | Images for the README and the guide | | `Theme/AETHER` | The default theme, packaged into the zip (see `Theme/README.md`) | +| `hfsplus.sh` | Puts Apple's `HfsPlus.efi` in the zip, from OcBinaryData at a fixed commit with its sha256 checked; falls back to `OpenHfsPlus.efi` | | `tools/` | `render-screen.swift` (text console to PNG) and `banner.swift` (README banner) | ## Moving to a newer official commit @@ -69,6 +70,13 @@ ARCHS=X64 TARGETS=RELEASE,DEBUG TOOLCHAINS=XCODE5 ./build_oc.tool `build_oc.tool` downloads the UDK into `UDK/`, which git ignores. +It also downloads Apple's `HfsPlus.efi` (X64) and `HfsPlus32.efi` (packaged as `HfsPlus.efi` for IA32) +from OcBinaryData at `DB_HFSPLUS_COMMIT` in `hfsplus.sh` and checks their sha256. Offline, set +`HFSPLUS_DIR=/path/to/OcBinaryData/Drivers`. Without either, the zip keeps only `OpenHfsPlus.efi`, its +`Docs/Sample*.plist` are switched to it, and the build prints `FALLING BACK TO OpenHfsPlus.efi`. Build +releases with `REQUIRE_HFSPLUS=1`, which stops instead. To move to a newer OcBinaryData, change the commit +and both hashes together. + ## Versions Our version is the OpenCore base plus our number, for example `1.0.9-db.1`. It goes in tags and release diff --git a/DrogaBox/hfsplus.sh b/DrogaBox/hfsplus.sh new file mode 100644 index 00000000..c30ac4f7 --- /dev/null +++ b/DrogaBox/hfsplus.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# Apple's HFS+ driver in the zip. build_oc.tool sources this file and calls db_hfsplus_package. +# +# Docs/Sample.plist loads HfsPlus.efi, and OpenCore's docs recommend Apple's driver, but the +# official zip only carries OpenHfsPlus.efi, because Apple's binary can't be shipped in +# OpenCorePkg. On a Z790 board OpenHfsPlus.efi froze the machine before the picker, with the +# keyboard dead, and Apple's HfsPlus.efi fixed it (2026-11-25). +# +# So the zip gets HfsPlus.efi from OcBinaryData at a pinned commit, with its sha256 checked. The +# binary is never committed here. If it can't be had, the zip keeps only OpenHfsPlus.efi, its +# sample configs are switched to it so they still match the zip, and the build says so. +# OpenHfsPlus.efi stays in the zip either way. +# +# HFSPLUS_DIR=/path/to/OcBinaryData/Drivers take the files from there instead of downloading +# (same sha256 check) +# REQUIRE_HFSPLUS=1 stop the build instead of falling back (releases) +# + +DB_HFSPLUS_COMMIT=c2a98980d30e39a571a2843ab26aa8d2b9188094 +DB_HFSPLUS_URL="https://raw.githubusercontent.com/acidanthera/OcBinaryData/${DB_HFSPLUS_COMMIT}/Drivers" + +# Prints " " for an arch. +db_hfsplus_source() { + case "$1" in + X64) echo "HfsPlus.efi a55b5fff36578864ba6792c4c6369c71f6f35b61dd5a853ddf8583cd36c31d8f" ;; + IA32) echo "HfsPlus32.efi 40badc5338e4cb373ed8370aba52bad9668f1970c68f546b9cba46ed55153d18" ;; + *) return 1 ;; + esac +} + +db_sha256() { + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$1" | cut -d ' ' -f 1 + else + sha256sum "$1" | cut -d ' ' -f 1 + fi +} + +# db_hfsplus_fetch ...: puts /.efi for every arch, checked. +db_hfsplus_fetch() { + local tmp="$1" + shift + local arch src name sha got + for arch in "$@"; do + src=$(db_hfsplus_source "$arch") || { + echo "HfsPlus.efi: OcBinaryData has no Apple driver for ${arch}" + return 1 + } + read -r name sha <<<"$src" + if [ -n "${HFSPLUS_DIR}" ]; then + cp "${HFSPLUS_DIR}/${name}" "${tmp}/${arch}.efi" || { + echo "HfsPlus.efi: cannot read ${HFSPLUS_DIR}/${name}" + return 1 + } + else + curl -LfsS --retry 2 --connect-timeout 20 -o "${tmp}/${arch}.efi" "${DB_HFSPLUS_URL}/${name}" || { + echo "HfsPlus.efi: cannot download ${DB_HFSPLUS_URL}/${name}" + return 1 + } + fi + got=$(db_sha256 "${tmp}/${arch}.efi") + if [ "$got" != "$sha" ]; then + echo "HfsPlus.efi: ${name} for ${arch} has sha256 ${got}, expected ${sha}" + return 1 + fi + done + return 0 +} + +# db_hfsplus_package ...: call once the drivers and Docs are in the package dir. +db_hfsplus_package() { + local dst="$1" + shift + local tmp arch plist n ok=1 + + tmp=$(mktemp -d) || return 1 + if db_hfsplus_fetch "$tmp" "$@"; then + for arch in "$@"; do + cp "${tmp}/${arch}.efi" "${dst}/${arch}/EFI/OC/Drivers/HfsPlus.efi" || ok=0 + done + else + ok=0 + fi + rm -rf "$tmp" + + if [ "$ok" = "1" ]; then + echo "HfsPlus.efi: Apple's driver from OcBinaryData ${DB_HFSPLUS_COMMIT:0:12} (sha256 checked) is in the zip;" \ + "OpenHfsPlus.efi stays as the fallback" + return 0 + fi + + for arch in "$@"; do + rm -f "${dst}/${arch}/EFI/OC/Drivers/HfsPlus.efi" + done + + if [ "${REQUIRE_HFSPLUS}" = "1" ]; then + echo "ERROR: Apple's HfsPlus.efi is not available and REQUIRE_HFSPLUS=1" + return 1 + fi + + for plist in "${dst}/Docs/Sample.plist" "${dst}/Docs/SampleCustom.plist"; do + n=$(grep -c 'HfsPlus.efi' "$plist") + if [ "$n" != "1" ]; then + echo "ERROR: expected one HfsPlus.efi driver entry in ${plist##*/}, found ${n}" + return 1 + fi + sed 's|HfsPlus.efi|OpenHfsPlus.efi|' "$plist" > "${plist}.tmp" || return 1 + mv "${plist}.tmp" "$plist" || return 1 + done + + echo "WARNING: FALLING BACK TO OpenHfsPlus.efi. Apple's HfsPlus.efi is NOT in this zip, and the zip's" + echo "WARNING: Docs/Sample.plist and SampleCustom.plist now load OpenHfsPlus.efi instead. OpenHfsPlus.efi" + echo "WARNING: froze at least one machine before the picker. Rebuild with network access, or with" + echo "WARNING: HFSPLUS_DIR=/path/to/OcBinaryData/Drivers, before handing this zip to anyone." + return 0 +} diff --git a/build_oc.tool b/build_oc.tool index 650df0ed..c5f37bc0 100755 --- a/build_oc.tool +++ b/build_oc.tool @@ -252,6 +252,11 @@ package() { cp "${selfdir}/Docs/${doc}" "${dstdir}/Docs"/ || exit 1 done cp "${selfdir}/Changelog.md" "${dstdir}/Docs"/ || exit 1 + + # Apple's HfsPlus.efi from OcBinaryData, or OpenHfsPlus.efi as the fallback (DrogaBox/hfsplus.sh). + # shellcheck source=DrogaBox/hfsplus.sh + source "${selfdir}/DrogaBox/hfsplus.sh" || exit 1 + db_hfsplus_package "${dstdir}" "${ARCHS[@]}" || exit 1 cp -r "${selfdir}/Docs/AcpiSamples/"* "${dstdir}/Docs/AcpiSamples"/ || exit 1 mkdir -p "${dstdir}/Docs/AcpiSamples/Binaries" || exit 1