Esempio n. 1
0
static int
handle_update_package(const char *path, ZipArchive *zip)
{
    // Update should take the rest of the progress bar.
    ui_print("Installing update...\n");

    LOGI("Trying update-binary.\n");
    int result = try_update_binary(path, zip);

    if (result == INSTALL_UPDATE_BINARY_MISSING)
    {
        LOGI("No update-binary found.\n");
        register_package_root(NULL, NULL);  // Unregister package root
        if (register_package_root(zip, path) < 0) {
            LOGE("Can't register package root\n");
            return INSTALL_ERROR;
        }
        const ZipEntry *script_entry;
        script_entry = find_update_script(zip);
        LOGI("Trying update-script.\n");
        result = handle_update_script(zip, script_entry);
        if (result == INSTALL_UPDATE_SCRIPT_MISSING)
            result = INSTALL_ERROR;
    }

    register_package_root(NULL, NULL);  // Unregister package root
    return result;
}
Esempio n. 2
0
static int
handle_update_package(const char *path, ZipArchive *zip)
{
/*    // Give verification half the progress bar...
    ui_print("Verifying update package...\n");
    ui_show_progress(
            VERIFICATION_PROGRESS_FRACTION,
            VERIFICATION_PROGRESS_TIME);

*//*
    if (!verify_jar_signature(zip, keys, numKeys)) {
        LOGE("Verification failed\n");
        return INSTALL_CORRUPT;
    }
*/

    // Update should take the rest of the progress bar.
    printf("Installing update...\n");

    int result = try_update_binary(path, zip);
    if (result == INSTALL_SUCCESS || result == INSTALL_ERROR) {
        register_package_root(NULL, NULL);  // Unregister package root
        return result;
    }

    // if INSTALL_CORRUPT is returned, this package doesn't have an
    // update binary.  Fall back to the older mechanism of looking for
    // an update script.

    const ZipEntry *script_entry;
    script_entry = find_update_script(zip);
    if (script_entry == NULL) {
        LOGE("Can't find update script\n");
        return INSTALL_CORRUPT;
    }

    if (register_package_root(zip, path) < 0) {
        LOGE("Can't register package root\n");
        return INSTALL_ERROR;
    }

    int ret = handle_update_script(zip, script_entry);
    register_package_root(NULL, NULL);  // Unregister package root
    return ret;
}