int install_package(const char *root_path) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("Finding update package...\n"); ui_show_indeterminate_progress(); LOGI("Update location: %s\n", root_path); if (ensure_root_path_mounted(root_path) != 0) { LOGE("Can't mount %s\n", root_path); return INSTALL_CORRUPT; } char path[PATH_MAX] = ""; if (translate_root_path(root_path, path, sizeof(path)) == NULL) { LOGE("Bad path %s\n", root_path); return INSTALL_CORRUPT; } ui_print("Opening update package...\n"); LOGI("Update file path: %s\n", path); int numKeys; RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys); if (loadedKeys == NULL) { LOGE("Failed to load keys\n"); return INSTALL_CORRUPT; } LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE); // Give verification half the progress bar... ui_print("Verifying update package...\n"); ui_show_progress( VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME); int err; err = verify_file(path, loadedKeys, numKeys); free(loadedKeys); LOGI("verify_file returned %d\n", err); if (err != VERIFY_SUCCESS) { LOGE("signature verification failed\n"); return INSTALL_CORRUPT; } /* Try to open the package. */ ZipArchive zip; err = mzOpenZipArchive(path, &zip); if (err != 0) { LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); return INSTALL_CORRUPT; } /* Verify and install the contents of the package. */ int status = handle_update_package(path, &zip); mzCloseZipArchive(&zip); return status; }
int install_package(const char *path) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("Finding update package...\n"); ui_show_indeterminate_progress(); LOGI("Update location: %s\n", path); /* if (strcmp(root_path, ":") == 0) { if (ensure_root_path_mounted(root_path) != 0) { LOGE("Can't mount %s\n", root_path); return INSTALL_CORRUPT; } if (translate_root_path(root_path, path, sizeof(path)) == NULL) { LOGE("Bad path %s\n", root_path); return INSTALL_CORRUPT; } } else { path = strndup(path, root_path); } */ ui_print("Opening update package...\n"); LOGI("Update file path: %s\n", path); /* int numKeys; RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys); if (loadedKeys == NULL) { LOGE("Failed to load keys\n"); return INSTALL_CORRUPT; } LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE); */ /* Try to open the package. */ ZipArchive zip; int err = mzOpenZipArchive(path, &zip); if (err != 0) { LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); return INSTALL_CORRUPT; } /* Verify and install the contents of the package. */ // int status = handle_update_package(path, &zip, loadedKeys, numKeys); int status = handle_update_package(path, &zip); mzCloseZipArchive(&zip); // free(loadedKeys); return status; }
int open_ota_package(const char *root_path) { int status = INSTALL_SUCCESS; int recovery_status = 0; ui_print("Opening OTA upgrade package...\n"); char *c = root_path; const char *p; int len = strlen(root_path); int i; c = c + len-2; for(i=1;i<len-1;i++) { --c; } c[len-1] = '\0'; p = c; int err; ZipArchive zip; err = mzOpenZipArchive(p, &zip); if (err != 0) { ui_print("Can't open '%s'\n(%s)\n", p, err != -1 ? strerror(err) : "bad"); status = INSTALL_CORRUPT; goto exit; } ui_print("start update package file\n"); status = handle_update_package(p, &zip); ui_print("install_success!!!\n"); mzCloseZipArchive(&zip); exit: if (status != INSTALL_SUCCESS) recovery_status = 1; else recovery_status = 0; return status; }
int install_package(const char *root_path) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("Finding update package...\n"); LOGI("Update location: %s\n", root_path); if (ensure_root_path_mounted(root_path) != 0) { LOGE("Can't mount %s\n", root_path); return INSTALL_CORRUPT; } char path[PATH_MAX] = ""; if (translate_root_path(root_path, path, sizeof(path)) == NULL) { LOGE("Bad path %s\n", root_path); return INSTALL_CORRUPT; } ui_print("Opening update package...\n"); LOGI("Update file path: %s\n", path); /* Try to open the package. */ int err; ZipArchive zip; err = mzOpenZipArchive(path, &zip); if (err != 0) { LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); return INSTALL_CORRUPT; } /* Verify and install the contents of the package. */ int status = handle_update_package(path, &zip); mzCloseZipArchive(&zip); return status; }
int install_package(const char *root_path) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("查找升级包中...\n"); LOGI("升级点: %s\n", root_path); if (ensure_root_path_mounted(root_path) != 0) { LOGE("无法挂载 %s\n", root_path); return INSTALL_CORRUPT; } char path[PATH_MAX] = ""; if (translate_root_path(root_path, path, sizeof(path)) == NULL) { LOGE("错误路径 %s\n", root_path); return INSTALL_CORRUPT; } ui_print("打开升级包中...\n"); LOGI("升级文件路径: %s\n", path); /* Try to open the package. */ int err; ZipArchive zip; err = mzOpenZipArchive(path, &zip); if (err != 0) { LOGE("无法打开%s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); return INSTALL_CORRUPT; } /* Verify and install the contents of the package. */ int status = handle_update_package(path, &zip); mzCloseZipArchive(&zip); return status; }
int install_package(const char *root_path) { recovery_status = 0; int status = INSTALL_SUCCESS; ui_set_background(BACKGROUND_ICON_INSTALLING); ui_print("Finding update package...\n"); ui_show_indeterminate_progress(); if (ensure_root_path_mounted(root_path) != 0) { ui_print("Can't mount %s\n", root_path); status = INSTALL_CORRUPT; goto exit; } char path[PATH_MAX] = ""; if (translate_root_path(root_path, path, sizeof(path)) == NULL) { ui_print("Bad path %s\n", root_path); status = INSTALL_CORRUPT; goto exit; } printf("package name = '%s'\t path_len= %d\n",path,strlen(path)); ui_print("Opening update package...\n"); #if 0 int numKeys; RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys); if (loadedKeys == NULL) { LOGE("Failed to load keys\n"); return INSTALL_CORRUPT; } LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE); // Give verification half the progress bar... ui_print("Verifying update package...\n"); ui_show_progress( VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME); int err; err = verify_file(path, loadedKeys, numKeys); free(loadedKeys); LOGI("verify_file returned %d\n", err); if (err != VERIFY_SUCCESS) { LOGE("signature verification failed\n"); return INSTALL_CORRUPT; } #endif /* Try to open the package. */ int err; ZipArchive zip; err = mzOpenZipArchive(path, &zip); if (err != 0) { ui_print("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); status = INSTALL_CORRUPT; goto exit; } /* * Verify hw version */ /* if (check_hw_version(&zip)) { ui_print("HW version doesn't match!!!"); status = INSTALL_CORRUPT; mzCloseZipArchive(&zip); goto exit; } */ /* Verify and install the contents of the package. */ ui_print("start update package file\n"); status = handle_update_package(path, &zip); ui_print("install_success!!!\n"); mzCloseZipArchive(&zip); exit: ensure_root_path_unmounted(root_path); if (status != INSTALL_SUCCESS) recovery_status = 1; else recovery_status = 0; return status; }