🔥 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:
1 parent
0b9c3780a3
commit
c8cd41aba8
8 files changed
+66
-229
No files matched your search
@@ -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:
|
||||
LICENSES/BSD-3-Clause-OpenCorePkg.txt.
|
||||
|
||||
What reims-util downloads and writes into images, such as OpenCore, Lilu and
|
||||
OVMF, is not part of the repository, and keeps its own license; OVMF's
|
||||
licenses are written beside OVMF_CODE.fd. The crates the build takes from crates.io keep
|
||||
What reims-util downloads and writes into images, such as OpenCore and OVMF,
|
||||
is not part of the repository, and keeps its own license; OVMF's licenses are
|
||||
written beside OVMF_CODE.fd. The crates the build takes from crates.io keep
|
||||
their own licenses too.
|
||||
@@ -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`
|
||||
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
|
||||
(OpenCore's release, a commit of its picker icons and boot chime, OcBinaryData, and Lilu's
|
||||
release, from GitHub; OVMF from Arch Linux's `edk2-ovmf` package), checked against the hashes
|
||||
reims-util knows, and cached in `~/.cache/reims-util`, so it's only downloaded once.
|
||||
(OpenCore's release and a commit of its picker icons and boot chime, OcBinaryData, from GitHub;
|
||||
OVMF from Arch Linux's `edk2-ovmf` package), checked against the hashes reims-util knows, and
|
||||
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
|
||||
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:
|
||||
|
||||
- **Lilu, which loads on macOS 26 alone**: kexts you add with `--add-kext` load after it
|
||||
([below](#adding-kexts)), and can link against it, as reims-vgpu's guest kexts do.
|
||||
`--no-kexts` leaves it out. There are no other kexts: QEMU's `isa-applesmc` is the SMC.
|
||||
- **Only the kexts you add** with `--add-kext` ([below](#adding-kexts)), such as reims-vgpu's
|
||||
guest kexts. There are no others: QEMU's `isa-applesmc` is the SMC.
|
||||
- **The drivers a VM boots with**: OpenRuntime, OpenHfsPlus (recovery images and installers are
|
||||
HFS+), OpenPartitionDxe (for older recovery images) and ResetNvramEntry.
|
||||
- **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
|
||||
|
||||
`--add-kext` puts a kext bundle of your own in the image, after Lilu. Repeat it for more: they
|
||||
load in the order you give them, so give a kext after the ones it links against.
|
||||
`--add-kext` puts a kext bundle of your own in the image. Repeat it for more: they load in the
|
||||
order you give them, so give a kext after the ones it links against.
|
||||
|
||||
```sh
|
||||
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
|
||||
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
|
||||
OpenCore loads the executable its Info.plist names, or none for a kext with no code. reims-util
|
||||
refuses a kext with the name or bundle identifier of one already in the image (the image's FAT32
|
||||
partition doesn't tell names apart by case), and one that links against a kext given after it, or
|
||||
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.
|
||||
macOS 26. The bundle is copied whole into `EFI/OC/Kexts`, without its dotfiles, and OpenCore loads
|
||||
the executable its Info.plist names, or none for a kext with no code. reims-util refuses a kext
|
||||
with the name or bundle identifier of one given before it (the image's FAT32 partition doesn't
|
||||
tell names apart by case), and one that links against a kext given after it.
|
||||
|
||||
### 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
|
||||
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,
|
||||
keep their own licenses.
|
||||
OpenCore, its picker icons and chime (OcBinaryData), and OVMF, which reims-util downloads, keep
|
||||
their own licenses.
|
||||
+1
-1
@@ -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`).
|
||||
|
||||
use crate::http::{self, Dest, Download, NoCheck};
|
||||
|
||||
+2
-7
@@ -108,12 +108,8 @@ pub struct OpencoreArgs {
|
||||
/// Show OpenCore's boot picker at every boot (by default OpenCore boots the default entry)
|
||||
#[arg(long)]
|
||||
pub show_picker: bool,
|
||||
/// Leave out Lilu: the image carries only the kexts given with --add-kext, such as a Lilu of
|
||||
/// your own, or none
|
||||
#[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
|
||||
/// Add a kext bundle, loaded 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)]
|
||||
pub add_kext: Vec<added::Spec>,
|
||||
/// 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,
|
||||
graphical_picker: !a.text_picker,
|
||||
show_picker: a.show_picker,
|
||||
kexts: !a.no_kexts,
|
||||
},
|
||||
add_kexts: a.add_kext.clone(),
|
||||
ovmf_dir,
|
||||
|
||||
+17
-78
@@ -1,5 +1,5 @@
|
||||
//! Kexts given with `--add-kext`, which the image carries after its own, Lilu, in the order given:
|
||||
//! reims-vgpu's guest kexts for its own GPU device, for one. Each is a bundle on disk, copied
|
||||
//! Kexts given with `--add-kext`, which the image carries in the order given: reims-vgpu's guest
|
||||
//! 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
|
||||
//! 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
|
||||
/// 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.
|
||||
/// the path; MIN and MAX are versions as OpenCore takes them (25.4.0), each 25.0.0 and 25.99.99
|
||||
/// (macOS 26) when left out or empty.
|
||||
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 mut path = s;
|
||||
@@ -174,29 +174,13 @@ fn walk(root: &Path, rel: &Path, files: &mut Vec<(String, Vec<u8>)>) -> Result<(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Refuses `added` where it would clash with the image's own kexts, `own` (in the image when
|
||||
/// `own_in`), or with each other: a bundle name FAT32 can't tell from another's (it ignores
|
||||
/// case), an identifier already loaded, or a library of the image's that does not load before it.
|
||||
pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> {
|
||||
let present: &[config::Kext] = if own_in { own } else { &[] };
|
||||
/// Refuses `added` where its kexts would clash with each other: a bundle name FAT32 can't tell
|
||||
/// from another's (it ignores case), an identifier given twice, or a kext given before one it
|
||||
/// links against.
|
||||
pub fn check(added: &[Kext]) -> Result<()> {
|
||||
for (i, k) in added.iter().enumerate() {
|
||||
let earlier = &added[..i];
|
||||
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 e.bundle == 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);
|
||||
}
|
||||
for l in &k.libraries {
|
||||
let before = *l == k.identifier
|
||||
|| present.iter().any(|o| o.identifier == *l)
|
||||
|| earlier.iter().any(|e| e.identifier == *l);
|
||||
if before {
|
||||
if *l == k.identifier || earlier.iter().any(|e| e.identifier == *l) {
|
||||
continue;
|
||||
}
|
||||
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
|
||||
);
|
||||
}
|
||||
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(())
|
||||
@@ -240,7 +214,6 @@ pub fn check(own: &[config::Kext], own_in: bool, added: &[Kext]) -> Result<()> {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::opencore::config::LILU;
|
||||
|
||||
fn spec(path: &str, min: &str, max: &str) -> Spec {
|
||||
Spec {
|
||||
@@ -357,7 +330,7 @@ pub(crate) mod tests {
|
||||
|
||||
#[test]
|
||||
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(
|
||||
"Loader.kext",
|
||||
&[
|
||||
@@ -373,7 +346,7 @@ pub(crate) mod tests {
|
||||
assert_eq!(k.bundle, "Loader.kext");
|
||||
assert_eq!(k.identifier, "t.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!(
|
||||
(k.min_kernel.as_str(), k.max_kernel.as_str()),
|
||||
("25.4.0", config::KEXT_MAX_KERNEL)
|
||||
@@ -431,68 +404,34 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checked_against_the_image() {
|
||||
let own = [LILU];
|
||||
fn checked() {
|
||||
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("Gfx.kext", "t.gfx", &["t.shim", "t.loader", "t.gfx"]),
|
||||
];
|
||||
check(&own, true, &ok).unwrap();
|
||||
check(&own, true, &[]).unwrap();
|
||||
check(&own, false, &[]).unwrap();
|
||||
check(&ok).unwrap();
|
||||
check(&[]).unwrap();
|
||||
|
||||
let refused = |own_in: bool, added: &[Kext], says: &str| {
|
||||
let e = check(&own, own_in, added).unwrap_err().to_string();
|
||||
let refused = |added: &[Kext], says: &str| {
|
||||
let e = check(added).unwrap_err().to_string();
|
||||
assert!(e.contains(says), "{says}: {e}");
|
||||
};
|
||||
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", &[])],
|
||||
"A.kext is given twice",
|
||||
);
|
||||
refused(
|
||||
true,
|
||||
&[kext("A.kext", "t.a", &[]), kext("a.kext", "t.b", &[])],
|
||||
"A.kext and a.kext are one name",
|
||||
);
|
||||
refused(
|
||||
true,
|
||||
&[kext("A.kext", "t.a", &[]), kext("B.kext", "t.a", &[])],
|
||||
"A.kext and B.kext are both t.a",
|
||||
);
|
||||
refused(
|
||||
true,
|
||||
&[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",
|
||||
);
|
||||
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
@@ -11,9 +11,8 @@
|
||||
//! picker, when asked for);
|
||||
//! - 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`);
|
||||
//! - on macOS 26, one kext, Lilu, which kexts given with `--add-kext` may link against; after it,
|
||||
//! those kexts (added.rs), in their order and on the Darwin versions given; no others, as QEMU's
|
||||
//! `isa-applesmc` is the SMC;
|
||||
//! - the kexts given with `--add-kext` (added.rs), in their order and on the Darwin versions
|
||||
//! given; no others, as QEMU's `isa-applesmc` is the SMC;
|
||||
//! - 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
|
||||
//! 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
|
||||
}
|
||||
|
||||
/// A kext of reims-util's own in `EFI/OC/Kexts`: its bundle, its `CFBundleIdentifier`, and the
|
||||
/// 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.
|
||||
/// A kext added with no bounds of its own loads on Darwin 25 alone, macOS 26.
|
||||
pub const KEXT_MIN_KERNEL: &str = "25.0.0";
|
||||
pub const KEXT_MAX_KERNEL: &str = "25.99.99";
|
||||
|
||||
@@ -90,12 +71,9 @@ pub struct Options {
|
||||
pub graphical_picker: bool,
|
||||
/// The picker at every boot, or none: OpenCore boots the default entry.
|
||||
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
|
||||
/// alone when `o.kexts` leaves Lilu out.
|
||||
/// The config.plist for `o`, from the release's `sample`, loading the kexts `added` (added.rs).
|
||||
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 c = root
|
||||
@@ -140,7 +118,7 @@ pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>
|
||||
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"], "Block", 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)
|
||||
}
|
||||
|
||||
/// Kernel > Add's entries, made from the sample's first: with `own`, Lilu for macOS 26, then
|
||||
/// `added`, in its order, on the Darwin versions each was given.
|
||||
fn kernel_add(template: &Dictionary, own: bool, added: &[added::Kext]) -> Vec<Value> {
|
||||
let mut add = Vec::new();
|
||||
if own {
|
||||
add.push((
|
||||
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)| {
|
||||
/// Kernel > Add's entries, made from the sample's first: `added`, in its order, on the Darwin
|
||||
/// versions each was given.
|
||||
fn kernel_add(template: &Dictionary, added: &[added::Kext]) -> Vec<Value> {
|
||||
added
|
||||
.iter()
|
||||
.map(|k| {
|
||||
let mut e = template.clone();
|
||||
e.insert("Arch".into(), "x86_64".into());
|
||||
e.insert("BundlePath".into(), bundle.into());
|
||||
e.insert("Comment".into(), comment.into());
|
||||
e.insert("BundlePath".into(), k.bundle.as_str().into());
|
||||
e.insert("Comment".into(), k.identifier.as_str().into());
|
||||
e.insert("Enabled".into(), true.into());
|
||||
// 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("MaxKernel".into(), max_kernel.into());
|
||||
e.insert("MinKernel".into(), min_kernel.into());
|
||||
e.insert("MaxKernel".into(), k.max_kernel.as_str().into());
|
||||
e.insert("MinKernel".into(), k.min_kernel.as_str().into());
|
||||
e.insert("PlistPath".into(), "Contents/Info.plist".into());
|
||||
Value::Dictionary(e)
|
||||
})
|
||||
@@ -412,7 +372,7 @@ mod tests {
|
||||
#[test]
|
||||
fn kernel_add_entries() {
|
||||
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());
|
||||
let keys = [
|
||||
"BundlePath",
|
||||
@@ -425,8 +385,8 @@ mod tests {
|
||||
let want = |b: &str, x: &str, min: &str, max: &str| {
|
||||
[b, x, "Contents/Info.plist", min, max, "x86_64"].map(str::to_string)
|
||||
};
|
||||
let entries = |own: bool, added: &[added::Kext]| -> Vec<[String; 6]> {
|
||||
kernel_add(&template, own, added)
|
||||
let entries = |added: &[added::Kext]| -> Vec<[String; 6]> {
|
||||
kernel_add(&template, added)
|
||||
.iter()
|
||||
.map(|e| {
|
||||
assert_eq!(e.as_dictionary().unwrap()["Enabled"], Value::Boolean(true));
|
||||
@@ -434,24 +394,16 @@ mod tests {
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let lilu = want(
|
||||
"Lilu.kext",
|
||||
"Contents/MacOS/Lilu",
|
||||
KEXT_MIN_KERNEL,
|
||||
KEXT_MAX_KERNEL,
|
||||
);
|
||||
// No kexts, no entries: the sample's own go.
|
||||
assert!(entries(&[]).is_empty());
|
||||
|
||||
// Lilu alone, or nothing.
|
||||
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.
|
||||
// Added kexts, in their order, on their own bounds; one with no code has no path.
|
||||
let set = [
|
||||
added("Loader", Some("Loader"), "25.4.0", "25.99.99"),
|
||||
added("Shim", None, "25.4.0", "25.6.0"),
|
||||
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("Shim.kext", "", "25.4.0", "25.6.0"),
|
||||
want(
|
||||
@@ -461,11 +413,8 @@ mod tests {
|
||||
"25.99.99",
|
||||
),
|
||||
];
|
||||
let mut all = vec![lilu];
|
||||
all.extend(tail.clone());
|
||||
assert_eq!(entries(true, &set), all);
|
||||
assert_eq!(entries(false, &set), tail);
|
||||
let e = &kernel_add(&template, true, &set)[1];
|
||||
assert_eq!(entries(&set), want_set);
|
||||
let e = &kernel_add(&template, &set)[0];
|
||||
assert_eq!(fields(e, &["Comment"]), ["t.Loader"]);
|
||||
}
|
||||
}
|
||||
+5
-47
@@ -1,8 +1,8 @@
|
||||
//! 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
|
||||
//! from a pinned commit of OcBinaryData, a pinned Lilu release, the kexts given with `--add-kext`
|
||||
//! (added.rs), and a `config.plist` made for a q35 VM (config.rs) with an SMBIOS identity of its
|
||||
//! own (smbios.rs). OVMF goes beside it (ovmf.rs), where reims-ctl looks for it.
|
||||
//! from a pinned commit of OcBinaryData, the kexts given with `--add-kext` (added.rs), and a
|
||||
//! `config.plist` made for a q35 VM (config.rs) with an SMBIOS identity of its own (smbios.rs).
|
||||
//! OVMF goes beside it (ovmf.rs), where reims-ctl looks for it.
|
||||
|
||||
pub mod acpi;
|
||||
pub mod added;
|
||||
@@ -39,15 +39,6 @@ const RESOURCES_ROOT: &str = "OcBinaryData-32500d5e3313f11cad00351ba1c6f9a4aa6cb
|
||||
/// The boot chime, the image's only sound.
|
||||
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.
|
||||
const DISK_SIZE: u64 = 128 << 20;
|
||||
|
||||
@@ -55,7 +46,7 @@ const DISK_SIZE: u64 = 128 << 20;
|
||||
pub struct Options {
|
||||
pub output: PathBuf,
|
||||
pub config: config::Options,
|
||||
/// Kexts to load after Lilu, in this order.
|
||||
/// Kexts to load, in this order.
|
||||
pub add_kexts: Vec<added::Spec>,
|
||||
/// Where OVMF's files go, or None to write none.
|
||||
pub ovmf_dir: Option<PathBuf>,
|
||||
@@ -79,26 +70,15 @@ pub fn build(o: &Options, r: &dyn Reporter) -> Result<Outputs> {
|
||||
.iter()
|
||||
.map(added::read)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
added::check(&config::OWN, o.config.kexts, &added)?;
|
||||
added::check(&added)?;
|
||||
let zip_path = cache::fetch(&RELEASE, r)?;
|
||||
progress::check(r)?;
|
||||
let resources_path = cache::fetch(&RESOURCES, 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"));
|
||||
let mut files = files(&zip_path, &o.config, &added)?;
|
||||
files.extend(resources(&resources_path, o.config.graphical_picker)?);
|
||||
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 (p, d) in k.files {
|
||||
files.push((format!("EFI/OC/Kexts/{}/{p}", k.bundle), d));
|
||||
@@ -186,28 +166,6 @@ fn 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.
|
||||
fn resources(zip_path: &Path, graphical: bool) -> Result<Vec<(String, Vec<u8>)>> {
|
||||
let f =
|
||||
|
||||
@@ -272,7 +272,6 @@ impl App {
|
||||
show_vm: !form.toggle(5),
|
||||
text_picker: !form.toggle(7),
|
||||
show_picker: form.toggle(8),
|
||||
no_kexts: false,
|
||||
add_kext: Vec::new(),
|
||||
_retired: 0,
|
||||
no_ovmf: !form.toggle(3),
|
||||
|
||||
Reference in new issue
Block a user