mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
COPKGManager: use config file for bad package detection
To detect bad packages, it must be existing a matching pattern list file. Path is defined in OPKG_BAD_PATTERN_LIST_FILE. This gives the option to filter some bad entries in the package listing menue. NOTE: a sample file you should find here as : "/var/tuxbox/config/bad_package_pattern.list.sample". If required, remove the ".sample" extension and change the entries for your requirements
This commit is contained in:
@@ -5,7 +5,7 @@ SUBDIRS += lcd
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
configdir = $(CONFIGDIR)
|
configdir = $(CONFIGDIR)
|
||||||
config_DATA = cables.xml satellites.xml encoding.conf tobackup.conf providermap.xml settingsupdate.conf terrestrial.xml
|
config_DATA = cables.xml satellites.xml encoding.conf tobackup.conf providermap.xml settingsupdate.conf terrestrial.xml bad_package_pattern.list.sample
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
$(INSTALL) -d $(DESTDIR)/$(CONFIGDIR)/zapit
|
$(INSTALL) -d $(DESTDIR)/$(CONFIGDIR)/zapit
|
||||||
|
11
data/bad_package_pattern.list.sample
Normal file
11
data/bad_package_pattern.list.sample
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-dev$
|
||||||
|
-doc$
|
||||||
|
-dbg$
|
||||||
|
-ptest$
|
||||||
|
-staticdev$
|
||||||
|
-locale-
|
||||||
|
-charmap-
|
||||||
|
-gconv-
|
||||||
|
-localedata-
|
||||||
|
^locale-base-
|
||||||
|
^perl-module-
|
@@ -55,13 +55,14 @@
|
|||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#define OPKG_CL "opkg"
|
#define OPKG_CL "opkg"
|
||||||
#define OPKG_TMP_DIR "/tmp/.opkg"
|
#define OPKG_TMP_DIR "/tmp/.opkg"
|
||||||
#define OPKG_TEST_DIR OPKG_TMP_DIR "/test"
|
#define OPKG_TEST_DIR OPKG_TMP_DIR "/test"
|
||||||
#define OPKG_CL_CONFIG_OPTIONS " -V2 --tmp-dir=/tmp --cache=" OPKG_TMP_DIR
|
#define OPKG_CL_CONFIG_OPTIONS " -V2 --tmp-dir=/tmp --cache=" OPKG_TMP_DIR
|
||||||
|
|
||||||
|
#define OPKG_BAD_PATTERN_LIST_FILE "/var/tuxbox/config/bad_package_pattern.list"
|
||||||
#define OPKG_CONFIG_FILE "/etc/opkg/opkg.conf"
|
#define OPKG_CONFIG_FILE "/etc/opkg/opkg.conf"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -113,8 +114,8 @@ COPKGManager::COPKGManager(): opkg_conf('\t')
|
|||||||
list_upgradeable_done = false;
|
list_upgradeable_done = false;
|
||||||
expert_mode = false;
|
expert_mode = false;
|
||||||
local_dir = &g_settings.update_dir_opkg;
|
local_dir = &g_settings.update_dir_opkg;
|
||||||
|
v_bad_pattern = getBadPackagePatternList();
|
||||||
CFileHelpers::createDir(OPKG_TMP_DIR);
|
CFileHelpers::createDir(OPKG_TMP_DIR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COPKGManager::~COPKGManager()
|
COPKGManager::~COPKGManager()
|
||||||
@@ -305,29 +306,38 @@ static const struct button_label COPKGManagerFooterButtonsExpert[COPKGManagerFoo
|
|||||||
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_OPKG_BUTTON_UNINSTALL }
|
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_OPKG_BUTTON_UNINSTALL }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO: this should go into a config file... */
|
vector<string> COPKGManager::getBadPackagePatternList()
|
||||||
static std::string bad_pattern[] = {
|
{
|
||||||
"-dev$",
|
vector<string> v_ret;
|
||||||
"-doc$",
|
|
||||||
"-dbg$",
|
ifstream in (OPKG_BAD_PATTERN_LIST_FILE, ios::in);
|
||||||
"-ptest$",
|
if (!in){
|
||||||
"-staticdev$",
|
dprintf(DEBUG_NORMAL, "[COPKGManager] [%s - %d] can't open %s, %s\n", __func__, __LINE__, OPKG_BAD_PATTERN_LIST_FILE, strerror(errno));
|
||||||
"-locale-",
|
return v_ret;
|
||||||
"-charmap-",
|
}
|
||||||
"-gconv-",
|
string line;
|
||||||
"-localedata-",
|
|
||||||
"^locale-base-",
|
while(getline(in, line)){
|
||||||
"^perl-module-",
|
v_ret.push_back(line);
|
||||||
""
|
}
|
||||||
};
|
in.close();
|
||||||
|
|
||||||
|
return v_ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool COPKGManager::badpackage(std::string &s)
|
bool COPKGManager::badpackage(std::string &s)
|
||||||
{
|
{
|
||||||
int i;
|
if(v_bad_pattern.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t i;
|
||||||
string st = "";
|
string st = "";
|
||||||
for (i = 0; !bad_pattern[i].empty(); i++)
|
for (i = 0; i < v_bad_pattern.size(); i++)
|
||||||
{
|
{
|
||||||
string p = bad_pattern[i];
|
string p = v_bad_pattern[i];
|
||||||
|
if (p.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
size_t patlen = p.length() - 1;
|
size_t patlen = p.length() - 1;
|
||||||
bool res = false;
|
bool res = false;
|
||||||
/* poor man's regex :-) only supported are "^" and "$" */
|
/* poor man's regex :-) only supported are "^" and "$" */
|
||||||
|
@@ -56,6 +56,9 @@ class COPKGManager : public CMenuTarget
|
|||||||
std::string config_src[OPKG_MAX_FEEDS];
|
std::string config_src[OPKG_MAX_FEEDS];
|
||||||
std::vector<std::string> config_dest;
|
std::vector<std::string> config_dest;
|
||||||
|
|
||||||
|
//filter
|
||||||
|
std::vector<std::string> v_bad_pattern;
|
||||||
|
|
||||||
std::map<std::string,pkg> pkg_map;
|
std::map<std::string,pkg> pkg_map;
|
||||||
std::vector<pkg*> pkg_vec;
|
std::vector<pkg*> pkg_vec;
|
||||||
|
|
||||||
@@ -107,7 +110,7 @@ class COPKGManager : public CMenuTarget
|
|||||||
bool isInstalled(const std::string& pkg_name);
|
bool isInstalled(const std::string& pkg_name);
|
||||||
bool isUpgradable(const std::string& pkg_name);
|
bool isUpgradable(const std::string& pkg_name);
|
||||||
|
|
||||||
/*
|
/*!
|
||||||
* Gets an info from opkg command info or status from a package via keywords as std::string
|
* Gets an info from opkg command info or status from a package via keywords as std::string
|
||||||
* 1st parameter is name of package as string eg. "gdb", without file extension or version data
|
* 1st parameter is name of package as string eg. "gdb", without file extension or version data
|
||||||
* 2nd parameter needs a keyword like:
|
* 2nd parameter needs a keyword like:
|
||||||
@@ -125,7 +128,25 @@ class COPKGManager : public CMenuTarget
|
|||||||
void showMenuConfigFeed(CMenuWidget *feed_menu);
|
void showMenuConfigFeed(CMenuWidget *feed_menu);
|
||||||
void updateMenu();
|
void updateMenu();
|
||||||
void refreshMenu();
|
void refreshMenu();
|
||||||
|
|
||||||
|
//!Returns a vector with possible filter entries from OPKG_BAD_PATTERN_LIST_FILE
|
||||||
|
static std::vector<std::string> getBadPackagePatternList();
|
||||||
|
/*!
|
||||||
|
* Returns true if found a ''bad'' package, Parameter: package name as std::string by rev
|
||||||
|
* To detect bad packages, it must be exist a matching pattern list file.
|
||||||
|
* Path is defined in OPKG_BAD_PATTERN_LIST_FILE.
|
||||||
|
* This provides the option to filter some unwanted entries in the package list menue.
|
||||||
|
* This makes sense eg. to hinder that the user could change important system packages.
|
||||||
|
* NOTE: a sample file you should find here as : "/var/tuxbox/config/bad_package_pattern.list.sample"
|
||||||
|
* If required, remove the ".sample" extension and change the entries for your requirements
|
||||||
|
* howto: a simple way to filter a package is to add the pure name, if you want
|
||||||
|
* to hide a package (even which name) then add this name to a line. Eg. if you want to hide
|
||||||
|
* package wget then add this and this package is not displayed at the gui.
|
||||||
|
* Also a few place holders should work, see the badpackage() function, but this
|
||||||
|
* can be inaccurately because it could filter innocent packages.
|
||||||
|
*/
|
||||||
bool badpackage(std::string &s);
|
bool badpackage(std::string &s);
|
||||||
|
|
||||||
void showError(const char* local_msg, char* err_msg = NULL, const std::string& additional_text = std::string());
|
void showError(const char* local_msg, char* err_msg = NULL, const std::string& additional_text = std::string());
|
||||||
int doUpdate();
|
int doUpdate();
|
||||||
void handleShellOutput(std::string* cur_line, int* res, bool* ok);
|
void handleShellOutput(std::string* cur_line, int* res, bool* ok);
|
||||||
|
Reference in New Issue
Block a user