From 14d21fdeec5392efb10b65331195418222252f10 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 31 Jan 2015 21:55:01 +0100 Subject: [PATCH] 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. --- src/gui/opkg_manager.cpp | 37 ++++++++++++++++--------------------- src/gui/opkg_manager.h | 2 +- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 36afb9e5f..1a966e4cf 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -5,7 +5,7 @@ OPKG-Manager Class for Neutrino-GUI Implementation: - Copyright (C) 2012-2014 T. Graf 'dbt' + Copyright (C) 2012-2015 T. Graf 'dbt' www.dbox2-tuning.net Adaptions: @@ -189,17 +189,8 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) force = "--force-reinstall "; } - //check package size...cancel installation if size check failed - if (!checkSize(actionKey)){ - 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; - } + //install package with size check ...cancel installation if check failed + installPackage(actionKey, force); refreshMenu(); } @@ -709,17 +700,21 @@ void COPKGManager::showError(const char* local_msg, char* err_message, const 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); - - if (r){ - 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); - return false; + //check package size...cancel installation if size check failed + if (!checkSize(pkg_name)){ + DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR)); + } + else{ + 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; } diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index 91d053bc7..3a659f6ca 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -109,7 +109,7 @@ class COPKGManager : public CMenuTarget int exec(CMenuTarget* parent, const std::string & actionKey); static bool hasOpkgSupport(); 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); }; #endif