/* Installing the package. */ static int install () { int status; const char *path, *optionstr, *store_client_id; assert (pi); path = pkgmgr_installer_get_request_info (pi); optionstr = pkgmgr_installer_get_optional_data (pi); store_client_id = pkgmgr_installer_get_caller_pkgid (pi); status = options_parse (&options, optionstr ? optionstr : ""); if (status) return errno; if (!options.package_id) { options.package_id = get_package_id_from_package_path (path); if (options.package_id == NULL) return ENOMEM; } /* TODO */ status = step_run (install_steps, sizeof install_steps / sizeof * install_steps); return 0; }
int main(int argc, char **argv) { int ret = 0; pkgmgr_installer *pi = pkgmgr_installer_new(); _pi = pi; pkgmgr_installer_receive_request(pi, argc, argv); int req_type = pkgmgr_installer_get_request_type(pi); if (PKGMGR_REQ_INVALID >= req_type) return EINVAL; const char *pkg_info = pkgmgr_installer_get_request_info(pi); switch (req_type) { case PKGMGR_REQ_INSTALL: ret = __install_package(pkg_info); break; case PKGMGR_REQ_UNINSTALL: ret = __uninstall_package(pkg_info); break; case PKGMGR_REQ_CLEAR: ret = __clear_package(pkg_info); break; case PKGMGR_REQ_RECOVER: ret = __recover_package_system(); break; default: ret = EINVAL; } return ret; }
int _ri_parse_cmdline(int argc, char **argv, ri_frontend_cmdline_arg *data) { int req_cmd = INVALID_CMD; const char *pkg_name = NULL; int quiet = 0; const char *pkeyid = NULL; int ret = 0; pi = pkgmgr_installer_new(); if (!pi) { _d_msg(DEBUG_ERR, "Failure in creating the pkgmgr_installer object \n"); return RPM_INSTALLER_ERR_WRONG_PARAM; } ret = pkgmgr_installer_receive_request(pi, argc, argv); if (ret) { _d_msg(DEBUG_ERR, "pkgmgr_installer_receive_request failed \n"); return RPM_INSTALLER_ERR_WRONG_PARAM; } ret = pkgmgr_installer_get_request_type(pi); switch (ret) { case PKGMGR_REQ_INSTALL: req_cmd = INSTALL_CMD; break; case PKGMGR_REQ_UNINSTALL: req_cmd = DELETE_CMD; break; case PKGMGR_REQ_RECOVER: req_cmd = RECOVER_CMD; break; case PKGMGR_REQ_CLEAR: req_cmd = CLEARDATA_CMD; break; case PKGMGR_REQ_PERM: goto PARSEERROR; case PKGMGR_REQ_INVALID: req_cmd = INVALID_CMD; goto PARSEERROR; default: goto PARSEERROR; } if (req_cmd != RECOVER_CMD) { pkg_name = pkgmgr_installer_get_request_info(pi); if (!pkg_name) { _d_msg(DEBUG_ERR, "pkgmgr_installer_get_request_info failed \n"); return RPM_INSTALLER_ERR_WRONG_PARAM; } pkeyid = pkgmgr_installer_get_session_id(pi); if (!pkeyid) { _d_msg(DEBUG_ERR, "pkgmgr_installer_get_session_id failed \n"); return RPM_INSTALLER_ERR_WRONG_PARAM; } quiet = pkgmgr_installer_is_quiet(pi); if (quiet != 0 && quiet != 1) { _d_msg(DEBUG_ERR, "pkgmgr_installer_is_quiet failed \n"); return RPM_INSTALLER_ERR_WRONG_PARAM; } } if (req_cmd != INSTALL_CMD && req_cmd != DELETE_CMD && req_cmd != RECOVER_CMD && req_cmd != CLEARDATA_CMD) { _d_msg(DEBUG_ERR, "invalid command \n"); goto PARSEERROR; } data->req_cmd = req_cmd; data->pkg_name = (char *)pkg_name; data->quiet = quiet; data->keyid = (char *)pkeyid; return RPM_INSTALLER_SUCCESS; PARSEERROR: _d_msg(DEBUG_ERR, "Error in parsing input parameter\n"); __ri_show_usage(argv); return RPM_INSTALLER_ERR_WRONG_PARAM; }