🔥 Stop putting Lilu in the OpenCore image, and drop --no-kexts

Lilu is replaced by Graft, a kext of reims-vgpu's own that its guest kext set
now carries, so reims-ctl adds it with --add-kext like the rest of the set.
Images no longer need a kext of reims-util's own:

- Lilu 1.7.2's release is no longer downloaded, cached or written into
  EFI/OC/Kexts, and Kernel > Add holds the kexts --add-kext gives alone, in
  their order, or nothing.
- --no-kexts goes: its only meaning was to leave Lilu out. reims-ctl never
  passes it.
- added::check loses what existed only for Lilu: a bundle named or
  identified as the image's own Lilu.kext, and a kext linking against Lilu
  when --no-kexts left it out. It keeps refusing a bundle name or identifier
  given twice and a kext given before one it links against.
- README.md, LICENSE, the cache's doc and --add-kext's help no longer name
  Lilu.

Kexts added with no bounds still load on Darwin 25 alone; the next commit
drops that range.
This commit is contained in:
Anees Iqbal committed 2026-11-07 22:49:45 -08:00
1 parent 0b9c3780a3
commit c8cd41aba8
8 files changed
+66 -229

No files matched your search

+3 -3
View File
@@ -19,7 +19,7 @@ OpenCorePkg's macserial (Copyright (c) 2018-2020 vit9696, Copyright (c) 2020
Matis Schotte), so that file is also under OpenCorePkg's BSD-3-Clause license: Matis Schotte), so that file is also under OpenCorePkg's BSD-3-Clause license:
LICENSES/BSD-3-Clause-OpenCorePkg.txt. LICENSES/BSD-3-Clause-OpenCorePkg.txt.
What reims-util downloads and writes into images, such as OpenCore, Lilu and What reims-util downloads and writes into images, such as OpenCore and OVMF,
OVMF, is not part of the repository, and keeps its own license; OVMF's is not part of the repository, and keeps its own license; OVMF's licenses are
licenses are written beside OVMF_CODE.fd. The crates the build takes from crates.io keep written beside OVMF_CODE.fd. The crates the build takes from crates.io keep
their own licenses too. their own licenses too.
+13 -16
View File
@@ -63,9 +63,9 @@ reims-util opencore -o OpenCore.qcow2
This writes a 128 MiB disk image with OpenCore 1.0.8 on its EFI partition: qcow2 for a `.qcow2` This writes a 128 MiB disk image with OpenCore 1.0.8 on its EFI partition: qcow2 for a `.qcow2`
name, and a raw disk image for anything else (`.img`). Beside it go `OVMF_CODE.fd` and name, and a raw disk image for anything else (`.img`). Beside it go `OVMF_CODE.fd` and
`OVMF_VARS.fd`, with OVMF's licenses. What goes in them is downloaded from pinned sources `OVMF_VARS.fd`, with OVMF's licenses. What goes in them is downloaded from pinned sources
(OpenCore's release, a commit of its picker icons and boot chime, OcBinaryData, and Lilu's (OpenCore's release and a commit of its picker icons and boot chime, OcBinaryData, from GitHub;
release, from GitHub; OVMF from Arch Linux's `edk2-ovmf` package), checked against the hashes OVMF from Arch Linux's `edk2-ovmf` package), checked against the hashes reims-util knows, and
reims-util knows, and cached in `~/.cache/reims-util`, so it's only downloaded once. cached in `~/.cache/reims-util`, so it's only downloaded once.
Each image gets a Mac identity of its own: a serial number, logic board serial (MLB), system UUID Each image gets a Mac identity of its own: a serial number, logic board serial (MLB), system UUID
and ROM, which it prints when it's done. Keep them if you'll want the same identity in another and ROM, which it prints when it's done. Keep them if you'll want the same identity in another
@@ -79,9 +79,8 @@ another with `--model`:
What's in the image, and why: What's in the image, and why:
- **Lilu, which loads on macOS 26 alone**: kexts you add with `--add-kext` load after it - **Only the kexts you add** with `--add-kext` ([below](#adding-kexts)), such as reims-vgpu's
([below](#adding-kexts)), and can link against it, as reims-vgpu's guest kexts do. guest kexts. There are no others: QEMU's `isa-applesmc` is the SMC.
`--no-kexts` leaves it out. There are no other kexts: QEMU's `isa-applesmc` is the SMC.
- **The drivers a VM boots with**: OpenRuntime, OpenHfsPlus (recovery images and installers are - **The drivers a VM boots with**: OpenRuntime, OpenHfsPlus (recovery images and installers are
HFS+), OpenPartitionDxe (for older recovery images) and ResetNvramEntry. HFS+), OpenPartitionDxe (for older recovery images) and ResetNvramEntry.
- **No boot picker**: OpenCore boots the default entry, the disk macOS last chose as its startup - **No boot picker**: OpenCore boots the default entry, the disk macOS last chose as its startup
@@ -104,8 +103,8 @@ arguments, and `--verbose-boot` shows the kernel's messages while it boots.
#### Adding kexts #### Adding kexts
`--add-kext` puts a kext bundle of your own in the image, after Lilu. Repeat it for more: they `--add-kext` puts a kext bundle of your own in the image. Repeat it for more: they load in the
load in the order you give them, so give a kext after the ones it links against. order you give them, so give a kext after the ones it links against.
```sh ```sh
reims-util opencore -o OpenCore.qcow2 \ reims-util opencore -o OpenCore.qcow2 \
@@ -114,12 +113,10 @@ reims-util opencore -o OpenCore.qcow2 \
Each value is `PATH[,MIN[,MAX]]`: the bundle, then the Darwin versions it loads on, as OpenCore's Each value is `PATH[,MIN[,MAX]]`: the bundle, then the Darwin versions it loads on, as OpenCore's
MinKernel and MaxKernel take them (25.4.0 is macOS 26.4). Left out, they're 25.0.0 and 25.99.99, MinKernel and MaxKernel take them (25.4.0 is macOS 26.4). Left out, they're 25.0.0 and 25.99.99,
macOS 26, as for Lilu. The bundle is copied whole into `EFI/OC/Kexts`, without its dotfiles, and macOS 26. The bundle is copied whole into `EFI/OC/Kexts`, without its dotfiles, and OpenCore loads
OpenCore loads the executable its Info.plist names, or none for a kext with no code. reims-util the executable its Info.plist names, or none for a kext with no code. reims-util refuses a kext
refuses a kext with the name or bundle identifier of one already in the image (the image's FAT32 with the name or bundle identifier of one given before it (the image's FAT32 partition doesn't
partition doesn't tell names apart by case), and one that links against a kext given after it, or tell names apart by case), and one that links against a kext given after it.
against Lilu when `--no-kexts` leaves Lilu out. `--no-kexts` leaves out Lilu alone: the kexts you
add still go in, so you can give a Lilu of your own, ahead of the kexts that link against it.
### Online installers ### Online installers
@@ -199,5 +196,5 @@ reims-util --json online-installer tahoe -o ~/vms/mac
reims-util is licensed under GPL-2.0-or-later OR LGPL-3.0-or-later; see [LICENSE](LICENSE). The reims-util is licensed under GPL-2.0-or-later OR LGPL-3.0-or-later; see [LICENSE](LICENSE). The
serial number tables come from OpenCorePkg's macserial, under its BSD-3-Clause license. serial number tables come from OpenCorePkg's macserial, under its BSD-3-Clause license.
OpenCore, its picker icons and chime (OcBinaryData), Lilu and OVMF, which reims-util downloads, OpenCore, its picker icons and chime (OcBinaryData), and OVMF, which reims-util downloads, keep
keep their own licenses. their own licenses.
+1 -1
View File
@@ -1,4 +1,4 @@
//! Files fetched once and kept: the OpenCore release, OcBinaryData, Lilu and the OVMF package, each //! Files fetched once and kept: the OpenCore release, OcBinaryData and the OVMF package, each
//! pinned to its SHA-256, under `$XDG_CACHE_HOME/reims-util` (`~/.cache/reims-util`). //! pinned to its SHA-256, under `$XDG_CACHE_HOME/reims-util` (`~/.cache/reims-util`).
use crate::http::{self, Dest, Download, NoCheck}; use crate::http::{self, Dest, Download, NoCheck};
+2 -7
View File
@@ -108,12 +108,8 @@ pub struct OpencoreArgs {
/// Show OpenCore's boot picker at every boot (by default OpenCore boots the default entry) /// Show OpenCore's boot picker at every boot (by default OpenCore boots the default entry)
#[arg(long)] #[arg(long)]
pub show_picker: bool, pub show_picker: bool,
/// Leave out Lilu: the image carries only the kexts given with --add-kext, such as a Lilu of /// Add a kext bundle, loaded on Darwin MIN to MAX (default 25.0.0 to 25.99.99, macOS 26).
/// your own, or none /// Repeat it for more: they load in the order given
#[arg(long)]
pub no_kexts: bool,
/// Add a kext bundle, loaded after Lilu on Darwin MIN to MAX (default 25.0.0 to 25.99.99,
/// macOS 26). Repeat it for more: they load in the order given
#[arg(long = "add-kext", value_name = "PATH[,MIN[,MAX]]", value_parser = added::parse)] #[arg(long = "add-kext", value_name = "PATH[,MIN[,MAX]]", value_parser = added::parse)]
pub add_kext: Vec<added::Spec>, pub add_kext: Vec<added::Spec>,
/// Accepted and ignored: --no-apv-arm64-port and --no-video, whose kexts images no longer /// Accepted and ignored: --no-apv-arm64-port and --no-video, whose kexts images no longer
@@ -361,7 +357,6 @@ pub fn opencore_options(a: &OpencoreArgs) -> Result<opencore::Options> {
hide_vm: !a.show_vm, hide_vm: !a.show_vm,
graphical_picker: !a.text_picker, graphical_picker: !a.text_picker,
show_picker: a.show_picker, show_picker: a.show_picker,
kexts: !a.no_kexts,
}, },
add_kexts: a.add_kext.clone(), add_kexts: a.add_kext.clone(),
ovmf_dir, ovmf_dir,
+17 -78
View File
@@ -1,5 +1,5 @@
//! Kexts given with `--add-kext`, which the image carries after its own, Lilu, in the order given: //! Kexts given with `--add-kext`, which the image carries in the order given: reims-vgpu's guest
//! reims-vgpu's guest kexts for its own GPU device, for one. Each is a bundle on disk, copied //! kexts for its own GPU device, for one. Each is a bundle on disk, copied
//! whole into `EFI/OC/Kexts` (dotfiles left out), and loaded by a Kernel > Add entry made from its //! whole into `EFI/OC/Kexts` (dotfiles left out), and loaded by a Kernel > Add entry made from its
//! Info.plist and the Darwin versions it was given (config.rs). //! Info.plist and the Darwin versions it was given (config.rs).
@@ -16,8 +16,8 @@ pub struct Spec {
} }
/// Reads `PATH[,MIN[,MAX]]`. The path ends in `.kext`, so a comma in a folder's name stays in /// Reads `PATH[,MIN[,MAX]]`. The path ends in `.kext`, so a comma in a folder's name stays in
/// the path; MIN and MAX are versions as OpenCore takes them (25.4.0), each 25.0.0 and 25.99.99, /// the path; MIN and MAX are versions as OpenCore takes them (25.4.0), each 25.0.0 and 25.99.99
/// the bounds of the image's own kexts, when left out or empty. /// (macOS 26) when left out or empty.
pub fn parse(s: &str) -> Result<Spec, String> { pub fn parse(s: &str) -> Result<Spec, String> {
let usage = "give PATH[,MIN[,MAX]], such as Foo.kext,25.4.0,25.99.99"; let usage = "give PATH[,MIN[,MAX]], such as Foo.kext,25.4.0,25.99.99";
let mut path = s; let mut path = s;
@@ -174,29 +174,13 @@ fn walk(root: &Path, rel: &Path, files: &mut Vec<(String, Vec<u8>)>) -> Result<(
Ok(()) Ok(())
} }
/// Refuses `added` where it would clash with the image's own kexts, `own` (in the image when /// Refuses `added` where its kexts would clash with each other: a bundle name FAT32 can't tell
/// `own_in`), or with each other: a bundle name FAT32 can't tell from another's (it ignores /// from another's (it ignores case), an identifier given twice, or a kext given before one it
/// case), an identifier already loaded, or a library of the image's that does not load before it. /// links against.
pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> { pub fn check(added: &[Kext]) -> Result<()> {
let present: &[config::Kext] = if own_in { own } else { &[] };
for (i, k) in added.iter().enumerate() { for (i, k) in added.iter().enumerate() {
let earlier = &added[..i]; let earlier = &added[..i];
let same = |b: &str| b.eq_ignore_ascii_case(&k.bundle); let same = |b: &str| b.eq_ignore_ascii_case(&k.bundle);
if let Some(o) = present.iter().find(|o| same(o.bundle)) {
bail!(
"the image carries its own {}: leave {} out of --add-kext",
o.bundle,
k.bundle
);
}
if let Some(o) = present.iter().find(|o| o.identifier == k.identifier) {
bail!(
"{} is {}, as the image's own {} is",
k.bundle,
k.identifier,
o.bundle
);
}
if let Some(e) = earlier.iter().find(|e| same(&e.bundle)) { if let Some(e) = earlier.iter().find(|e| same(&e.bundle)) {
if e.bundle == k.bundle { if e.bundle == k.bundle {
bail!("{} is given twice", k.bundle); bail!("{} is given twice", k.bundle);
@@ -211,10 +195,7 @@ pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> {
bail!("{} and {} are both {}", e.bundle, k.bundle, k.identifier); bail!("{} and {} are both {}", e.bundle, k.bundle, k.identifier);
} }
for l in &k.libraries { for l in &k.libraries {
let before = *l == k.identifier if *l == k.identifier || earlier.iter().any(|e| e.identifier == *l) {
|| present.iter().any(|o| o.identifier == *l)
|| earlier.iter().any(|e| e.identifier == *l);
if before {
continue; continue;
} }
if let Some(later) = added[i + 1..].iter().find(|a| a.identifier == *l) { if let Some(later) = added[i + 1..].iter().find(|a| a.identifier == *l) {
@@ -225,13 +206,6 @@ pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> {
later.bundle later.bundle
); );
} }
if let Some(o) = own.iter().find(|o| o.identifier == *l) {
bail!(
"{} links against {} ({l}), which --no-kexts leaves out",
k.bundle,
o.bundle
);
}
} }
} }
Ok(()) Ok(())
@@ -240,7 +214,6 @@ pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::opencore::config::LILU;
fn spec(path: &str, min: &str, max: &str) -> Spec { fn spec(path: &str, min: &str, max: &str) -> Spec {
Spec { Spec {
@@ -357,7 +330,7 @@ pub(crate) mod tests {
#[test] #[test]
fn read_with_code() { fn read_with_code() {
let plist = info("t.loader", Some("Loader"), &["as.vit9696.Lilu"]); let plist = info("t.loader", Some("Loader"), &["com.apple.kpi.libkern"]);
let b = Bundle::new( let b = Bundle::new(
"Loader.kext", "Loader.kext",
&[ &[
@@ -373,7 +346,7 @@ pub(crate) mod tests {
assert_eq!(k.bundle, "Loader.kext"); assert_eq!(k.bundle, "Loader.kext");
assert_eq!(k.identifier, "t.loader"); assert_eq!(k.identifier, "t.loader");
assert_eq!(k.executable.as_deref(), Some("Loader")); assert_eq!(k.executable.as_deref(), Some("Loader"));
assert_eq!(k.libraries, ["as.vit9696.Lilu"]); assert_eq!(k.libraries, ["com.apple.kpi.libkern"]);
assert_eq!( assert_eq!(
(k.min_kernel.as_str(), k.max_kernel.as_str()), (k.min_kernel.as_str(), k.max_kernel.as_str()),
("25.4.0", config::KEXT_MAX_KERNEL) ("25.4.0", config::KEXT_MAX_KERNEL)
@@ -431,68 +404,34 @@ pub(crate) mod tests {
} }
#[test] #[test]
fn checked_against_the_image() { fn checked() {
let own = [LILU];
let ok = [ let ok = [
kext("Loader.kext", "t.loader", &["as.vit9696.Lilu"]), kext("Loader.kext", "t.loader", &["com.apple.kpi.libkern"]),
kext("Shim.kext", "t.shim", &["com.apple.kpi.iokit"]), kext("Shim.kext", "t.shim", &["com.apple.kpi.iokit"]),
kext("Gfx.kext", "t.gfx", &["t.shim", "t.loader", "t.gfx"]), kext("Gfx.kext", "t.gfx", &["t.shim", "t.loader", "t.gfx"]),
]; ];
check(&own, true, &ok).unwrap(); check(&ok).unwrap();
check(&own, true, &[]).unwrap(); check(&[]).unwrap();
check(&own, false, &[]).unwrap();
let refused = |own_in: bool, added: &[Kext], says: &str| { let refused = |added: &[Kext], says: &str| {
let e = check(&own, own_in, added).unwrap_err().to_string(); let e = check(added).unwrap_err().to_string();
assert!(e.contains(says), "{says}: {e}"); assert!(e.contains(says), "{says}: {e}");
}; };
refused( refused(
true,
&[kext("Lilu.kext", "t.other", &[])],
"carries its own Lilu.kext: leave Lilu.kext out",
);
refused(
true,
&[kext("lilu.KEXT", "t.other", &[])],
"carries its own Lilu.kext: leave lilu.KEXT out",
);
refused(
true,
&[kext("L.kext", "as.vit9696.Lilu", &[])],
"L.kext is as.vit9696.Lilu, as the image's own Lilu.kext is",
);
refused(
true,
&[kext("A.kext", "t.a", &[]), kext("A.kext", "t.b", &[])], &[kext("A.kext", "t.a", &[]), kext("A.kext", "t.b", &[])],
"A.kext is given twice", "A.kext is given twice",
); );
refused( refused(
true,
&[kext("A.kext", "t.a", &[]), kext("a.kext", "t.b", &[])], &[kext("A.kext", "t.a", &[]), kext("a.kext", "t.b", &[])],
"A.kext and a.kext are one name", "A.kext and a.kext are one name",
); );
refused( refused(
true,
&[kext("A.kext", "t.a", &[]), kext("B.kext", "t.a", &[])], &[kext("A.kext", "t.a", &[]), kext("B.kext", "t.a", &[])],
"A.kext and B.kext are both t.a", "A.kext and B.kext are both t.a",
); );
refused( refused(
true,
&[kext("A.kext", "t.a", &["t.b"]), kext("B.kext", "t.b", &[])], &[kext("A.kext", "t.a", &["t.b"]), kext("B.kext", "t.b", &[])],
"A.kext links against B.kext (t.b), which comes after it: give B.kext first", "A.kext links against B.kext (t.b), which comes after it: give B.kext first",
); );
refused(
false,
&[kext("Loader.kext", "t.loader", &["as.vit9696.Lilu"])],
"Loader.kext links against Lilu.kext (as.vit9696.Lilu), which --no-kexts leaves out",
);
// With --no-kexts, a Lilu of one's own goes in, ahead of its plugins.
let own_lilu = [
kext("Lilu.kext", "as.vit9696.Lilu", &[]),
kext("Loader.kext", "t.loader", &["as.vit9696.Lilu"]),
];
check(&own, false, &own_lilu).unwrap();
refused(true, &own_lilu, "carries its own Lilu.kext");
} }
} }
+25 -76
View File
@@ -11,9 +11,8 @@
//! picker, when asked for); //! picker, when asked for);
//! - the boot chime, which AudioDxe plays on the first Intel HDA controller and codec it finds, //! - the boot chime, which AudioDxe plays on the first Intel HDA controller and codec it finds,
//! when the VM has one, unless macOS's "Play sound on startup" is off (`StartupMute`); //! when the VM has one, unless macOS's "Play sound on startup" is off (`StartupMute`);
//! - on macOS 26, one kext, Lilu, which kexts given with `--add-kext` may link against; after it, //! - the kexts given with `--add-kext` (added.rs), in their order and on the Darwin versions
//! those kexts (added.rs), in their order and on the Darwin versions given; no others, as QEMU's //! given; no others, as QEMU's `isa-applesmc` is the SMC;
//! `isa-applesmc` is the SMC;
//! - one ACPI table, the `EC` and `USBX` devices macOS looks for (acpi.rs); //! - one ACPI table, the `EC` and `USBX` devices macOS looks for (acpi.rs);
//! - CPUID leaf 1 reported as a Skylake-SP (family 6, model 85, stepping 4), a CPU every x86-64 //! - CPUID leaf 1 reported as a Skylake-SP (family 6, model 85, stepping 4), a CPU every x86-64
//! macOS from 10.13 to 26 knows, whatever `-cpu` model the VM has; //! macOS from 10.13 to 26 knows, whatever `-cpu` model the VM has;
@@ -46,25 +45,7 @@ pub fn drivers(o: &Options) -> Vec<&'static str> {
d d
} }
/// A kext of reims-util's own in `EFI/OC/Kexts`: its bundle, its `CFBundleIdentifier`, and the /// A kext added with no bounds of its own loads on Darwin 25 alone, macOS 26.
/// executable in its `Contents/MacOS`.
pub struct Kext {
pub bundle: &'static str,
pub identifier: &'static str,
pub executable: &'static str,
}
pub const LILU: Kext = Kext {
bundle: "Lilu.kext",
identifier: "as.vit9696.Lilu",
executable: "Lilu",
};
/// reims-util's kexts, in the order they load.
pub const OWN: [Kext; 1] = [LILU];
/// reims-util's kexts load on Darwin 25 alone, macOS 26; so does a kext added with no bounds of
/// its own.
pub const KEXT_MIN_KERNEL: &str = "25.0.0"; pub const KEXT_MIN_KERNEL: &str = "25.0.0";
pub const KEXT_MAX_KERNEL: &str = "25.99.99"; pub const KEXT_MAX_KERNEL: &str = "25.99.99";
@@ -90,12 +71,9 @@ pub struct Options {
pub graphical_picker: bool, pub graphical_picker: bool,
/// The picker at every boot, or none: OpenCore boots the default entry. /// The picker at every boot, or none: OpenCore boots the default entry.
pub show_picker: bool, pub show_picker: bool,
/// Lilu, for macOS 26.
pub kexts: bool,
} }
/// The config.plist for `o`, from the release's `sample`. `added` (added.rs) loads after Lilu, or /// The config.plist for `o`, from the release's `sample`, loading the kexts `added` (added.rs).
/// alone when `o.kexts` leaves Lilu out.
pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>> { pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>> {
let mut root: Value = plist::from_bytes(sample).context("read Sample.plist")?; let mut root: Value = plist::from_bytes(sample).context("read Sample.plist")?;
let c = root let c = root
@@ -140,7 +118,7 @@ pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>
Value::Dictionary(Dictionary::new()), Value::Dictionary(Dictionary::new()),
)?; )?;
let kexts = kernel_add(&template(c, &["Kernel", "Add"])?, o.kexts, added); let kexts = kernel_add(&template(c, &["Kernel", "Add"])?, added);
set(c, &["Kernel"], "Add", Value::Array(kexts))?; set(c, &["Kernel"], "Add", Value::Array(kexts))?;
set(c, &["Kernel"], "Block", Value::Array(vec![]))?; set(c, &["Kernel"], "Block", Value::Array(vec![]))?;
set(c, &["Kernel"], "Force", Value::Array(vec![]))?; set(c, &["Kernel"], "Force", Value::Array(vec![]))?;
@@ -302,40 +280,22 @@ pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>
Ok(out) Ok(out)
} }
/// Kernel > Add's entries, made from the sample's first: with `own`, Lilu for macOS 26, then /// Kernel > Add's entries, made from the sample's first: `added`, in its order, on the Darwin
/// `added`, in its order, on the Darwin versions each was given. /// versions each was given.
fn kernel_add(template: &Dictionary, own: bool, added: &[added::Kext]) -> Vec<Value> { fn kernel_add(template: &Dictionary, added: &[added::Kext]) -> Vec<Value> {
let mut add = Vec::new(); added
if own { .iter()
add.push(( .map(|k| {
LILU.bundle,
Some(LILU.executable),
KEXT_MIN_KERNEL,
KEXT_MAX_KERNEL,
"Patch engine",
));
}
for k in added {
add.push((
&k.bundle,
k.executable.as_deref(),
&k.min_kernel,
&k.max_kernel,
&k.identifier,
));
}
add.into_iter()
.map(|(bundle, executable, min_kernel, max_kernel, comment)| {
let mut e = template.clone(); let mut e = template.clone();
e.insert("Arch".into(), "x86_64".into()); e.insert("Arch".into(), "x86_64".into());
e.insert("BundlePath".into(), bundle.into()); e.insert("BundlePath".into(), k.bundle.as_str().into());
e.insert("Comment".into(), comment.into()); e.insert("Comment".into(), k.identifier.as_str().into());
e.insert("Enabled".into(), true.into()); e.insert("Enabled".into(), true.into());
// A kext with no code has an empty path. // A kext with no code has an empty path.
let path = executable.map(|x| format!("Contents/MacOS/{x}")); let path = k.executable.as_ref().map(|x| format!("Contents/MacOS/{x}"));
e.insert("ExecutablePath".into(), path.unwrap_or_default().into()); e.insert("ExecutablePath".into(), path.unwrap_or_default().into());
e.insert("MaxKernel".into(), max_kernel.into()); e.insert("MaxKernel".into(), k.max_kernel.as_str().into());
e.insert("MinKernel".into(), min_kernel.into()); e.insert("MinKernel".into(), k.min_kernel.as_str().into());
e.insert("PlistPath".into(), "Contents/Info.plist".into()); e.insert("PlistPath".into(), "Contents/Info.plist".into());
Value::Dictionary(e) Value::Dictionary(e)
}) })
@@ -412,7 +372,7 @@ mod tests {
#[test] #[test]
fn kernel_add_entries() { fn kernel_add_entries() {
let mut template = Dictionary::new(); let mut template = Dictionary::new();
template.insert("BundlePath".into(), "Lilu.kext".into()); template.insert("BundlePath".into(), "Sample.kext".into());
template.insert("Enabled".into(), false.into()); template.insert("Enabled".into(), false.into());
let keys = [ let keys = [
"BundlePath", "BundlePath",
@@ -425,8 +385,8 @@ mod tests {
let want = |b: &str, x: &str, min: &str, max: &str| { let want = |b: &str, x: &str, min: &str, max: &str| {
[b, x, "Contents/Info.plist", min, max, "x86_64"].map(str::to_string) [b, x, "Contents/Info.plist", min, max, "x86_64"].map(str::to_string)
}; };
let entries = |own: bool, added: &[added::Kext]| -> Vec<[String; 6]> { let entries = |added: &[added::Kext]| -> Vec<[String; 6]> {
kernel_add(&template, own, added) kernel_add(&template, added)
.iter() .iter()
.map(|e| { .map(|e| {
assert_eq!(e.as_dictionary().unwrap()["Enabled"], Value::Boolean(true)); assert_eq!(e.as_dictionary().unwrap()["Enabled"], Value::Boolean(true));
@@ -434,24 +394,16 @@ mod tests {
}) })
.collect() .collect()
}; };
let lilu = want( // No kexts, no entries: the sample's own go.
"Lilu.kext", assert!(entries(&[]).is_empty());
"Contents/MacOS/Lilu",
KEXT_MIN_KERNEL,
KEXT_MAX_KERNEL,
);
// Lilu alone, or nothing. // Added kexts, in their order, on their own bounds; one with no code has no path.
assert_eq!(entries(true, &[]), std::slice::from_ref(&lilu));
assert!(entries(false, &[]).is_empty());
// Added kexts follow, in their order, on their own bounds; one with no code has no path.
let set = [ let set = [
added("Loader", Some("Loader"), "25.4.0", "25.99.99"), added("Loader", Some("Loader"), "25.4.0", "25.99.99"),
added("Shim", None, "25.4.0", "25.6.0"), added("Shim", None, "25.4.0", "25.6.0"),
added("Gfx", Some("ReimsGraphics"), "25.0.0", "25.99.99"), added("Gfx", Some("ReimsGraphics"), "25.0.0", "25.99.99"),
]; ];
let tail = [ let want_set = [
want("Loader.kext", "Contents/MacOS/Loader", "25.4.0", "25.99.99"), want("Loader.kext", "Contents/MacOS/Loader", "25.4.0", "25.99.99"),
want("Shim.kext", "", "25.4.0", "25.6.0"), want("Shim.kext", "", "25.4.0", "25.6.0"),
want( want(
@@ -461,11 +413,8 @@ mod tests {
"25.99.99", "25.99.99",
), ),
]; ];
let mut all = vec![lilu]; assert_eq!(entries(&set), want_set);
all.extend(tail.clone()); let e = &kernel_add(&template, &set)[0];
assert_eq!(entries(true, &set), all);
assert_eq!(entries(false, &set), tail);
let e = &kernel_add(&template, true, &set)[1];
assert_eq!(fields(e, &["Comment"]), ["t.Loader"]); assert_eq!(fields(e, &["Comment"]), ["t.Loader"]);
} }
} }
+5 -47
View File
@@ -1,8 +1,8 @@
//! The OpenCore boot image: a 128 MiB GPT disk whose EFI system partition holds a pinned //! The OpenCore boot image: a 128 MiB GPT disk whose EFI system partition holds a pinned
//! OpenCore release, the drivers and ACPI table a VM needs, the picker's icons and the boot chime //! OpenCore release, the drivers and ACPI table a VM needs, the picker's icons and the boot chime
//! from a pinned commit of OcBinaryData, a pinned Lilu release, the kexts given with `--add-kext` //! from a pinned commit of OcBinaryData, the kexts given with `--add-kext` (added.rs), and a
//! (added.rs), and a `config.plist` made for a q35 VM (config.rs) with an SMBIOS identity of its //! `config.plist` made for a q35 VM (config.rs) with an SMBIOS identity of its own (smbios.rs).
//! own (smbios.rs). OVMF goes beside it (ovmf.rs), where reims-ctl looks for it. //! OVMF goes beside it (ovmf.rs), where reims-ctl looks for it.
pub mod acpi; pub mod acpi;
pub mod added; pub mod added;
@@ -39,15 +39,6 @@ const RESOURCES_ROOT: &str = "OcBinaryData-32500d5e3313f11cad00351ba1c6f9a4aa6cb
/// The boot chime, the image's only sound. /// The boot chime, the image's only sound.
const CHIME: &str = "Audio/OCEFIAudio_VoiceOver_Boot.mp3"; const CHIME: &str = "Audio/OCEFIAudio_VoiceOver_Boot.mp3";
/// Lilu, which kexts given with `--add-kext` may link against: reims-vgpu's guest kexts link
/// against 1.7.2.
const LILU_RELEASE: Pinned = Pinned {
name: "Lilu-1.7.2-RELEASE.zip",
url: "https://github.com/acidanthera/Lilu/releases/download/1.7.2/Lilu-1.7.2-RELEASE.zip",
sha256: "53967d7dcfaab01023a33df2e969a89522f13d6654a6a56ac4711b62dabf3ab8",
what: "Lilu 1.7.2",
};
/// The image's size: room for OpenCore (about 2 MiB of it here) and for what a person may add. /// The image's size: room for OpenCore (about 2 MiB of it here) and for what a person may add.
const DISK_SIZE: u64 = 128 << 20; const DISK_SIZE: u64 = 128 << 20;
@@ -55,7 +46,7 @@ const DISK_SIZE: u64 = 128 << 20;
pub struct Options { pub struct Options {
pub output: PathBuf, pub output: PathBuf,
pub config: config::Options, pub config: config::Options,
/// Kexts to load after Lilu, in this order. /// Kexts to load, in this order.
pub add_kexts: Vec<added::Spec>, pub add_kexts: Vec<added::Spec>,
/// Where OVMF's files go, or None to write none. /// Where OVMF's files go, or None to write none.
pub ovmf_dir: Option<PathBuf>, pub ovmf_dir: Option<PathBuf>,
@@ -79,26 +70,15 @@ pub fn build(o: &Options, r: &dyn Reporter) -> Result<Outputs> {
.iter() .iter()
.map(added::read) .map(added::read)
.collect::<Result<Vec<_>>>()?; .collect::<Result<Vec<_>>>()?;
added::check(&config::OWN, o.config.kexts, &added)?; added::check(&added)?;
let zip_path = cache::fetch(&RELEASE, r)?; let zip_path = cache::fetch(&RELEASE, r)?;
progress::check(r)?; progress::check(r)?;
let resources_path = cache::fetch(&RESOURCES, r)?; let resources_path = cache::fetch(&RESOURCES, r)?;
progress::check(r)?; progress::check(r)?;
let lilu_path = if o.config.kexts {
let p = cache::fetch(&LILU_RELEASE, r)?;
progress::check(r)?;
Some(p)
} else {
None
};
r.step(&format!("Building the OpenCore {VERSION} image")); r.step(&format!("Building the OpenCore {VERSION} image"));
let mut files = files(&zip_path, &o.config, &added)?; let mut files = files(&zip_path, &o.config, &added)?;
files.extend(resources(&resources_path, o.config.graphical_picker)?); files.extend(resources(&resources_path, o.config.graphical_picker)?);
let mut kext_names = Vec::new(); let mut kext_names = Vec::new();
if let Some(p) = &lilu_path {
files.extend(kexts(p)?);
kext_names.extend(config::OWN.iter().map(|k| k.bundle.to_string()));
}
for k in added { for k in added {
for (p, d) in k.files { for (p, d) in k.files {
files.push((format!("EFI/OC/Kexts/{}/{p}", k.bundle), d)); files.push((format!("EFI/OC/Kexts/{}/{p}", k.bundle), d));
@@ -186,28 +166,6 @@ fn files(
Ok(files) Ok(files)
} }
/// Lilu's files, from its release.
fn kexts(lilu_zip: &Path) -> Result<Vec<(String, Vec<u8>)>> {
use config::LILU;
let f =
std::fs::File::open(lilu_zip).with_context(|| format!("open {}", lilu_zip.display()))?;
let mut zip = zip::ZipArchive::new(f).context("read Lilu's release")?;
let mut files = Vec::new();
for p in [
"Contents/Info.plist".to_string(),
format!("Contents/MacOS/{}", LILU.executable),
] {
let name = format!("{}/{p}", LILU.bundle);
let mut e = zip
.by_name(&name)
.with_context(|| format!("Lilu's release has no {name}"))?;
let mut v = Vec::new();
e.read_to_end(&mut v)?;
files.push((format!("EFI/OC/Kexts/{name}"), v));
}
Ok(files)
}
/// The resources the image carries, from OcBinaryData's archive. /// The resources the image carries, from OcBinaryData's archive.
fn resources(zip_path: &Path, graphical: bool) -> Result<Vec<(String, Vec<u8>)>> { fn resources(zip_path: &Path, graphical: bool) -> Result<Vec<(String, Vec<u8>)>> {
let f = let f =
-1
View File
@@ -272,7 +272,6 @@ impl App {
show_vm: !form.toggle(5), show_vm: !form.toggle(5),
text_picker: !form.toggle(7), text_picker: !form.toggle(7),
show_picker: form.toggle(8), show_picker: form.toggle(8),
no_kexts: false,
add_kext: Vec::new(), add_kext: Vec::new(),
_retired: 0, _retired: 0,
no_ovmf: !form.toggle(3), no_ovmf: !form.toggle(3),