From 0326deeba3ec0f11e0386d9448bf670f24dfff22 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 2 Oct 2013 13:21:33 +0200 Subject: custom fw: fall back to User ram disk if Update ramdisk is not found This is a fix for AppleTV firmwares since they don't have an Update ram disk but only a User ram disk. When restoring a custom firmware idevicerestore fails if -e parameter is not given. This fix will automatically set erase mode enabled if no update ram disk is found. --- src/idevicerestore.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 45f78ba..8a2786f 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -373,13 +373,6 @@ int idevicerestore_start(struct idevicerestore_client_t* client) plist_t inf; plist_t manifest; - inf = plist_new_dict(); - plist_dict_insert_item(inf, "RestoreBehavior", plist_new_string((client->flags & FLAG_ERASE) ? "Erase" : "Update")); - plist_dict_insert_item(inf, "Variant", plist_new_string((client->flags & FLAG_ERASE) ? "Customer Erase Install (IPSW)" : "Customer Upgrade Install (IPSW)")); - plist_dict_insert_item(build_identity, "Info", inf); - - manifest = plist_new_dict(); - char tmpstr[256]; char p_all_flash[128]; char lcmodel[8]; @@ -414,6 +407,8 @@ int idevicerestore_start(struct idevicerestore_client_t* client) } free(fmanifest); + manifest = plist_new_dict(); + for (x = 0; x < fc; x++) { inf = plist_new_dict(); strcpy(tmpstr, p_all_flash); @@ -477,6 +472,12 @@ int idevicerestore_start(struct idevicerestore_client_t* client) node = plist_dict_get_item(buildmanifest, "RestoreRamDisks"); if (node && (plist_get_node_type(node) == PLIST_DICT)) { plist_t rd = plist_dict_get_item(node, (client->flags & FLAG_ERASE) ? "User" : "Update"); + // if no "Update" ram disk entry is found try "User" ram disk instead + if (!rd && !(client->flags & FLAG_ERASE)) { + rd = plist_dict_get_item(node, "User"); + // also, set the ERASE flag since we actually change the restore variant + client->flags |= FLAG_ERASE; + } if (rd && (plist_get_node_type(rd) == PLIST_STRING)) { inf = plist_new_dict(); plist_dict_insert_item(inf, "Path", plist_copy(rd)); @@ -502,6 +503,12 @@ int idevicerestore_start(struct idevicerestore_client_t* client) plist_dict_insert_item(manifest, "OS", comp); } + // add info + inf = plist_new_dict(); + plist_dict_insert_item(inf, "RestoreBehavior", plist_new_string((client->flags & FLAG_ERASE) ? "Erase" : "Update")); + plist_dict_insert_item(inf, "Variant", plist_new_string((client->flags & FLAG_ERASE) ? "Customer Erase Install (IPSW)" : "Customer Upgrade Install (IPSW)")); + plist_dict_insert_item(build_identity, "Info", inf); + // finally add manifest plist_dict_insert_item(build_identity, "Manifest", manifest); } -- cgit v1.1-32-gdbae