From c9833c2f931290ae30ad991b91f54b65fa44c428 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 8 Feb 2015 11:24:49 +0100 Subject: [PATCH] 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 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5750ca23ae5516dc3c9a142e2b032356b890703b Author: Stefan Seyfried Date: 2015-02-08 (Sun, 08 Feb 2015) ------------------ This commit was generated by Migit --- src/gui/opkg_manager.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ src/gui/opkg_manager.h | 1 + 2 files changed, 45 insertions(+) diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index 959dca1c0..f569ea16a 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -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::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::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); diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index 26e89afcb..c5f014ea5 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -67,6 +67,7 @@ class COPKGManager : public CMenuTarget int showMenu(); void updateMenu(); void refreshMenu(); + bool badpackage(std::string &s); struct pkg { std::string name;