summaryrefslogtreecommitdiffstats
path: root/src/tss.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-01-25 12:31:34 +0100
committerGravatar Nikias Bassen2019-01-25 12:31:34 +0100
commit917f2ae4e3e6245a81e4b853ade240b7644f69f3 (patch)
treec943dbf95b783aba3fb297e23b800c6e431c7bf9 /src/tss.c
parent06a7cc2f23c25034183eec0cc9596f4284a4c3c9 (diff)
downloadidevicerestore-917f2ae4e3e6245a81e4b853ade240b7644f69f3.tar.gz
idevicerestore-917f2ae4e3e6245a81e4b853ade240b7644f69f3.tar.bz2
restore: Move Yonkers component selection code to tss_request_add_yonkers_tags()
Diffstat (limited to 'src/tss.c')
-rw-r--r--src/tss.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/src/tss.c b/src/tss.c
index 80d2935..ca4a7bc 100644
--- a/src/tss.c
+++ b/src/tss.c
@@ -969,7 +969,7 @@ int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t ove
return 0;
}
-int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides)
+int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name)
{
plist_t node = NULL;
@@ -1006,6 +1006,71 @@ int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t ov
}
}
+ char *comp_name = NULL;
+ plist_t comp_node = NULL;
+ uint8_t isprod = 1;
+ uint64_t fabrevision = (uint64_t)-1;
+
+ node = plist_dict_get_item(parameters, "Yonkers,ProductionMode");
+ if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) {
+ plist_get_bool_val(node, &isprod);
+ }
+
+ node = plist_dict_get_item(parameters, "Yonkers,FabRevision");
+ if (node && (plist_get_node_type(node) == PLIST_UINT)) {
+ plist_get_uint_val(node, &fabrevision);
+ }
+
+ plist_dict_iter iter = NULL;
+ plist_dict_new_iter(manifest_node, &iter);
+ while (iter) {
+ node = NULL;
+ comp_name = NULL;
+ plist_dict_next_item(manifest_node, iter, &comp_name, &node);
+ if (comp_name == NULL) {
+ node = NULL;
+ break;
+ }
+ if (strncmp(comp_name, "Yonkers,", 8) == 0) {
+ int target_node = 1;
+ plist_t sub_node;
+ if ((sub_node = plist_dict_get_item(node, "EPRO")) != NULL && plist_get_node_type(sub_node) == PLIST_BOOLEAN) {
+ uint8_t b = 0;
+ plist_get_bool_val(sub_node, &b);
+ target_node &= ((isprod) ? b : !b);
+ }
+ if ((sub_node = plist_dict_get_item(node, "FabRevision")) != NULL && plist_get_node_type(sub_node) == PLIST_UINT) {
+ uint64_t v = 0;
+ plist_get_uint_val(sub_node, &v);
+ target_node &= (v == fabrevision);
+ }
+ if (target_node) {
+ comp_node = node;
+ break;
+ }
+ }
+ free(comp_name);
+ }
+ free(iter);
+
+ if (comp_name == NULL) {
+ error("ERROR: No Yonkers node for %s/%lu\n", (isprod) ? "Production" : "Development", (unsigned long)fabrevision);
+ return -1;
+ }
+
+ /* add Yonkers,SysTopPatch* */
+ if (comp_node != NULL) {
+ plist_t comp_dict = plist_copy(comp_node);
+ plist_dict_remove_item(comp_dict, "Info");
+ plist_dict_set_item(request, comp_name, comp_dict);
+ }
+
+ if (component_name) {
+ *component_name = comp_name;
+ } else {
+ free(comp_name);
+ }
+
/* apply overrides */
if (overrides) {
plist_dict_merge(&request, overrides);