Author SHA1 Message Date
Xiaochi You 8e81d554a1 Merge pull request #1 from yxc0915/steelbrain/preserve-opencore-preboot-input
Preserve FileVault input in rebuilt OpenCore images
2026-12-04 16:45:28 +08:00
YXC0915 c363a029b1 🐛 Preserve preboot input in rebuilt OpenCore images 2026-12-04 16:43:58 +08:00
YXC0915 573d4a5ffa 🐎 Download chunk-checked offline installers in parallel 2026-12-03 02:47:51 +08:00
8 changed files with 512 additions and 82 deletions

No files matched your search

+5 -1
View File
@@ -43,7 +43,7 @@ pub struct Cli {
pub enum Command {
/// Make an OpenCore boot image, and write OVMF beside it
#[command(after_help = OPENCORE_HELP)]
Opencore(OpencoreArgs),
Opencore(Box<OpencoreArgs>),
/// Make an online installer: Apple's recovery image, which installs the newest release of
/// its macOS (10.13 to 26) over the network
#[command(after_help = ONLINE_HELP)]
@@ -112,6 +112,9 @@ pub struct OpencoreArgs {
/// 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>,
/// Carry the saved OpenCore preboot input settings and EFI drivers from DIR
#[arg(long, value_name = "DIR")]
pub preboot_input: Option<PathBuf>,
/// Accepted and ignored: --no-apv-arm64-port and --no-video, whose kexts images no longer
/// carry
#[arg(
@@ -359,6 +362,7 @@ pub fn opencore_options(a: &OpencoreArgs) -> Result<opencore::Options> {
show_picker: a.show_picker,
},
add_kexts: a.add_kext.clone(),
preboot_input: a.preboot_input.clone(),
ovmf_dir,
})
}
+346 -77
View File
@@ -13,13 +13,15 @@
use crate::progress::{self, Reporter};
use anyhow::{Context, Result, bail};
use std::fs::{File, OpenOptions};
use std::io::{Read, Seek, SeekFrom, Write};
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use std::thread;
use std::time::Duration;
use ureq::Agent;
/// The most each request asks for.
pub const SEGMENT: u64 = 64 << 20;
const PARALLEL_REQUESTS: usize = 4;
/// How long a request may take to send its range: a stall is noticed within this. (On a
/// connection too slow to send a whole range in it, each request sends what it can.)
pub const SEGMENT_BUDGET: Duration = Duration::from_secs(180);
@@ -124,6 +126,8 @@ pub struct Download<'a> {
/// For requests the server refuses (401, 403): new headers, such as a fresh asset token.
pub refresh: Option<&'a mut dyn FnMut() -> Result<Headers>>,
pub user_agent: Option<&'static str>,
/// Fetch the public installer package in parallel within each checked segment.
pub parallel: bool,
/// Failed requests in a row, with no byte received between them, before it gives up:
/// [`MAX_FAILURES`], or fewer when there is another place to download the file from.
pub tries: u32,
@@ -138,6 +142,7 @@ impl Download<'_> {
size: None,
refresh: None,
user_agent: None,
parallel: false,
tries: MAX_FAILURES,
}
}
@@ -229,6 +234,8 @@ pub fn download(
let mut failures = 0u32;
let mut bad_chunks = 0u32;
let mut buf = vec![0u8; 1 << 18];
let mut parallel =
d.parallel && check.verifies() && d.headers.is_empty() && d.user_agent.is_none();
r.progress(have, total);
'requests: loop {
@@ -240,94 +247,116 @@ pub fn download(
Some(t) => (have + SEGMENT).min(t) - 1,
None => have + SEGMENT - 1,
};
let mut req = agent
.get(&d.url)
.header("Range", format!("bytes={have}-{end}"));
for (k, v) in &d.headers {
req = req.header(k, v);
}
let mut cfg = req.config().timeout_recv_body(Some(SEGMENT_BUDGET));
if let Some(ua) = d.user_agent {
cfg = cfg.user_agent(ua);
}
let resp = match cfg.build().call() {
Ok(resp) => resp,
Err(e) => {
failures += 1;
retry_or_fail(&mut failures, d.tries, &format!("{e}"), &d.url, r)?;
continue;
// Keep one segment in memory and commit it through the same ordered
// writer and chunk checker used by serial downloads.
let batch = if parallel
&& let Some(size) = total
&& end - have >= (PARALLEL_REQUESTS - 1) as u64
{
match read_parallel_segment(agent, &d.url, have, end, size, r) {
Ok(bytes) => Some(bytes),
Err(_) => {
progress::check(r)?;
parallel = false;
r.note("Parallel ranges could not be read. Continuing with one connection.");
None
}
}
} else {
None
};
let status = resp.status().as_u16();
match status {
206 => {
let range = resp
.headers()
.get("content-range")
.and_then(|v| v.to_str().ok())
.and_then(content_range)
.with_context(|| format!("{} sent a range without Content-Range", d.url))?;
if range.0 != have {
bail!(
"{} sent bytes from {} when asked for {have}",
d.url,
range.0
);
}
match (total, range.1) {
(Some(t), Some(rt)) if t != rt => bail!(
"{} is {} long, not the expected {}: it changed on the server",
d.url,
rt,
t
),
(None, Some(rt)) => {
total = Some(rt);
r.progress(have, total);
}
_ => {}
}
let mut body: Box<dyn Read> = if let Some(bytes) = batch {
Box::new(Cursor::new(bytes))
} else {
let mut req = agent
.get(&d.url)
.header("Range", format!("bytes={have}-{end}"));
for (k, v) in &d.headers {
req = req.header(k, v);
}
200 => {
// The whole file: the server ignored the range.
if have > 0 {
let mut cfg = req.config().timeout_recv_body(Some(SEGMENT_BUDGET));
if let Some(ua) = d.user_agent {
cfg = cfg.user_agent(ua);
}
let resp = match cfg.build().call() {
Ok(resp) => resp,
Err(e) => {
failures += 1;
retry_or_fail(&mut failures, d.tries, &format!("{e}"), &d.url, r)?;
continue;
}
};
let status = resp.status().as_u16();
match status {
206 => {
let range = resp
.headers()
.get("content-range")
.and_then(|v| v.to_str().ok())
.and_then(content_range)
.with_context(|| format!("{} sent a range without Content-Range", d.url))?;
if range.0 != have {
bail!(
"{} sent bytes from {} when asked for {have}",
d.url,
range.0
);
}
match (total, range.1) {
(Some(t), Some(rt)) if t != rt => bail!(
"{} is {} long, not the expected {}: it changed on the server",
d.url,
rt,
t
),
(None, Some(rt)) => {
total = Some(rt);
r.progress(have, total);
}
_ => {}
}
}
200 => {
// The whole file: the server ignored the range.
if have > 0 {
cut(file, 0)?;
have = 0;
check.restart_at(0);
}
if total.is_none() {
total = resp.body().content_length();
}
}
416 if total.is_some_and(|t| have >= t) => break,
416 => {
// Past the end: the file on the server is shorter than what we have.
if have == 0 {
bail!("{} refused every range", d.url);
}
r.note("The file changed on the server: starting over");
cut(file, 0)?;
have = 0;
check.restart_at(0);
continue;
}
if total.is_none() {
total = resp.body().content_length();
401 | 403 if d.refresh.is_some() && failures < 3 => {
failures += 1;
if let Some(f) = d.refresh.as_mut() {
d.headers = f()?;
}
continue;
}
}
416 if total.is_some_and(|t| have >= t) => break,
416 => {
// Past the end: the file on the server is shorter than what we have.
if have == 0 {
bail!("{} refused every range", d.url);
408 | 429 | 500..=599 => {
failures += 1;
retry_or_fail(&mut failures, d.tries, &format!("HTTP {status}"), &d.url, r)?;
continue;
}
r.note("The file changed on the server: starting over");
cut(file, 0)?;
have = 0;
check.restart_at(0);
continue;
_ => bail!("{} answered HTTP {status}", d.url),
}
401 | 403 if d.refresh.is_some() && failures < 3 => {
failures += 1;
if let Some(f) = d.refresh.as_mut() {
d.headers = f()?;
}
continue;
}
408 | 429 | 500..=599 => {
failures += 1;
retry_or_fail(&mut failures, d.tries, &format!("HTTP {status}"), &d.url, r)?;
continue;
}
_ => bail!("{} answered HTTP {status}", d.url),
}
Box::new(resp.into_body().into_reader())
};
file.seek(SeekFrom::Start(base + have))?;
let mut body = resp.into_body().into_reader();
let start = have;
loop {
if r.cancelled() {
@@ -389,6 +418,79 @@ pub fn download(
Ok(())
}
fn read_parallel_segment(
agent: &Agent,
url: &str,
start: u64,
end: u64,
total: u64,
r: &dyn Reporter,
) -> Result<Vec<u8>> {
let mut segment = vec![0; (end - start + 1) as usize];
let request_size = segment.len().div_ceil(PARALLEL_REQUESTS);
thread::scope(|scope| -> Result<()> {
let mut requests = Vec::with_capacity(PARALLEL_REQUESTS);
for (index, chunk) in segment.chunks_mut(request_size).enumerate() {
let first = start + (index * request_size) as u64;
let request = thread::Builder::new().spawn_scoped(scope, move || {
read_exact_range(agent, url, first, total, chunk, r)
})?;
requests.push(request);
}
for request in requests {
request
.join()
.map_err(|_| anyhow::anyhow!("range worker failed"))??;
}
Ok(())
})?;
Ok(segment)
}
fn read_exact_range(
agent: &Agent,
url: &str,
start: u64,
total: u64,
mut remaining: &mut [u8],
r: &dyn Reporter,
) -> Result<()> {
let end = start + remaining.len() as u64 - 1;
progress::check(r)?;
let response = agent
.get(url)
.header("Range", format!("bytes={start}-{end}"))
.header("Accept-Encoding", "identity")
.config()
.timeout_recv_body(Some(SEGMENT_BUDGET))
.build()
.call()?;
let expected = format!("bytes {start}-{end}/{total}");
if response.status().as_u16() != 206
|| response
.headers()
.get("Content-Range")
.and_then(|value| value.to_str().ok())
!= Some(expected.as_str())
{
bail!("server did not return the requested byte range");
}
let mut body = response.into_body().into_reader();
while !remaining.is_empty() {
progress::check(r)?;
let n = body.read(remaining)?;
if n == 0 {
bail!("range body ended before its declared length");
}
remaining = &mut remaining[n..];
}
progress::check(r)?;
if body.read(&mut [0u8; 1])? != 0 {
bail!("range body exceeded its declared length");
}
Ok(())
}
fn retry_or_fail(
failures: &mut u32,
tries: u32,
@@ -455,6 +557,173 @@ pub fn hex(b: &[u8]) -> String {
#[cfg(test)]
mod tests {
use super::*;
use std::io::{BufRead, BufReader};
use std::net::{TcpListener, TcpStream};
struct Silent;
impl Reporter for Silent {
fn event(&self, _: progress::Event) {}
}
fn read_request(stream: &TcpStream) -> Result<String> {
stream.set_read_timeout(Some(Duration::from_secs(5)))?;
let mut reader = BufReader::new(stream);
let mut range = String::new();
loop {
let mut line = String::new();
if reader.read_line(&mut line)? == 0 || line == "\r\n" {
break;
}
if let Some((name, value)) = line.split_once(':')
&& name.eq_ignore_ascii_case("range")
{
range = value.trim().to_string();
}
}
Ok(range)
}
#[test]
fn sends_four_ranges_before_waiting_for_their_bodies() -> Result<()> {
let listener = TcpListener::bind("127.0.0.1:0")?;
listener.set_nonblocking(true)?;
let url = format!("http://{}", listener.local_addr()?);
let server = thread::spawn(move || -> Result<()> {
let deadline = std::time::Instant::now() + Duration::from_secs(5);
let mut requests = std::collections::BTreeMap::new();
while requests.len() < 4 {
match listener.accept() {
Ok((stream, _)) => {
let range = read_request(&stream)?;
requests.insert(range, stream);
}
Err(e)
if e.kind() == std::io::ErrorKind::WouldBlock
&& std::time::Instant::now() < deadline =>
{
thread::sleep(Duration::from_millis(5));
}
Err(e) => {
return Err(e).context("waiting for four simultaneous range requests");
}
}
}
// No worker gets a response until all four requests have arrived.
let data = b"abcdefghijklmnop";
for offset in (0..data.len()).step_by(4).rev() {
let mut stream = requests
.remove(&format!("bytes={offset}-{}", offset + 3))
.context("missing requested range")?;
write!(
stream,
"HTTP/1.1 206 Partial Content\r\nContent-Length: 4\r\nContent-Range: bytes {offset}-{}/16\r\nConnection: close\r\n\r\n",
offset + 3
)?;
stream.write_all(&data[offset..offset + 4])?;
}
Ok(())
});
let data = read_parallel_segment(&test_agent(), &url, 0, 15, 16, &Silent);
server
.join()
.map_err(|_| anyhow::anyhow!("test server failed"))??;
assert_eq!(data?, b"abcdefghijklmnop");
Ok(())
}
#[test]
fn rejects_ignored_misaligned_and_truncated_ranges() -> Result<()> {
let listener = TcpListener::bind("127.0.0.1:0")?;
let url = format!("http://{}", listener.local_addr()?);
let server = thread::spawn(move || -> Result<()> {
for reply in [
"HTTP/1.1 200 OK\r\nContent-Length: 4\r\nConnection: close\r\n\r\nabcd",
"HTTP/1.1 206 Partial Content\r\nContent-Length: 4\r\nContent-Range: bytes 5-8/16\r\nConnection: close\r\n\r\nabcd",
"HTTP/1.1 206 Partial Content\r\nContent-Length: 3\r\nContent-Range: bytes 4-7/16\r\nConnection: close\r\n\r\nabc",
] {
let (mut stream, _) = listener.accept()?;
read_request(&stream)?;
stream.write_all(reply.as_bytes())?;
}
Ok(())
});
let agent = test_agent();
for _ in 0..3 {
assert!(read_exact_range(&agent, &url, 4, 16, &mut [0; 4], &Silent).is_err());
}
server
.join()
.map_err(|_| anyhow::anyhow!("test server failed"))??;
Ok(())
}
#[test]
fn falls_back_to_a_single_request_from_the_verified_prefix() -> Result<()> {
use crate::chunklist::{ChunkCheck, Chunklist, Signature};
use sha2::{Digest, Sha256};
let data = b"abcdefghijklmnop";
let listener = TcpListener::bind("127.0.0.1:0")?;
let url = format!("http://{}", listener.local_addr()?);
let server = thread::spawn(move || -> Result<()> {
for _ in 0..PARALLEL_REQUESTS {
let (mut stream, _) = listener.accept()?;
read_request(&stream)?;
stream.write_all(
b"HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n",
)?;
}
let (mut stream, _) = listener.accept()?;
assert_eq!(read_request(&stream)?, "bytes=4-15");
stream.write_all(
b"HTTP/1.1 206 Partial Content\r\nContent-Length: 12\r\nContent-Range: bytes 4-15/16\r\nConnection: close\r\n\r\n",
)?;
stream.write_all(&data[4..])?;
Ok(())
});
let dir = std::env::temp_dir().join(format!("reims-util-fallback-{}", std::process::id()));
std::fs::create_dir_all(&dir)?;
let path = dir.join("download");
std::fs::write(part_path(&path), &data[..4])?;
let chunks = data
.chunks_exact(4)
.map(|chunk| (4, Sha256::digest(chunk).into()))
.collect();
let mut check = ChunkCheck::new(Chunklist {
chunks,
signature: Signature::Digest,
});
let mut request = Download::new(&url, "Test download".into());
request.size = Some(data.len() as u64);
request.parallel = true;
let result = download(
&test_agent(),
request,
Dest::File(&path),
&mut check,
&Silent,
);
let actual = std::fs::read(&path);
let _ = std::fs::remove_file(&path);
let _ = std::fs::remove_file(part_path(&path));
let _ = std::fs::remove_dir(&dir);
result?;
server
.join()
.map_err(|_| anyhow::anyhow!("test server failed"))??;
assert_eq!(actual?, data);
Ok(())
}
fn test_agent() -> Agent {
Agent::config_builder()
.proxy(None)
.http_status_as_error(false)
.timeout_global(Some(Duration::from_secs(5)))
.build()
.into()
}
#[test]
fn parses_content_range() {
+2
View File
@@ -475,6 +475,7 @@ pub fn offline_installer(inst: &Installer, dir: &Path, r: &dyn Reporter) -> Resu
progress::check(r)?;
let mut d = Download::new(&inst.url, format!("Downloading {}", inst.label()));
d.size = Some(inst.size);
d.parallel = true;
let pkg = Dest::Region {
file: &mut f,
offset: pkg_at,
@@ -746,6 +747,7 @@ mod tests {
/// macOS 12's and 26's do, through `<target>Applications`), and where it fails after placing
/// the app (as Big Sur's does, needing zsh), the app gets the package as SharedSupport.dmg
/// and the script starts its startosinstall on the volume.
#[cfg(unix)]
#[test]
fn install_script_runs_without_dirname_or_zsh() {
use std::os::unix::fs::{PermissionsExt, symlink};
+134 -1
View File
@@ -3,9 +3,66 @@
//! 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).
use anyhow::{Context, Result, bail};
use anyhow::{Context, Result, bail, ensure};
use plist::{Dictionary, Value};
use std::path::{Path, PathBuf};
#[derive(serde::Deserialize)]
#[serde(rename_all = "PascalCase")]
struct PrebootManifest {
input: Dictionary,
drivers: Vec<Dictionary>,
}
/// Saved UEFI input settings and the original preboot drivers, in load order.
pub struct PrebootInput {
pub input: Dictionary,
pub drivers: Vec<Dictionary>,
pub files: Vec<(String, Vec<u8>)>,
}
impl PrebootInput {
pub fn read(dir: &Path) -> Result<Self> {
let manifest = dir.join("input.plist");
let PrebootManifest { input, drivers } = plist::from_bytes(&read_regular_file(&manifest)?)
.with_context(|| format!("read {}", manifest.display()))?;
let mut files = Vec::with_capacity(drivers.len());
let mut seen = Vec::<&str>::new();
for entry in &drivers {
let path = entry
.get("Path")
.and_then(Value::as_string)
.context("a preboot driver has no Path string")?;
let name = ["ReimsTablet.efi", "OpenUsbKbDxe.efi"]
.into_iter()
.find(|name| path.eq_ignore_ascii_case(name))
.with_context(|| format!("unsupported preboot driver {path:?}"))?;
ensure!(!seen.contains(&name), "duplicate preboot driver {path:?}");
seen.push(name);
// Path is one of the supported basenames above. Keep the spelling in the plist.
let bytes = read_regular_file(&dir.join(path))?;
files.push((format!("EFI/OC/Drivers/{path}"), bytes));
}
Ok(Self {
input,
drivers,
files,
})
}
}
fn read_regular_file(path: &Path) -> Result<Vec<u8>> {
let context = || format!("read {}", path.display());
ensure!(
std::fs::symlink_metadata(path)
.with_context(context)?
.is_file(),
"{} is not a regular file",
path.display()
);
std::fs::read(path).with_context(context)
}
/// A `--add-kext` value, `PATH[,MIN[,MAX]]`: a bundle, and the Darwin versions it loads on, each
/// bound empty for none.
#[derive(Clone, Debug, PartialEq)]
@@ -300,6 +357,82 @@ pub(crate) mod tests {
}
}
fn preboot_manifest(paths: &[&str]) -> Vec<u8> {
let mut input = Dictionary::new();
input.insert("KeySupport".into(), false.into());
input.insert("PointerSupport".into(), true.into());
let drivers = paths
.iter()
.map(|&path| {
let mut row = Dictionary::new();
row.insert("Path".into(), path.into());
row.insert("LoadEarly".into(), true.into());
row.insert("Enabled".into(), true.into());
Value::Dictionary(row)
})
.collect();
let mut manifest = Dictionary::new();
manifest.insert("Input".into(), input.into());
manifest.insert("Drivers".into(), Value::Array(drivers));
let mut bytes = Vec::new();
Value::Dictionary(manifest)
.to_writer_xml(&mut bytes)
.unwrap();
bytes
}
#[test]
fn preboot_input_preserves_driver_order_casing_and_bytes() {
let paths = ["OpenUsbKbDxe.efi", "reimstablet.EFI"];
let manifest = preboot_manifest(&paths);
let dir = Bundle::new(
"preboot",
&[
("input.plist", &manifest),
(paths[0], b"keyboard"),
(paths[1], b"tablet"),
],
);
let preboot = PrebootInput::read(&dir.path).unwrap();
assert_eq!(preboot.input["KeySupport"], Value::Boolean(false));
assert_eq!(preboot.input["PointerSupport"], Value::Boolean(true));
for (entry, path) in preboot.drivers.iter().zip(paths) {
assert_eq!(entry["Path"], Value::String(path.into()));
assert_eq!(entry["LoadEarly"], Value::Boolean(true));
}
assert_eq!(
preboot.files,
[
(
"EFI/OC/Drivers/OpenUsbKbDxe.efi".into(),
b"keyboard".to_vec()
),
("EFI/OC/Drivers/reimstablet.EFI".into(), b"tablet".to_vec()),
]
);
}
#[test]
fn preboot_input_refuses_duplicates_and_missing_or_unrecognized_files() {
for (paths, expected) in [
(&["../ReimsTablet.efi"][..], "unsupported preboot driver"),
(&["Anything.efi"][..], "unsupported preboot driver"),
(
&["ReimsTablet.efi", "reimstablet.EFI"][..],
"duplicate preboot driver",
),
(&["OpenUsbKbDxe.efi"][..], "OpenUsbKbDxe.efi"),
] {
let manifest = preboot_manifest(paths);
let dir = Bundle::new(
"preboot",
&[("input.plist", &manifest), ("ReimsTablet.efi", b"tablet")],
);
let error = PrebootInput::read(&dir.path).err().unwrap();
assert!(format!("{error:#}").contains(expected), "{error:#}");
}
}
/// An Info.plist: its identifier, executable and libraries.
pub(crate) fn info(id: &str, executable: Option<&str>, libraries: &[&str]) -> Vec<u8> {
let mut d = plist::Dictionary::new();
+10 -1
View File
@@ -70,7 +70,12 @@ pub struct Options {
}
/// 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>> {
pub fn make(
sample: &[u8],
o: &Options,
added: &[added::Kext],
preboot: Option<&added::PrebootInput>,
) -> Result<Vec<u8>> {
let mut root: Value = plist::from_bytes(sample).context("read Sample.plist")?;
let c = root
.as_dictionary_mut()
@@ -268,6 +273,10 @@ pub fn make(sample: &[u8], o: &Options, added: &[added::Kext]) -> Result<Vec<u8>
e.insert("LoadEarly".into(), false.into());
entries.push(Value::Dictionary(e));
}
if let Some(preboot) = preboot {
set(c, &["UEFI"], "Input", preboot.input.clone().into())?;
entries.extend(preboot.drivers.iter().cloned().map(Value::Dictionary));
}
set(c, &["UEFI"], "Drivers", Value::Array(entries))?;
set(c, &["UEFI"], "ReservedMemory", Value::Array(vec![]))?;
+13 -2
View File
@@ -52,6 +52,8 @@ pub struct Options {
pub config: config::Options,
/// Kexts to load, in this order.
pub add_kexts: Vec<added::Spec>,
/// Directory containing the original VM's preboot input settings and drivers.
pub preboot_input: Option<PathBuf>,
/// Where OVMF's files go, or None to write none.
pub ovmf_dir: Option<PathBuf>,
}
@@ -75,12 +77,20 @@ pub fn build(o: &Options, r: &dyn Reporter) -> Result<Outputs> {
.map(added::read)
.collect::<Result<Vec<_>>>()?;
added::check(&added)?;
let preboot = o
.preboot_input
.as_deref()
.map(added::PrebootInput::read)
.transpose()?;
let zip_path = cache::fetch(&RELEASE, r)?;
progress::check(r)?;
let resources_path = cache::fetch(&RESOURCES, r)?;
progress::check(r)?;
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, preboot.as_ref())?;
if let Some(preboot) = preboot {
files.extend(preboot.files);
}
files.extend(resources(&resources_path, o.config.graphical_picker)?);
let mut kext_names = Vec::new();
for k in added {
@@ -125,6 +135,7 @@ fn files(
zip_path: &Path,
c: &config::Options,
added: &[added::Kext],
preboot: Option<&added::PrebootInput>,
) -> Result<Vec<(String, Vec<u8>)>> {
let f =
std::fs::File::open(zip_path).with_context(|| format!("open {}", zip_path.display()))?;
@@ -157,7 +168,7 @@ fn files(
let sample = read("Docs/Sample.plist")?;
files.push((
"EFI/OC/config.plist".into(),
config::make(&sample, c, added)?,
config::make(&sample, c, added, preboot)?,
));
files.push((
format!("EFI/OC/ACPI/{}", acpi::FILE_NAME),
+1
View File
@@ -311,6 +311,7 @@ impl Image {
size: Some(self.size()),
refresh: Some(&mut refresh),
user_agent: Some(USER_AGENT),
parallel: false,
tries: http::MAX_FAILURES,
};
http::download(&self.agent, d, dest, check, r)
+1
View File
@@ -270,6 +270,7 @@ impl App {
text_picker: !form.toggle(7),
show_picker: form.toggle(8),
add_kext: Vec::new(),
preboot_input: None,
_retired: 0,
no_ovmf: !form.toggle(3),
ovmf_dir: None,