summaryrefslogtreecommitdiffstats
path: root/src/idevicerestore.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-10-02 13:21:33 +0200
committerGravatar Nikias Bassen2013-10-02 13:21:33 +0200
commit0326deeba3ec0f11e0386d9448bf670f24dfff22 (patch)
tree77e6e87565f5967ce4a26887cf1fca89060eca56 /src/idevicerestore.c
parentda393b9c399e0c5541311e07f68c4f2c337d50b7 (diff)
downloadidevicerestore-0326deeba3ec0f11e0386d9448bf670f24dfff22.tar.gz
idevicerestore-0326deeba3ec0f11e0386d9448bf670f24dfff22.tar.bz2
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.
Diffstat (limited to 'src/idevicerestore.c')
-rw-r--r--src/idevicerestore.c21
1 files changed, 14 insertions, 7 deletions
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);
}