COPKGManager: use installPackage() for install from package list too

installPackage() has also a new parameter for options,
in this case is --force-reinstall in use.
This commit is contained in:
2015-01-31 21:55:01 +01:00
parent 55a027efbf
commit 14d21fdeec
2 changed files with 17 additions and 22 deletions

View File

@@ -5,7 +5,7 @@
OPKG-Manager Class for Neutrino-GUI OPKG-Manager Class for Neutrino-GUI
Implementation: Implementation:
Copyright (C) 2012-2014 T. Graf 'dbt' Copyright (C) 2012-2015 T. Graf 'dbt'
www.dbox2-tuning.net www.dbox2-tuning.net
Adaptions: Adaptions:
@@ -189,17 +189,8 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey)
force = "--force-reinstall "; force = "--force-reinstall ";
} }
//check package size...cancel installation if size check failed //install package with size check ...cancel installation if check failed
if (!checkSize(actionKey)){ installPackage(actionKey, force);
DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR));
}
else{
int r = execCmd(pkg_types[OM_INSTALL] + force + actionKey, true, true);
if (r)
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_types[OM_INSTALL] + force + actionKey);
else
installed = true;
}
refreshMenu(); refreshMenu();
} }
@@ -709,17 +700,21 @@ void COPKGManager::showError(const char* local_msg, char* err_message, const str
DisplayErrorMessage(msg.c_str()); DisplayErrorMessage(msg.c_str());
} }
bool COPKGManager::installPackage(const std::string& pkg_name) bool COPKGManager::installPackage(const string& pkg_name, string options)
{ {
int r = execCmd(pkg_types[OM_INSTALL] + pkg_name, true, true); //check package size...cancel installation if size check failed
if (!checkSize(pkg_name)){
if (r){ DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR));
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] error[%d]: %s\n", __func__, __LINE__, errno, strerror(errno)); }
// showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_name); else{
return false; string opts = " " + options + " ";
int r = execCmd(pkg_types[OM_INSTALL] + opts + pkg_name, true, true);
if (r)
showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), pkg_types[OM_INSTALL] + opts + pkg_name);
else
installed = true;
} }
else
installed = true;
return true; return true;
} }

View File

@@ -109,7 +109,7 @@ class COPKGManager : public CMenuTarget
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
static bool hasOpkgSupport(); static bool hasOpkgSupport();
bool checkUpdates(const std::string & package_name = std::string(), bool show_progress = true); bool checkUpdates(const std::string & package_name = std::string(), bool show_progress = true);
bool installPackage(const std::string& pkg_name); bool installPackage(const std::string& pkg_name, std::string options = std::string());
bool checkSize(const std::string& pkg_name); bool checkSize(const std::string& pkg_name);
}; };
#endif #endif