diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-18 16:39:10 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-18 16:39:10 +0100 |
| commit | d2ce308082886c50d0ef47efa5a277370603fac1 (patch) | |
| tree | 616fbd3d84e81c2a50cad68bab5f6538b683492c /apt-pkg/contrib | |
| parent | f82dcd7e4ebb3f70d28e9feb3621676f8c0cc024 (diff) | |
| parent | 815d5b01bf9be1d476b110050b20ae980c76d4a8 (diff) | |
Merge branch 'solver3'
Diffstat (limited to 'apt-pkg/contrib')
| -rw-r--r-- | apt-pkg/contrib/configuration.cc | 33 | ||||
| -rw-r--r-- | apt-pkg/contrib/configuration.h | 3 |
2 files changed, 36 insertions, 0 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 28cf3e480..cf72aa3d7 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -1226,3 +1226,36 @@ bool Configuration::MatchAgainstConfig::Match(char const * str) const return false; } /*}}}*/ +// helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/ +static bool ConfigValueInSubTree(Configuration *config, const char *SubTree, std::string_view const needle) +{ + if (needle.empty()) + return false; + Configuration::Item const *Opts = config->Tree(SubTree); + if (Opts != nullptr && Opts->Child != nullptr) + { + Opts = Opts->Child; + for (; Opts != nullptr; Opts = Opts->Next) + { + if (Opts->Value.empty()) + continue; + if (needle == Opts->Value) + return true; + } + } + return false; +} +bool Configuration::SectionInSubTree(char const *const SubTree, std::string_view Needle) +{ + if (ConfigValueInSubTree(this, SubTree, Needle)) + return true; + auto const sub = Needle.rfind('/'); + if (sub == std::string_view::npos) + { + std::string special{"/"}; + special.append(Needle); + return ConfigValueInSubTree(this, SubTree, special); + } + return ConfigValueInSubTree(this, SubTree, Needle.substr(sub + 1)); +} + /*}}}*/ diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 4a21d977b..30a1cbf43 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -117,6 +117,9 @@ class APT_PUBLIC Configuration void Dump(std::ostream& str, char const * const root, char const * const format, bool const emptyValue); +#ifdef APT_COMPILING_APT + bool SectionInSubTree(char const *const SubTree, std::string_view Needle); +#endif explicit Configuration(const Item *Root); Configuration(); ~Configuration(); |
