COPKGManager: add possibility to manage source feeds for packages

Feeds are saved in opkg config file.

NOTE:Existing config file will be overwrite, so must be reconfigured
via gui.
Source names are strictly numbered src 0...10 (maximmal 10 at the moment)

FIXME: input mask in keyboardinput class is too small for some adresses, large
address names are cutted and makes entries useless
This commit is contained in:
2015-02-04 11:12:18 +01:00
parent ee56b75567
commit aad5db705f
7 changed files with 123 additions and 10 deletions

View File

@@ -1196,6 +1196,7 @@ menu.hint_next Weiter zum nächsten Menü.\nDie Taste 'Menü' schließt alle Men
menu.hint_next_brief Weiter zum nächsten Menü
menu.hint_numeric_adjust Bei numerischer Programmwahl die Kanalliste am neu gewählten Programm ausrichten
menu.hint_opkg Software-Pakete installieren oder vorhandene aktualisieren
menu.hint_opkg_feed_address_edit Bearbeiten von Feed-Adressen
menu.hint_opkg_install_local_package Paket von USB-Stick, SD, Freigabe oder lokalem Ordner installieren.
menu.hint_opkg_upgrade Aktualisiert alle installierten Pakete auf die neueste verfügbare Version
menu.hint_osd Farben, Schriftarten, Anzeigegröße, Ansichtsoptionen der Menüs und mehr
@@ -1862,9 +1863,12 @@ opkg.button.expert_on Experten-Modus
opkg.button.info Paket-Informationen
opkg.button.install Paket installieren
opkg.button.uninstall Paket entfernen
opkg.enter.feed.address Bitte Adresse für Server-Feed oder lokalen Ordner eintragen!
opkg.enter.feed.address.example Beispiel: http://pkg.nevis.neutrino-hd.com
opkg.failure.install Installation fehlgeschlagen
opkg.failure.update Update fehlgeschlagen
opkg.failure.upgrade Upgrade fehlgeschlagen
opkg.feed.addresses Feed-Adressen
opkg.install.local.package Installiere lokales Paket
opkg.messagebox.reinstall %s erneut installieren?
opkg.messagebox.remove %s entfernen?

View File

@@ -1196,6 +1196,7 @@ menu.hint_next Continue to next menu\nPress menu key to close all menus
menu.hint_next_brief Continue to next menu
menu.hint_numeric_adjust Adjust channel list mode on numeric zap
menu.hint_opkg Install or update software packages
menu.hint_opkg_feed_address_edit Edit feed addresses
menu.hint_opkg_install_local_package Install package from USB, SD, share or local directory.
menu.hint_opkg_upgrade Updates all installed packages to the most recent version available
menu.hint_osd Colors, fonts, screen size\nGUI look and feel options
@@ -1863,9 +1864,12 @@ opkg.button.expert_on Expert mode
opkg.button.info Package information
opkg.button.install Install package
opkg.button.uninstall Uninstall package
opkg.enter.feed.address Please enter address for server, local folder or share!
opkg.enter.feed.address.example Example: http://pkg.nevis.neutrino-hd.com
opkg.failure.install Install failed
opkg.failure.update Update failed
opkg.failure.upgrade Upgrade failed
opkg.feed.addresses Feed addresses
opkg.install.local.package Install local package
opkg.messagebox.reinstall Re-install %s?
opkg.messagebox.remove Remove %s?

View File

@@ -1139,6 +1139,7 @@ menu.hint_network IP adres, gateway, DNS, Tijd synchronisatie\nNetwerklocaties e
menu.hint_new_zap_mode Schakelen van kanalen toestaan tijdens het browsen.\n(Schakelen tussen vensters met de 'Mute' toets)
menu.hint_numeric_adjust Pas zenderlijst modus aan na numerieke zap
menu.hint_opkg Installeer of update software pakketten
menu.hint_opkg_feed_address_edit Bewerk server adressen!
menu.hint_opkg_install_local_package Installatiepakket van USB, SD of netwerk.
menu.hint_opkg_upgrade Update alle geinstalleerde pakketten naar de meest recente beschikbare versie
menu.hint_osd Kleuren, Lettertypes, scherm afmeting\ngebruikersinterface vormgeving
@@ -1753,9 +1754,12 @@ opkg.button.expert_on Expert modus
opkg.button.info Pakket info
opkg.button.install Installeer pakket
opkg.button.uninstall Deinstaleer pakket
opkg.enter.feed.address Voer het adres van de server!
opkg.enter.feed.address.example Voorbeeld: http://pkg.nevis.neutrino-hd.com
opkg.failure.install installatie mislukt
opkg.failure.update Update mislukt
opkg.failure.upgrade Upgrade mislukt
opkg.feed.addresses Feed adressen
opkg.install.local.package Installeer lokale pakket
opkg.messagebox.reinstall Herinstalleer %s?
opkg.messagebox.remove Wissen%s?

View File

