mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
COPKGManager: add possibilty to check required size before install package
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -48,7 +48,7 @@
|
||||
#include <system/debug.h>
|
||||
#include <system/helpers.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/vfs.h>
|
||||
#include <poll.h>
|
||||
#include <fcntl.h>
|
||||
#include <alloca.h>
|
||||
@@ -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
|
||||
//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;
|
||||
|
@@ -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,
|
||||
|
@@ -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",
|
||||
|
Reference in New Issue
Block a user