diff options
author | Nikias Bassen | 2022-06-27 03:38:13 +0200 |
---|---|---|
committer | Nikias Bassen | 2022-06-27 03:38:13 +0200 |
commit | e667b49a4a6d7059c1ae8243961f764551f91a85 (patch) | |
tree | 7bbebb704bef32cd07a315968c647888194d7a86 | |
parent | fbbd4b69842cf97c2d89f0732c88ce127b5d098c (diff) | |
download | idevicerestore-e667b49a4a6d7059c1ae8243961f764551f91a85.tar.gz idevicerestore-e667b49a4a6d7059c1ae8243961f764551f91a85.tar.bz2 |
Add --variant command line switch to specify build identity to use
-rw-r--r-- | src/common.h | 1 | ||||
-rw-r--r-- | src/idevicerestore.c | 19 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h index 634fc09..97d5f96 100644 --- a/src/common.h +++ b/src/common.h @@ -124,6 +124,7 @@ struct idevicerestore_client_t { cond_t device_event_cond; int ignore_device_add_events; plist_t macos_variant; + char* restore_variant; }; extern struct idevicerestore_mode_t idevicerestore_modes[]; diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 96ba67a..ac628ca 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -87,6 +87,7 @@ static struct option longopts[] = { { "version", no_argument, NULL, 'v' }, { "ipsw-info", no_argument, NULL, 'I' }, { "ignore-errors", no_argument, NULL, 1 }, + { "variant", required_argument, NULL, 2 }, { NULL, 0, NULL, 0 } }; @@ -140,6 +141,8 @@ static void usage(int argc, char* argv[], int err) " -P, --plain-progress Print progress as plain step and progress\n" \ " -R, --restore-mode Allow restoring from Restore mode\n" \ " -T, --ticket PATH Use file at PATH to send as AP ticket\n" \ + " --variant VARIANT Use given VARIANT to match the build identity to use,\n" \ + " e.g. 'Customer Erase Install (IPSW)'\n" \ " --ignore-errors Try to continue the restore process after certain\n" \ " errors (like a failed baseband update)\n" \ " WARNING: This might render the device unable to boot\n" \ @@ -831,18 +834,20 @@ int idevicerestore_start(struct idevicerestore_client_t* client) // finally add manifest plist_dict_set_item(build_identity, "Manifest", manifest); } + } else if (client->restore_variant) { + build_identity = build_manifest_get_build_identity_for_model_with_variant(client->build_manifest, client->device->hardware_model, client->restore_variant); } else if (client->flags & FLAG_ERASE) { build_identity = build_manifest_get_build_identity_for_model_with_variant(client->build_manifest, client->device->hardware_model, RESTORE_VARIANT_ERASE_INSTALL); - if (build_identity == NULL) { - error("ERROR: Unable to find any build identities\n"); - return -1; - } } else { build_identity = build_manifest_get_build_identity_for_model_with_variant(client->build_manifest, client->device->hardware_model, RESTORE_VARIANT_UPGRADE_INSTALL); if (!build_identity) { build_identity = build_manifest_get_build_identity_for_model(client->build_manifest, client->device->hardware_model); } } + if (build_identity == NULL) { + error("ERROR: Unable to find a matching build identity\n"); + return -1; + } client->macos_variant = build_manifest_get_build_identity_for_model_with_variant(client->build_manifest, client->device->hardware_model, RESTORE_VARIANT_MACOS_RECOVERY_OS); @@ -1488,6 +1493,7 @@ void idevicerestore_client_free(struct idevicerestore_client_t* client) if (client->preflight_info) { plist_free(client->preflight_info); } + free(client->restore_variant); free(client); } @@ -1718,6 +1724,11 @@ int main(int argc, char* argv[]) { client->flags |= FLAG_IGNORE_ERRORS; break; + case 2: + free(client->restore_variant); + client->restore_variant = strdup(optarg); + break; + default: usage(argc, argv, 1); return EXIT_FAILURE; |