diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 03e18de81..04dcbfb44 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1867,6 +1867,7 @@ opkg.failure.upgrade Upgrade fehlgeschlagen opkg.install.local.package Installiere lokales Paket opkg.messagebox.reinstall %s erneut installieren? opkg.messagebox.remove %s entfernen? +opkg.messagebox.size.error Nicht genügend freier Speicher für Paketinstallation verfügbar! opkg.messagebox.updates.available Aktualisierungen verfügbar! opkg.success.install Installation erfolgreich, Neustart von Neutrino kann erforderlich sein. opkg.title Paketverwaltung diff --git a/data/locale/english.locale b/data/locale/english.locale index 3e69ab85c..c44c45a55 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1867,6 +1867,7 @@ opkg.failure.upgrade Upgrade failed opkg.install.local.package Install local package opkg.messagebox.reinstall Re-install %s? opkg.messagebox.remove Remove %s? +opkg.messagebox.size.error Not enough free memory available for this package! opkg.messagebox.updates.available Updates available! opkg.success.install Install successful, restart of Neutrino might be required. opkg.title Package Management diff --git a/data/locale/nederlands.locale b/data/locale/nederlands.locale index b14414176..b367c67a8 100644 --- a/data/locale/nederlands.locale +++ b/data/locale/nederlands.locale @@ -1758,6 +1758,7 @@ opkg.failure.upgrade Upgrade mislukt opkg.install.local.package Installeer lokale pakket opkg.messagebox.reinstall Herinstalleer %s? opkg.messagebox.remove Wissen%s? +opkg.messagebox.size.error Onvoldoende geheugen beschikbaar voor dit pakket! opkg.messagebox.updates.available Updates beschikbare! opkg.success.install installatie succesvol, herstart van Neutrino mogelijk vereist. opkg.title Pakket management diff --git a/data/locale/slovak.locale b/data/locale/slovak.locale index 2ae778458..39f56a2f1 100644 --- a/data/locale/slovak.locale +++ b/data/locale/slovak.locale @@ -1848,6 +1848,7 @@ opkg.failure.upgrade Upgrade zlyhalo opkg.install.local.package Nainštalujte miestne balíček opkg.messagebox.reinstall Preinštalovať %s? opkg.messagebox.remove Odstrániť %s? +opkg.messagebox.size.error Nie je dostatok voľnej pamäte pre tento balík! opkg.messagebox.updates.available Aktualizácia k dispozícii! opkg.success.install Inštalácia v poriadku, reštart Neutrina bude žiadúci. opkg.title Správa balíčkov diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index fc2407b95..3044d8295 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -48,7 +48,7 @@ #include #include #include - +#include #include #include #include @@ -190,12 +190,38 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey) return res; force = "--force-reinstall "; } - 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; + //get package size + string s_pkgsize = getPkgInfo(actionKey, "Size"); + std::istringstream s(s_pkgsize); + u_int64_t pkg_size; + s >> pkg_size; + + //get available size + //TODO: Check writability! + struct statfs root_fs; + statfs("/",&root_fs); + u_int64_t free_size = root_fs.f_bfree*root_fs.f_bsize; + dprintf(DEBUG_INFO, "[COPKGManager] [%s - %d] Package: %s [package size=%lld (free size: %lld)]\n", __func__, __LINE__, actionKey.c_str(), pkg_size, free_size); + + //only for sure, it's more secure for users to abort installation if is available size too small + //TODO: Package size is not really the same like required/recommended size, because of unknown compression factor, some possible options like cache, different tmp-dir size eg. are still not considered. + u_int64_t rec_size = pkg_size/2*3; + if (free_size < rec_size){ + dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] WARNING: size check freesize=%lld required size=%lld (recommended: %lld)\n", __func__, __LINE__, free_size, pkg_size, rec_size); + DisplayErrorMessage(g_Locale->getText(LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR)); + }else{ + string cmd = pkg_types[OM_INSTALL] + force + actionKey; + int r = execCmd(cmd, true, true); + string cur_version = getPkgInfo(actionKey, "Version"); + dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] %s: current version = %s\n", __func__, __LINE__, actionKey.c_str(), cur_version.c_str()); + if (r){ + showError(g_Locale->getText(LOCALE_OPKG_FAILURE_INSTALL), strerror(errno), cmd); + }else{ + installed = true; + } + } + refreshMenu(); } return res; diff --git a/src/system/locals.h b/src/system/locals.h index 559fc58de..3b2d2c74e 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1894,6 +1894,7 @@ typedef enum LOCALE_OPKG_INSTALL_LOCAL_PACKAGE, LOCALE_OPKG_MESSAGEBOX_REINSTALL, LOCALE_OPKG_MESSAGEBOX_REMOVE, + LOCALE_OPKG_MESSAGEBOX_SIZE_ERROR, LOCALE_OPKG_MESSAGEBOX_UPDATES_AVAILABLE, LOCALE_OPKG_SUCCESS_INSTALL, LOCALE_OPKG_TITLE, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 7fe25c9b0..e1a2c2de0 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1894,6 +1894,7 @@ const char * locale_real_names[] = "opkg.install.local.package", "opkg.messagebox.reinstall", "opkg.messagebox.remove", + "opkg.messagebox.size.error", "opkg.messagebox.updates.available", "opkg.success.install", "opkg.title",