opkg_manager: add a list of packages to hide

Advanced build system can come up with an impressive list of
(sub-)packages, most of them not really interesting for installation
through the GUI. Add a filter with simple patterns to suppress the
display of those packages.
TODO: this should be made configurable via a run-time config file.

Signed-off-by: Markus Volk <f_l_k@gmx.net>
This commit is contained in:
Stefan Seyfried
2015-02-08 11:24:49 +01:00
committed by Thilo Graf
parent 47b37d4405
commit 5750ca23ae
2 changed files with 45 additions and 0 deletions

View File

@@ -187,12 +187,52 @@ static const struct button_label COPKGManagerFooterButtonsExpert[COPKGManagerFoo
{ NEUTRINO_ICON_BUTTON_BLUE, LOCALE_OPKG_BUTTON_UNINSTALL }
};
/* TODO: this should go into a config file... */
static std::string bad_pattern[] = {
"-dev$",
"-doc$",
"-dbg$",
"-ptest$",
"-staticdev$",
"-locale-",
"-charmap-",
"-gconv-",
"-localedata-",
"^locale-base-",
"^perl-module-",
""
};
bool COPKGManager::badpackage(std::string &s)
{
int i;
for (i = 0; !bad_pattern[i].empty(); i++)
{
std::string p = bad_pattern[i];
size_t patlen = p.length() - 1;
/* poor man's regex :-) only supported are "^" and "$" */
if (p.substr(patlen, 1) == "$") { /* match at end */
if (s.rfind(p.substr(0, patlen)) == (s.length() - patlen))
return true;
} else if (p.substr(0, 1) == "^") { /* match at beginning */
if (s.find(p.substr(1)) == 0)
return true;
} else { /* match everywhere */
if (s.find(p) != std::string::npos)
return true;
}
}
return false;
}
void COPKGManager::updateMenu()
{
bool upgradesAvailable = false;
getPkgData(OM_LIST_INSTALLED);
getPkgData(OM_LIST_UPGRADEABLE);
for (std::map<string, struct pkg>::iterator it = pkg_map.begin(); it != pkg_map.end(); it++) {
if (badpackage(it->second.name))
continue;
it->second.forwarder->iconName_Info_right = "";
it->second.forwarder->setActive(true);
if (it->second.upgradable) {
@@ -249,6 +289,8 @@ int COPKGManager::showMenu()
pkg_vec.clear();
for (std::map<string, struct pkg>::iterator it = pkg_map.begin(); it != pkg_map.end(); it++) {
if (badpackage(it->second.name))
continue;
it->second.forwarder = new CMenuForwarder(it->second.desc, true, NULL , this, it->second.name.c_str());
it->second.forwarder->setHint("", it->second.desc);
menu->addItem(it->second.forwarder);
@@ -322,6 +364,8 @@ void COPKGManager::getPkgData(const int pkg_content_id)
while (fgets(buf, sizeof(buf), f))
{
if (buf[0] == ' ')
continue; /* second, third, ... line of description will not be shown anyway */
std::string line(buf);
trim(line);