Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ is on main, the release is published with that section as its notes (AGENTS.md,
iOS 10.3.4, boots past its iBSS after a Pico's checkm8: Orchard sends
the plain iBEC there instead of stopping for an encrypted one.

- `orchard resize --amethyst` makes room on iOS 12.2 to 13.7 without DFU
mode and from any computer, Linux included: Resize APFS comes inside the
Amethyst app, signed with your Apple ID. The iPhone 5s, iPad Air and iPad
mini 2 and 3 can now make room without a Mac.

- Touch firmware builds for the iPad Pro 9.7-inch Cellular (J128), whose
touch settings leave out the "Power Off On Reset" flag. Firmware for
devices whose settings carry the flag is unchanged.
Expand Down
43 changes: 40 additions & 3 deletions crates/cli/src/commands/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct AccessFlags {
/// Short for --access dopamine
#[arg(long, conflicts_with = "access")]
dopamine: bool,
/// Short for --access amethyst
#[arg(long, conflicts_with = "access")]
amethyst: bool,
}

#[derive(clap::Args)]
Expand Down Expand Up @@ -56,14 +59,14 @@ pub struct Args {
pub fn run(global: &Global, args: &Args) -> Result<Output> {
let started = Instant::now();
let say = |message: &str| output::progress(global, &format!("[{:.3}s] {message}", started.elapsed().as_secs_f64()));
let short = [(args.short.palera1n, "palera1n"), (args.short.checkra1n, "checkra1n"), (args.short.dopamine, "dopamine")];
let short = [(args.short.palera1n, "palera1n"), (args.short.checkra1n, "checkra1n"), (args.short.dopamine, "dopamine"), (args.short.amethyst, "amethyst")];
let route = args.access.as_deref().or(short.into_iter().find_map(|(set, name)| set.then_some(name))).unwrap_or("palera1n");

let data = global.data_dir()?;
let catalog = Catalog::open(&data)?;
let routes = routes::read(&catalog)?;
routes.named(Kind::Access, route)?;
if !matches!(route, "palera1n" | "checkra1n" | "dopamine") {
if !matches!(route, "palera1n" | "checkra1n" | "dopamine" | "amethyst") {
return Err(Error::new(Code::Unsupported, format!("this version does not run the {route} access route")));
}
// checkra1n's session ends when the person says so: that needs a terminal.
Expand Down Expand Up @@ -96,6 +99,9 @@ pub fn run(global: &Global, args: &Args) -> Result<Output> {
if route == "dopamine" {
return dopamine(&executor, &app, args, &say, started);
}
if route == "amethyst" {
return amethyst(&executor, &app, args, &say, started);
}
let found = super::run::find(global, Duration::from_secs(args.wait))?;
let selector = Selector { ecid: found.identity.ecid.clone(), location: Some(found.location.clone()), mode: Some(Mode::Dfu) };
let mut session = Session::start(Host, &selector, None)?;
Expand Down Expand Up @@ -221,17 +227,48 @@ fn dopamine(executor: &orchard_runtime::exec::Executor, app: &orchard_runtime::r
// Developer Mode comes after the install: iOS lists that setting only
// once an app signed this way is on the device.
access_dopamine::install(executor, access, &signer, &udid, access_dopamine::RESIZE_APFS, say)?;
Ok(Installed { version: app.version.clone(), seconds: started.elapsed().as_secs_f64() }.into())
Ok(Installed { version: app.version.clone(), seconds: started.elapsed().as_secs_f64(), developer_mode: true }.into())
}

/// The route without DFU on iOS 12.2 to 13.7: as [`dopamine`], with the
/// pinned Amethyst, always signed by xtool (Xcode builds nothing for iOS 12
/// and 13), and without Developer Mode, which those versions do not have.
fn amethyst(executor: &orchard_runtime::exec::Executor, app: &orchard_runtime::resize_app::App, args: &Args, say: &dyn Fn(&str), started: Instant) -> Result<Output> {
use orchard_runtime::access_dopamine;
if args.team.is_some() {
return Err(Error::new(Code::Unsupported, "the amethyst route signs with xtool: Xcode builds nothing for iOS 12 and 13"));
}
let access = app.amethyst.as_ref().ok_or_else(|| Error::new(Code::NotFound, format!("Resize APFS {} has no build for the amethyst route", app.version)))?;
if !access_dopamine::xtool_here() {
return Err(Error::new(Code::Unsupported, "nothing on this computer signs the app: xtool publishes no build for it"));
}
let udid = access_dopamine::device()?;
say("Signing with xtool and your Apple ID");
access_dopamine::install_into(executor, access_dopamine::Host::Amethyst, access, &access_dopamine::Signer::Xtool, &udid, access_dopamine::RESIZE_APFS, say)?;
Ok(Installed { version: app.version.clone(), seconds: started.elapsed().as_secs_f64(), developer_mode: false }.into())
}

#[derive(Serialize)]
struct Installed {
version: String,
seconds: f64,
/// iOS 15 and later: Developer Mode must be on (the dopamine route).
developer_mode: bool,
}

impl Report for Installed {
fn human(&self) -> Vec<u8> {
if !self.developer_mode {
return format!(
"Resize APFS {} is installed ({:.0} s).\n\
Trust your Apple ID on the device: Settings > General > Profiles & Device Management.\n\
Then open Resize APFS and tap Continue. The first time, the device restarts once: open Resize APFS \
again when it is back and tap Continue again. Then the screen restarts; unlock the device when it comes back.\n\
A free Apple ID signs the app for 7 days: run this again when it stops opening.\n",
self.version, self.seconds
)
.into_bytes();
}
format!(
"Resize APFS {} is installed ({:.0} s).\n\
Turn on Developer Mode on the device: Settings > Privacy & Security > Developer Mode \
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/examples/dopamine_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
let dir = Path::new(&args[2]);
let mut resources = Vec::new();
files(&dir.join("Resources"), &dir.join("Resources"), &mut resources);
let access = Access { info: std::fs::read(dir.join("Info.plist")).unwrap(), library: std::fs::read(dir.join("ResizeAccess.dylib")).unwrap(), resources };
let access = Access { info: std::fs::read(dir.join("Info.plist")).unwrap(), library: std::fs::read(dir.join("ResizeAccess.dylib")).unwrap(), resources, host: None };
let prepared = prepare(std::fs::read(&args[1]).unwrap(), &access, Path::new(&args[3])).unwrap();
// With a fourth argument, also the IPA a signing tool is given.
if let Some(ipa) = args.get(4) {
Expand Down
Loading
Loading