From 52f7ea0567bf0209b6bbf31229c0bd0d403cd152 Mon Sep 17 00:00:00 2001 From: Tyler Smith <74526874+tylertms@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:42:12 -0500 Subject: [PATCH] feat(setup)!: make every new setup a network install and remove the installer choice and --install-image, since no install works without the network --- .github/workflows/release.yml | 6 +- README.md | 6 +- crates/stela-cli/src/lib.rs | 2 +- crates/stela-cli/src/setup.rs | 42 ++++---- crates/stela-cli/src/setup/addresses.rs | 2 +- crates/stela-cli/src/setup/command.rs | 20 +--- crates/stela-cli/src/setup/create.rs | 4 +- crates/stela-cli/src/setup/doctor.rs | 21 +--- crates/stela-cli/src/setup/record.rs | 13 +-- crates/stela-cli/src/setup/tests.rs | 22 ++-- crates/stela-cli/src/setup/wizard.rs | 104 +++---------------- crates/stela-cli/src/setup/wizard/choices.rs | 4 +- 12 files changed, 69 insertions(+), 177 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a688ecfba2..2ddbc316e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,15 +35,15 @@ env: - An x86-64-v2 CPU (about 2011 or newer), UEFI with Secure Boot off, 8 GB of RAM. - An NVIDIA GTX 16 or RTX 20 series GPU or newer. - - A USB stick: 8 GB for the network installer, 32 GB for the full installer. + - A USB stick of 8 GB or more. - An empty GPT partition of at least 60 GB. - - Network access during the install. + - Network access during the install, which downloads macOS. INSTALL: |- Install: 1. Unpack the archive for your system. 2. On the PC that will run macOS, run sudo ./stela setup (Linux, macOS) or double-click stela.exe (Windows). - 3. Choose the USB stick, the installer type and the Mac model, then confirm. Setup erases the USB stick. + 3. Choose the USB stick, the macOS version and the Mac model, then confirm. Setup erases the USB stick. 4. Boot the PC from the USB stick. You are responsible for following Apple's software license agreement and terms of use. diff --git a/README.md b/README.md index 0ed089fb42..5ec403f591 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ and Apple7 GPU families. - An x86-64-v2 CPU (about 2011 or newer), UEFI with Secure Boot off, 8 GB of RAM. - An NVIDIA GTX 16 or RTX 20 series GPU or newer. -- A USB stick: 8 GB for the network installer, 32 GB for the full installer. +- A USB stick of 8 GB or more. - An empty GPT partition of at least 60 GB. -- Network access during the install. +- Network access during the install, which downloads macOS. Stela currently models the Mac mini (M2) and runs macOS 27. @@ -41,7 +41,7 @@ Stela currently models the Mac mini (M2) and runs macOS 27. [releases page](https://github.com/tylertms/Stela/releases). 2. On the PC that will run macOS, run `sudo ./stela setup` (Linux, macOS) or double-click `stela.exe` (Windows). -3. Choose the USB stick, the installer type and the Mac model, then confirm. +3. Choose the USB stick, the macOS version and the Mac model, then confirm. Setup erases the USB stick. 4. Boot the PC from the USB stick. diff --git a/crates/stela-cli/src/lib.rs b/crates/stela-cli/src/lib.rs index 05f44b43d6..e719d92f46 100644 --- a/crates/stela-cli/src/lib.rs +++ b/crates/stela-cli/src/lib.rs @@ -239,7 +239,7 @@ mod tests { &["status"][..], &["repair", "--ipsw", "a.ipsw", "--erase-target"], &["update", "stela", "--efi", "stela.efi"], - &["update", "os", "--install-image", "network"], + &["update", "os", "--ipsw", "a.ipsw"], &["update", "stela", "--fetch"], &["uninstall"], &["nvram", "next-boot", "recovery", "--install", "macOS"], diff --git a/crates/stela-cli/src/setup.rs b/crates/stela-cli/src/setup.rs index dd08a1e189..bad91ab5cf 100644 --- a/crates/stela-cli/src/setup.rs +++ b/crates/stela-cli/src/setup.rs @@ -2,10 +2,10 @@ //! a disk of the PC and boot it, and keep it working over the installed //! system's life. //! -//! Setup writes the install medium (`setup::medium`) as `--install-image` -//! says: full, the whole IPSW on the USB's FAT32 data partition; network, -//! only its inventory, and `stela.efi` streams the IPSW from Apple's servers -//! during the install. It prepares each machine's restore bundle (`stela +//! Setup writes the install medium (`setup::medium`): the IPSW's inventory, +//! from which `stela.efi` streams the IPSW from Apple's servers during the +//! install. A USB made when setup still offered it holds the whole IPSW on +//! its FAT32 data partition instead, and keeps doing so. It prepares each machine's restore bundle (`stela //! boot prepare --restore`) and adds an Install macOS startup choice //! (`stela.efi --install`), which restores macOS and its paired recoveryOS //! and System Recovery onto the Mac's internal SSD, as a Mac's erase @@ -142,10 +142,6 @@ const CHOOSER_SECONDS: u32 = 5; const INSTALL_CHOICE: &str = "Install macOS"; /// The startup choice that updates a setup's one install in place. const UPDATE_CHOICE: &str = "Update macOS"; -/// The commands `--install-image` goes with. -const INSTALL_IMAGE_ACTIONS: &str = "--install-image goes with a new setup or --target; \ - `stela setup update os` and `stela setup repair` take it with the image they write"; - /// `stela setup {words} --usb {usb}` in backticks, as a user types it: every /// maintenance command needs `--usb`. fn fix(usb: &Path, words: &str) -> String { @@ -176,9 +172,6 @@ fn rerun(record: &Record, usb: &Path) -> String { if record.build != builds::DEFAULT.build { let _ = write!(words, " --build {}", record.build); } - if record.install_image == Some(InstallImage::Full) || record.media.iter().any(|m| !m.remote) { - words.push_str(" --install-image full"); - } if record.model != PINNED_MODEL { let _ = write!(words, " --model {}", record.model); } @@ -272,8 +265,9 @@ fn restore_choice_name(kind: Kind) -> &'static str { } } -/// Where an install reads the macOS restore image (`--install-image`). -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, clap::ValueEnum)] +/// Where an install reads the macOS restore image. Every new setup streams +/// it; a USB made when setup still offered the whole image keeps it. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub(crate) enum InstallImage { /// The whole IPSW on the USB: no image download during the install, @@ -294,14 +288,13 @@ fn image_is_remote(ipsw: &Path, choice: Option) -> Result { Some(InstallImage::Full) => { ensure!( complete, - "{} holds only the recovery members, without the macOS system image an \ - install restores; pass the whole IPSW with --ipsw, leave out --ipsw to download \ - it, or use --install-image network to stream it from Apple during the install", + "{} holds only the recovery members, without the macOS system image this USB's \ + install reads from it; pass the whole IPSW with --ipsw", ipsw.display() ); Ok(false) } - None => Ok(!complete), + None => Ok(true), } } @@ -673,6 +666,17 @@ impl Request { // A maintenance `--fetch` downloads the image of the model the setup // presents. self.model.get_or_insert_with(|| record.model.clone()); + // A USB that holds the whole macOS image keeps holding it: its + // repairs and updates download whole images. + if self.install_image.is_none() { + self.install_image = record.install_image.or_else(|| { + record + .media + .iter() + .any(|medium| !medium.remote) + .then_some(InstallImage::Full) + }); + } // Repair puts back the active build's files, so `--fetch` downloads // that build. if matches!(action, Action::Repair) { @@ -777,10 +781,6 @@ impl Request { } return machines::add(environment, &self); } - ensure!( - !configured || self.install_image.is_none(), - "{INSTALL_IMAGE_ACTIONS}" - ); setup(environment, self) } diff --git a/crates/stela-cli/src/setup/addresses.rs b/crates/stela-cli/src/setup/addresses.rs index 1339f11303..a54ef26cf0 100644 --- a/crates/stela-cli/src/setup/addresses.rs +++ b/crates/stela-cli/src/setup/addresses.rs @@ -119,7 +119,7 @@ pub(super) fn servers(word: &str) -> Result { /// The wizard's network step: automatic addresses, or a static IPv4 /// address with its router and DNS servers. pub(super) fn choose(request: &mut Request) -> Result<()> { - let manual = cliclack::select("6 / 7 Network addresses") + let manual = cliclack::select("5 / 6 Network addresses") .item(false, "Automatic", "DHCP and IPv6 autoconfiguration") .item( true, diff --git a/crates/stela-cli/src/setup/command.rs b/crates/stela-cli/src/setup/command.rs index e4b25eed5d..d593325219 100644 --- a/crates/stela-cli/src/setup/command.rs +++ b/crates/stela-cli/src/setup/command.rs @@ -2,7 +2,7 @@ //! flags, and each action on an existing setup is a subcommand with only //! the options it takes, so the parser refuses every other combination. //! Each form becomes one [`Request`] for the action it names. -use super::{Action, InstallImage, NextBoot, Request, builds, ecid::Ecid, wifi}; +use super::{Action, NextBoot, Request, builds, ecid::Ecid, wifi}; use clap::{Args, Subcommand, builder::TypedValueParser}; use std::path::PathBuf; use stela_boot_core::options::Uuid; @@ -275,13 +275,6 @@ struct Create { usb4_approve: Vec, #[command(flatten)] addressing: Addressing, - /// Where an install reads macOS: `full` copies the whole IPSW (about - /// 27 GB) onto the USB; `network` writes only its file list, and - /// stela.efi downloads macOS from Apple during the install. Either way - /// the install needs the network for Apple's signing server. A local - /// IPSW defaults to full, a download to network. - #[arg(long, value_enum)] - install_image: Option, /// The `stela.efi` to install instead of the one built into `stela`. #[arg(long, hide = true)] efi: Option, @@ -359,7 +352,6 @@ impl Create { let mut request = Request { action: Action::Create, usb: self.usb, - install_image: self.install_image, efi: self.efi, model: self.model, dry_run: self.dry_run, @@ -395,10 +387,6 @@ struct Repair { /// again. #[arg(long, conflicts_with = "ipsw")] fetch: bool, - /// Where an install reads the restore image the repaired medium holds - /// (with `--ipsw` or `--fetch`). - #[arg(long, value_enum)] - install_image: Option, /// Erase the other file system an install's SSD partition holds: the /// PC's own OS would mount it and clear Stela's machine state. #[arg(long)] @@ -424,7 +412,6 @@ struct Repair { impl Repair { fn request(self) -> Request { let mut request = Request { - install_image: self.install_image, erase_target: self.erase_target, initialize_nor: self.initialize_nor, ecid: self.ecid, @@ -462,7 +449,6 @@ impl Update { } Self::Os(command) => { let mut request = Request { - install_image: command.install_image, dry_run: command.dry_run, ..command.usb.request(Action::UpdateOs) }; @@ -497,10 +483,6 @@ struct UpdateOs { usb: Usb, #[command(flatten)] image: Image, - /// Where an install reads the new build's restore image (see `stela - /// setup --help`). - #[arg(long, value_enum)] - install_image: Option, /// Show what would change, and change nothing. #[arg(long)] dry_run: bool, diff --git a/crates/stela-cli/src/setup/create.rs b/crates/stela-cli/src/setup/create.rs index 8d27977f27..8a95e2ee2e 100644 --- a/crates/stela-cli/src/setup/create.rs +++ b/crates/stela-cli/src/setup/create.rs @@ -961,9 +961,7 @@ pub(super) fn setup(environment: &Environment<'_>, mut command: Request) -> Resu + 4 * MARGIN; ensure!( *capacity == 0 || *capacity >= required, - "this installer needs a USB of at least {} (this one holds {}): use a larger \ - USB, or the network installer (--install-image network), which downloads macOS \ - during the install", + "this installer needs a USB of at least {} (this one holds {}): use a larger USB", host::bytes_text(required), host::bytes_text(*capacity) ); diff --git a/crates/stela-cli/src/setup/doctor.rs b/crates/stela-cli/src/setup/doctor.rs index 996854619b..949a0951a5 100644 --- a/crates/stela-cli/src/setup/doctor.rs +++ b/crates/stela-cli/src/setup/doctor.rs @@ -225,18 +225,13 @@ fn efi_status(environment: &Environment<'_>, record: &Record, report: &mut Repor /// The command that puts back the active build's restore files: `--fetch` /// downloads that build, the whole image when the medium holds it. -fn image_fix(record: &Record, report: &Report) -> String { - let full = record.active_medium().is_some_and(|medium| !medium.remote); - report.fix(if full { - "repair --fetch --install-image full" - } else { - "repair --fetch" - }) +fn image_fix(report: &Report) -> String { + report.fix("repair --fetch") } fn bundle_status(environment: &Environment<'_>, record: &Record, report: &mut Report) { let repair = report.fix("repair"); - let image = image_fix(record, report); + let image = image_fix(report); for kept in &record.bundles { let directory = kept.directory(&record.volume); let role = if kept.build == record.build && kept.generation() == record.generation() { @@ -741,21 +736,13 @@ pub(super) fn repair(environment: &Environment<'_>, command: &Request) -> Result "" } )?; - let full = record.active_medium().is_some_and(|medium| !medium.remote); return Err(Reported { report: text, summary: format!( "repair needs the macOS {} restore image: run {} (or --ipsw FILE in place \ of --fetch)", record.build, - fix( - usb, - if full { - "repair --fetch --install-image full" - } else { - "repair --fetch" - } - ) + fix(usb, "repair --fetch") ), } .into()); diff --git a/crates/stela-cli/src/setup/record.rs b/crates/stela-cli/src/setup/record.rs index 206df92fdc..22a6fc49fc 100644 --- a/crates/stela-cli/src/setup/record.rs +++ b/crates/stela-cli/src/setup/record.rs @@ -80,8 +80,7 @@ pub(super) struct Record { /// Every choice times the engine (`--profile`). #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub(super) profile: bool, - /// Where installs read the restore image (`--install-image`); the - /// default when absent. + /// Where installs read the restore image; streamed when absent. #[serde(default, skip_serializing_if = "Option::is_none")] pub(super) install_image: Option, /// The translation store `stela.efi` keeps its packs in, if the USB @@ -111,12 +110,10 @@ pub(super) const RECORD_KIND: &str = "stela_setup"; pub(super) const RECORD_SCHEMA: u32 = 9; impl Record { - /// Whether installs stream `ipsw`'s build from Apple's servers - /// (`--install-image network`) rather than read it from the USB. An erase - /// restore needs the macOS system image, which a recovery archive - /// (`restore::payload::trim`) leaves out. A complete local image - /// stays local by default, including when the target disk will be - /// chosen later on another PC. + /// Whether installs stream `ipsw`'s build from Apple's servers rather + /// than read it from the USB, as every setup does but one that already + /// holds whole images. An erase restore needs the macOS system image, + /// which a recovery archive (`restore::payload::trim`) leaves out. pub(super) fn remote_install(&self, ipsw: &Path) -> Result { image_is_remote(ipsw, self.install_image) } diff --git a/crates/stela-cli/src/setup/tests.rs b/crates/stela-cli/src/setup/tests.rs index fe5adb2a04..4056bddd5f 100644 --- a/crates/stela-cli/src/setup/tests.rs +++ b/crates/stela-cli/src/setup/tests.rs @@ -243,7 +243,9 @@ fn command(f: &Fixture, usb: &Path) -> Request { usb: usb.to_path_buf(), ipsw: Some(f.ipsw.clone()), fetch: false, - install_image: None, + // Most of these tests exercise a USB that holds the whole image, as + // setups made before every install streamed it do. + install_image: Some(InstallImage::Full), download_dir: None, efi: Some(f.efi.clone()), model: Some(restore::payload::SYNTHETIC_MODEL.into()), @@ -1235,11 +1237,6 @@ fn install_reads_full_or_streamed_image() { "{install}" ); assert!(!install.contains("--install-source"), "{install}"); - // The choice is the setup's. - let error = rerun(&f, |c| c.install_image = Some(InstallImage::Full)) - .unwrap_err() - .to_string(); - assert!(error.contains("--install-image goes with"), "{error}"); // Repair makes it full: the IPSW in pieces on the USB. let switch = |image| { rerun(&f, |c| { @@ -1282,9 +1279,18 @@ fn full_install_requires_system_image() { full.dry_run = true; let error = format!("{:#}", setup(&environment(&f.host), full).unwrap_err()); assert!(error.contains("only the recovery members"), "{error}"); - // By default such an image streams the install instead. + // A new setup names no image choice and streams the install, from a + // recovery archive and from a whole image alike. + for ipsw in [recovery, f.ipsw.clone()] { + let mut default = installed_command(&f); + default.ipsw = Some(ipsw); + default.install_image = None; + default.dry_run = true; + let report = setup(&environment(&f.host), default).unwrap(); + assert!(report.contains("file list only"), "{report}"); + } let mut default = installed_command(&f); - default.ipsw = Some(recovery); + default.install_image = None; setup(&environment(&f.host), default).unwrap(); let record = record(&f); assert_eq!(record.install_image, None); diff --git a/crates/stela-cli/src/setup/wizard.rs b/crates/stela-cli/src/setup/wizard.rs index ca22e7adf9..d5573931c6 100644 --- a/crates/stela-cli/src/setup/wizard.rs +++ b/crates/stela-cli/src/setup/wizard.rs @@ -19,7 +19,6 @@ mod theme; // Advertised USB capacity classes; preparation also checks exact image sizes. const NETWORK_MIN: u64 = 7 * 1024 * 1024 * 1024; -const FULL_MIN: u64 = 28 * 1024 * 1024 * 1024; #[derive(Clone, Debug, PartialEq, Eq)] pub(super) struct Usb { @@ -213,10 +212,8 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { "Capacity unavailable".into() } else if usb.bytes < NETWORK_MIN { "Too small · Requires an 8 GB or larger USB".into() - } else if usb.bytes < FULL_MIN { - "Network installer only · Full needs a 32 GB USB".into() } else { - "Full or network installer".into() + String::new() }, enabled: usb.bytes >= NETWORK_MIN, }) @@ -235,7 +232,7 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { .iter() .position(|usb| usb.path() == command.usb) .unwrap_or(0); - let usb = &choices[menu::select("1 / 7 Choose a USB", &rows, initial)?]; + let usb = &choices[menu::select("1 / 6 Choose a USB", &rows, initial)?]; command.usb = usb.path(); // A setup this USB holds that stopped part way is finished, not // erased and begun again. @@ -256,67 +253,12 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { return Ok(true); } } - let full = usb.bytes >= FULL_MIN; - let prefilled = first && command.ipsw.is_some() && full; + // A local IPSW named on the command line supplies the boot files; + // the install still downloads macOS. + let prefilled = first && command.ipsw.is_some(); first = false; - let source = if prefilled { - 2 - } else { - let item = |value, label: &str, hint: &str, enabled| menu::Item { - value, - label: label.into(), - hint: hint.into(), - enabled, - }; - let rows = [ - item( - 0, - "Full installer", - "Downloads the full macOS image onto the USB · Requires a 32 GB USB", - full, - ), - item( - 1, - "Network installer", - "Downloads boot files only · Requires an 8 GB USB; macOS downloads during installation", - true, - ), - item( - 2, - "Use an existing IPSW", - "Copies your downloaded image to the USB · Requires a 32 GB USB", - full, - ), - ]; - let initial = if command.ipsw.is_some() { - 2 - } else { - usize::from(command.install_image == Some(InstallImage::Network)) - }; - menu::select("2 / 7 Choose an installer", &rows, initial)? - }; - let (version, models) = if source == 2 { - let path = if prefilled { - command.ipsw.clone().unwrap() - } else { - let initial = command - .ipsw - .as_ref() - .map(|p| p.display().to_string()) - .unwrap_or_default(); - let text: String = cliclack::input("3 / 7 Choose an IPSW file") - .placeholder("Path to the .ipsw file") - .default_input(&initial) - .validate(|s: &String| { - if Path::new(s.trim().trim_matches('"')).is_file() { - Ok(()) - } else { - Err("Choose an existing IPSW file") - } - }) - .interact()?; - PathBuf::from(text.trim().trim_matches('"')) - }; + let (version, models) = if prefilled { + let path = command.ipsw.clone().unwrap(); let progress = Phase::spinner("Reading IPSW metadata"); let manifest = local_image(&path).with_context(|| format!("reading {}", path.display()))?; @@ -327,7 +269,7 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { command.fetch = false; command.build = manifest.product_build.clone(); preferred_build = Some(command.build.clone()); - command.install_image = Some(InstallImage::Full); + command.install_image = Some(InstallImage::Network); cliclack::log::info(format!( "macOS {} ({}) · local IPSW{}", manifest.product_version, @@ -355,11 +297,7 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { preferred_build = Some(command.build.clone()); command.ipsw = None; command.fetch = true; - command.install_image = Some(if source == 0 { - InstallImage::Full - } else { - InstallImage::Network - }); + command.install_image = Some(InstallImage::Network); (image.version.clone(), image.models.clone()) }; ensure!( @@ -372,29 +310,13 @@ fn configure_inner(command: &mut Request, host: &dyn Host) -> Result { command.model = Some(choices::model(&models, &names, command.model.as_deref())?); // Every install needs the network for Apple's signing server; a // network installer also downloads macOS over it. - cliclack::log::info(stela_runtime::restore::tss::network_reason( - command.install_image == Some(InstallImage::Network), - ))?; + cliclack::log::info(stela_runtime::restore::tss::network_reason(true))?; choose_wifi(command)?; super::addresses::choose(command)?; - let installer = match (source, command.install_image) { - (2, _) => format!( - "Existing IPSW · {}", - command - .ipsw - .as_deref() - .and_then(Path::file_name) - .map_or_else(String::new, |name| name.to_string_lossy().into_owned()) - ), - (_, Some(InstallImage::Network)) => { - "Network · macOS downloads during installation".into() - } - _ => "Full · the macOS image goes on the USB".into(), - }; cliclack::note( - "7 / 7 Review", + "6 / 6 Review", format!( - "USB {}\nInstaller {installer}\nmacOS {version} ({})\nMac {}\n{}{}{}", + "USB {}\nmacOS {version} ({}) · downloads during installation\nMac {}\n{}{}{}", usb.serial.as_ref().map_or_else( || usb.description(), |serial| format!("{} · serial {serial}", usb.description()) @@ -464,7 +386,7 @@ fn choose_wifi(command: &mut Request) -> Result<()> { progress.finish(); const ETHERNET: usize = usize::MAX; const TYPED: usize = usize::MAX - 1; - let mut select = cliclack::select("5 / 7 Wi-Fi during installation").item( + let mut select = cliclack::select("4 / 6 Wi-Fi during installation").item( ETHERNET, "No Wi-Fi", "Connect the PC to Ethernet during installation", diff --git a/crates/stela-cli/src/setup/wizard/choices.rs b/crates/stela-cli/src/setup/wizard/choices.rs index 65a02c46bd..7ba7b57055 100644 --- a/crates/stela-cli/src/setup/wizard/choices.rs +++ b/crates/stela-cli/src/setup/wizard/choices.rs @@ -86,7 +86,7 @@ pub(super) fn release(images: &[Image], preferred: &str) -> Result { } }) .collect(); - initial = super::menu::select("3 / 7 Choose a macOS version", &majors, initial)?; + initial = super::menu::select("2 / 6 Choose a macOS version", &majors, initial)?; let (major, entries) = &groups[initial]; let rows: Vec<_> = entries .iter() @@ -223,7 +223,7 @@ pub(super) fn model( } }) .collect(); - initial = super::menu::select("4 / 7 Choose a Mac", &families, initial)?; + initial = super::menu::select("3 / 6 Choose a Mac", &families, initial)?; let (family, models) = &groups[initial]; let rows: Vec<_> = models .iter()