@@ -43,6 +43,7 @@
#include <gui/widget/messagebox.h>
#include <gui/widget/shellwindow.h>
#include <gui/widget/progresswindow.h>
#include <gui/widget/keyboard_input.h>
#include <driver/screen_max.h>
#include <gui/filebrowser.h>
#include <system/debug.h>
@@ -55,8 +56,11 @@
#include <errno.h>
/* later this can be changed to just "opkg" */
#define OPKG_CL "opkg-cl"
#define OPKG_CL_CONFIG_OPTIONS " -V2 --tmp-dir=/tmp --cache=/tmp/.opkg "
#define OPKG_TMP_DIR "/tmp/.opkg"
#define OPKG_CL_CONFIG_OPTIONS " -V2 --tmp-dir=/tmp --cache=" OPKG_TMP_DIR
#define OPKG_CONFIG_FILE "/etc/opkg/opkg.conf"
using namespace std;
@@ -87,15 +91,23 @@ static const string pkg_types[OM_MAX] =
OPKG_CL " status ",
};
COPKGManager::COPKGManager()
COPKGManager::COPKGManager(): opkg_conf('\t')
{
width = 80;
//define default dest keys
string dest_defaults[] = {"/", OPKG_TMP_DIR, "/mnt"};
for(size_t i=0; i<sizeof(dest_defaults)/sizeof(dest_defaults[0]) ;i++)
config_dest.push_back(dest_defaults[i]);
loadConfig();
pkg_map.clear();
list_installed_done = false;
list_upgradeable_done = false;
expert_mode = false;
local_dir = &g_settings.update_dir_opkg;
CFileHelpers::createDir(OPKG_TMP_DIR);
}
COPKGManager::~COPKGManager()
@@ -111,6 +123,7 @@ int COPKGManager::exec(CMenuTarget* parent, const string &actionKey)
if (parent)
parent->hide();
int ret = showMenu();
saveConfig();
CFileHelpers::removeDir(OPKG_TMP_DIR);
return ret;
}
@@ -403,10 +416,17 @@ int COPKGManager::showMenu()
menu->addItem(upgrade_forwarder);
//select and install local package
CMenuForwarder *local;
local = new CMenuForwarder(LOCALE_OPKG_INSTALL_LOCAL_PACKAGE, true, NULL, this, "local_package", CRCInput::RC_green);
local->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, LOCALE_MENU_HINT_OPKG_INSTALL_LOCAL_PACKAGE);
menu->addItem(local);
CMenuForwarder *fw;
fw = new CMenuForwarder(LOCALE_OPKG_INSTALL_LOCAL_PACKAGE, true, NULL, this, "local_package", CRCInput::RC_green);
fw->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, LOCALE_MENU_HINT_OPKG_INSTALL_LOCAL_PACKAGE);
menu->addItem(fw);
//feed setup
CMenuWidget feeds_menu(LOCALE_OPKG_TITLE, NEUTRINO_ICON_UPDATE, w_max (100, 10));
showMenuConfigFeed(&feeds_menu);
fw = new CMenuForwarder(LOCALE_OPKG_FEED_ADRESSES, true, NULL, &feeds_menu, NULL, CRCInput::RC_www);
fw->setHint(NEUTRINO_ICON_HINT_SW_UPDATE, LOCALE_MENU_HINT_OPKG_FEED_ADRESSES_EDIT);
menu->addItem(fw);
menu->addItem(GenericMenuSeparatorLine);
@@ -467,7 +487,7 @@ int COPKGManager::showMenu()
bool COPKGManager::hasOpkgSupport()
{
string deps[] = {"/etc/opkg/opkg.conf", "/var/lib/opkg"};
string deps[] = {"/bin/opkg-check-config", "/bin/update-alternatives", "/var/lib/opkg", "/share/opkg/intercept"};
if (find_executable(OPKG_CL).empty()) {
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d]" OPKG_CL " executable not found\n", __func__, __LINE__);
@@ -722,3 +742,67 @@ bool COPKGManager::installPackage(const string& pkg_name, string options)
return true;
}
void COPKGManager::showMenuConfigFeed(CMenuWidget *feed_menu)
{
feed_menu->addIntroItems(LOCALE_OPKG_FEED_ADRESSES);
for(size_t i=0; i<OPKG_MAX_FEEDS ;i++){
CKeyboardInput *feedinput = new CKeyboardInput("Feed " +to_string(i+1), &config_src[i], 0, NULL, NULL, LOCALE_OPKG_ENTER_FEED_ADDRESS, LOCALE_OPKG_ENTER_FEED_ADDRESS_EXAMPLE);
CMenuForwarder *fw = new CMenuDForwarder( string(), true , config_src[i], feedinput, NULL, CRCInput::convertDigitToKey(i));
feed_menu->addItem( fw);
}
}
void COPKGManager::loadConfig()
{
opkg_conf.clear();
bool load_defaults = false;
if (!opkg_conf.loadConfig(OPKG_CONFIG_FILE, '\t')){
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] Error: error while loading opkg config file! -> %s. Using default settings!\n", __func__, __LINE__, OPKG_CONFIG_FILE);
load_defaults = true;
}
//package feeds
for(size_t i=0; i<OPKG_MAX_FEEDS ;i++){
string src_key = "src " + to_string(i);
config_src[i] = opkg_conf.getString(src_key, string());
}
//dest dir default keys, predefined in constructor
for(size_t j=0; j<config_dest.size() ;j++){
string dest_key = "dest " + to_string(j);
opkg_conf.getString(dest_key, config_dest[j]);
}
//load default settings and write to config file
if (load_defaults)
saveConfig();
}
void COPKGManager::saveConfig()
{
//set package feeds
for(size_t i=0; i<OPKG_MAX_FEEDS ;i++){
string src_key = "src " + to_string(i);
if (!config_src[i].empty())
opkg_conf.setString(src_key, config_src[i]);
else
opkg_conf.deleteKey(src_key); //remove unused keys
}
//set dest dir default key values
for(size_t j=0; j<config_dest.size() ;j++){
string dest_key = "dest " + to_string(j);
opkg_conf.setString(dest_key, config_dest[j]);
}
//finally save config file
if (!opkg_conf.saveConfig(OPKG_CONFIG_FILE, '\t')){
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] Error: error while saving opkg config file! -> %s\n", __func__, __LINE__, OPKG_CONFIG_FILE);
DisplayErrorMessage("Error while saving opkg config file!");
}
}

