properly selecting correct buildidentity now

This commit is contained in:
tihmstar 2016-12-30 14:07:25 +01:00
parent 74c63d725b
commit 485b0912fc
3 changed files with 63 additions and 57 deletions

View file

@ -567,7 +567,7 @@ char *futurerestore::getLatestFirmwareUrl(){
void futurerestore::loadLatestBaseband(){ void futurerestore::loadLatestBaseband(){
char * manifeststr = getLatestManifest(); char * manifeststr = getLatestManifest();
char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr); char *pathStr = getPathOfElementInManifest("BasebandFirmware", manifeststr, getConnectedDeviceModel(), 0);
info("downloading Baseband\n\n"); info("downloading Baseband\n\n");
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH)) if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
reterror(-32, "could not download baseband\n"); reterror(-32, "could not download baseband\n");
@ -576,7 +576,7 @@ void futurerestore::loadLatestBaseband(){
void futurerestore::loadLatestSep(){ void futurerestore::loadLatestSep(){
char * manifeststr = getLatestManifest(); char * manifeststr = getLatestManifest();
char *pathStr = getPathOfElementInManifest("SEP", manifeststr); char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getConnectedDeviceModel(), 0);
info("downloading SEP\n\n"); info("downloading SEP\n\n");
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH)) if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
reterror(-33, "could not download SEP\n"); reterror(-33, "could not download SEP\n");
@ -688,20 +688,20 @@ plist_t futurerestore::loadPlistFromFile(const char *path){
return ret; return ret;
} }
char *futurerestore::getPathOfElementInManifest(const char *element, const char *manifeststr){ char *futurerestore::getPathOfElementInManifest(const char *element, const char *manifeststr, const char *model, int isUpdateInstall){
char *pathStr = NULL; char *pathStr = NULL;
ptr_smart<plist_t> buildmanifest(NULL,plist_free); ptr_smart<plist_t> buildmanifest(NULL,plist_free);
plist_from_xml(manifeststr, (uint32_t)strlen(manifeststr), &buildmanifest); plist_from_xml(manifeststr, (uint32_t)strlen(manifeststr), &buildmanifest);
if (plist_t buildidentities = plist_dict_get_item(buildmanifest._p, "BuildIdentities")) if (plist_t identity = getBuildidentity(buildmanifest._p, model, isUpdateInstall))
if (plist_t firstIdentitie = plist_array_get_item(buildidentities, 0)) if (plist_t manifest = plist_dict_get_item(identity, "Manifest"))
if (plist_t manifest = plist_dict_get_item(firstIdentitie, "Manifest"))
if (plist_t elem = plist_dict_get_item(manifest, element)) if (plist_t elem = plist_dict_get_item(manifest, element))
if (plist_t info = plist_dict_get_item(elem, "Info")) if (plist_t info = plist_dict_get_item(elem, "Info"))
if (plist_t path = plist_dict_get_item(info, "Path")) if (plist_t path = plist_dict_get_item(info, "Path"))
if (plist_get_string_val(path, &pathStr), pathStr) if (plist_get_string_val(path, &pathStr), pathStr)
goto noerror; goto noerror;
reterror(-31, "could not get %s path\n",element); reterror(-31, "could not get %s path\n",element);
noerror: noerror:
return pathStr; return pathStr;

View file

@ -89,7 +89,7 @@ public:
static char *getNonceFromAPTicket(const char* apticketPath); static char *getNonceFromAPTicket(const char* apticketPath);
static plist_t loadPlistFromFile(const char *path); static plist_t loadPlistFromFile(const char *path);
static void saveStringToFile(const char *str, const char *path); static void saveStringToFile(const char *str, const char *path);
static char *getPathOfElementInManifest(const char *element, const char *manifeststr); static char *getPathOfElementInManifest(const char *element, const char *manifeststr, const char *model, int isUpdateInstall);
}; };

View file

@ -130,6 +130,7 @@ int main(int argc, const char * argv[]) {
futurerestore client; futurerestore client;
if (!client.init()) reterror(-3,"can't init, no device found\n"); if (!client.init()) reterror(-3,"can't init, no device found\n");
try {
if (apticketPaths.size()) client.loadAPTickets(apticketPaths); if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
if (!((apticketPaths.size() && ipsw) if (!((apticketPaths.size() && ipsw)
@ -178,6 +179,11 @@ int main(int argc, const char * argv[]) {
if (flags & FLAG_WAIT){ if (flags & FLAG_WAIT){
client.waitForNonce(); client.waitForNonce();
} }
} catch (int error) {
err = error;
printf("[Error] Fail code=%d\n",err);
goto error;
}
try { try {
res = client.doRestore(ipsw, flags & FLAG_UPDATE); res = client.doRestore(ipsw, flags & FLAG_UPDATE);