int install_package(const char* path, int* wipe_cache, const char* install_file) { FILE* install_log = fopen_path(install_file, "w"); if (install_log) { fputs(path, install_log); fputc('\n', install_log); } else { LOGE("failed to open last_install: %s\n", strerror(errno)); } int result; if (strstr(path, AROMA_FM_PATH) == NULL && setup_install_mounts() != 0) { // do not umount any partition when starting up aroma file manager from default location // in some devices, aroma have trouble mounting /system and /data if they are unmounted at this stage LOGE("failed to set up expected mounts for install; aborting\n"); result = INSTALL_ERROR; } else { result = really_install_package(path, wipe_cache); } #ifdef ENABLE_LOKI if (result == INSTALL_SUCCESS && loki_support_enabled() > 0) { ui_print("Checking if loki-fying is needed\n"); result = loki_check(); } #endif if (install_log) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); fclose(install_log); } return result; }
int install_package(const char* path, bool* wipe_cache, const char* install_file, bool needs_mount) { modified_flash = true; FILE* install_log = fopen_path(install_file, "w"); if (install_log) { fputs(path, install_log); fputc('\n', install_log); } else { LOGE("failed to open last_install: %s\n", strerror(errno)); } int result; if (setup_install_mounts() != 0) { LOGE("failed to set up expected mounts for install; aborting\n"); result = INSTALL_ERROR; } else { result = really_install_package(path, wipe_cache, needs_mount); } if (install_log) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); fclose(install_log); } return result; }
/** * 安装指定路径的 ota_pkg. * @param path * 待安装的 ota_pkg 的路径字串. * @param wipe_cache * 用于返回后续是否要 wipe cache 分区. * @param install_file * 传入 install 流程的 log file 的路径. * @param is_ru_pkg * 标识 'path' 指定的 ota_pkg 是否是 ru_pkg. */ int install_package(const char* path, int* wipe_cache, const char* install_file, bool needs_mount, int is_ru_pkg) { FILE* install_log = fopen_path(install_file, "w"); int ret = INSTALL_SUCCESS; if (install_log) { fputs(path, install_log); fputc('\n', install_log); } else { LOGE("failed to open last_install: %s\n", strerror(errno)); } #ifdef USE_BOARD_ID gIfBoardIdCustom = false; #endif int result; if (setup_install_mounts() != 0) { LOGE("failed to set up expected mounts for install; aborting\n"); result = INSTALL_ERROR; } else { result = really_install_package(path, wipe_cache, needs_mount, is_ru_pkg); } if (install_log) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); fclose(install_log); } #ifdef USE_BOARD_ID if(gIfBoardIdCustom) { ensure_path_mounted("/cust"); ensure_path_mounted("/system"); D("to custom system_partition for board_id"); custom(); } #endif #ifdef USE_RADICAL_UPDATE if ( is_ru_pkg ) { I("installed a ru_pkg, to apply radical_update to system_partition."); if ( 0 != ensure_path_mounted(RU_PARTITION_MOUNT_PATH) ) { SET_ERROR_AND_JUMP("fail to mount ru_partition.", ret, INSTALL_ERROR, EXIT); } if ( 0 != ensure_path_mounted(SYSTEM_PARTITION_MOUNT_PATH) ) { SET_ERROR_AND_JUMP("fail to mount system_partition.", ret, INSTALL_ERROR, EXIT); } if ( 0 != RadicalUpdate_tryToApplyRadicalUpdate() ) { SET_ERROR_AND_JUMP("fail to apply radical_update.", ret, INSTALL_ERROR, EXIT); } D("to delete ru_pkg '%s' after being applied.", path); unlink(path); if ( 0 != ensure_path_unmounted(RU_PARTITION_MOUNT_PATH) ) { SET_ERROR_AND_JUMP("fail to unmount ru_partition.", ret, INSTALL_ERROR, EXIT); } if ( 0 != ensure_path_unmounted(SYSTEM_PARTITION_MOUNT_PATH) ) { SET_ERROR_AND_JUMP("fail to unmount system_partition.", ret, INSTALL_ERROR, EXIT); } } else { I("installed an original_ota_pkg, " "do not apply radical_update to system_partition, " "there might be incompatibility between modules in ru_ver and ota_ver."); } #endif EXIT: return result; }