View File

@@ -5,7 +5,7 @@
OPKG-Manager Class for Neutrino-GUI
Implementation:
Copyright (C) 2012 T. Graf 'dbt'
Copyright (C) 2012-2015 T. Graf 'dbt'
www.dbox2-tuning.net
Adaptions:
@@ -33,20 +33,28 @@
#include <gui/widget/menue.h>
#include <driver/framebuffer.h>
#include <configfile.h>
#include <string>
#include <vector>
#include <map>
#define OPKG_MAX_FEEDS 10
class COPKGManager : public CMenuTarget
{
private:
int width;
std::string tmp_str;
CFrameBuffer *frameBuffer;
CConfigFile opkg_conf;
void saveConfig();
void loadConfig();
struct pkg;
//config
std::string config_src[OPKG_MAX_FEEDS];
std::vector<std::string> config_dest;
std::map<std::string,pkg> pkg_map;
std::vector<pkg*> pkg_vec;
@@ -84,6 +92,7 @@ class COPKGManager : public CMenuTarget
std::string getKeyInfo(const std::string& input, const std::string& pkg_info_key, const std::string& delimiters);
int showMenu();
void showMenuConfigFeed(CMenuWidget *feed_menu);
void updateMenu();
void refreshMenu();
bool badpackage(std::string &s);

View File

@@ -1223,6 +1223,7 @@ typedef enum
LOCALE_MENU_HINT_NEXT_BRIEF,
LOCALE_MENU_HINT_NUMERIC_ADJUST,
LOCALE_MENU_HINT_OPKG,
LOCALE_MENU_HINT_OPKG_FEED_ADRESSES_EDIT,
LOCALE_MENU_HINT_OPKG_INSTALL_LOCAL_PACKAGE,
LOCALE_MENU_HINT_OPKG_UPGRADE,
LOCALE_MENU_HINT_OSD,
@@ -1889,9 +1890,12 @@ typedef enum
LOCALE_OPKG_BUTTON_INFO,
LOCALE_OPKG_BUTTON_INSTALL,
LOCALE_OPKG_BUTTON_UNINSTALL,
LOCALE_OPKG_ENTER_FEED_ADDRESS,
LOCALE_OPKG_ENTER_FEED_ADDRESS_EXAMPLE,
LOCALE_OPKG_FAILURE_INSTALL,
LOCALE_OPKG_FAILURE_UPDATE,
LOCALE_OPKG_FAILURE_UPGRADE,
LOCALE_OPKG_FEED_ADRESSES,
LOCALE_OPKG_INSTALL_LOCAL_PACKAGE,
LOCALE_OPKG_MESSAGEBOX_REINSTALL,
LOCALE_OPKG_MESSAGEBOX_REMOVE,

View File

@@ -1223,6 +1223,7 @@ const char * locale_real_names[] =
"menu.hint_next_brief",
"menu.hint_numeric_adjust",
"menu.hint_opkg",
"menu.hint_opkg_feed_address_edit",
"menu.hint_opkg_install_local_package",
"menu.hint_opkg_upgrade",
"menu.hint_osd",
@@ -1889,9 +1890,12 @@ const char * locale_real_names[] =
"opkg.button.info",
"opkg.button.install",
"opkg.button.uninstall",
"opkg.enter.feed.address",
"opkg.enter.feed.address.example",
"opkg.failure.install",
"opkg.failure.update",
"opkg.failure.upgrade",
"opkg.feed.addresses",
"opkg.install.local.package",
"opkg.messagebox.reinstall",
"opkg.messagebox.remove",