diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-17 21:33:30 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-18 10:56:45 +0100 |
| commit | e8b240eb3aab7e2584e245f03700ede30a3fc23a (patch) | |
| tree | 4f191f0a9b367adfdbd5bb011c3048486dee1a7a /cmdline/apt-mark.cc | |
| parent | f82dcd7e4ebb3f70d28e9feb3621676f8c0cc024 (diff) | |
refactor: Deduplicate and Move SectionInSubTree to Configuration
Deduplicate the copies in a central one, mark it unavailable to
external users.
Diffstat (limited to 'cmdline/apt-mark.cc')
| -rw-r--r-- | cmdline/apt-mark.cc | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 33716bb3c..180247cd0 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -139,40 +139,6 @@ static bool DoMarkAuto(CommandLine &CmdL) return true; } /*}}}*/ -// helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/ -// FIXME: Copied verbatim from apt-pkg/depcache.cc -static bool ConfigValueInSubTree(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; -} -static bool SectionInSubTree(char const * const SubTree, std::string_view Needle) -{ - if (ConfigValueInSubTree(SubTree, Needle)) - return true; - auto const sub = Needle.rfind('/'); - if (sub == std::string_view::npos) - { - std::string special{"/"}; - special.append(Needle); - return ConfigValueInSubTree(SubTree, special); - } - return ConfigValueInSubTree(SubTree, Needle.substr(sub + 1)); -} - /*}}}*/ /* DoMinimize - minimize manually installed {{{*/ /* Traverses dependencies of meta packages and marks them as manually * installed. */ @@ -192,7 +158,7 @@ static bool DoMinimize(CommandLine &CmdL) auto ver = pkg.CurrentVer(); return ver.end() == false && ((*DepCache)[pkg].Flags & pkgCache::Flag::Auto) == 0 && ver->Section != 0 && - SectionInSubTree("APT::Never-MarkAuto-Sections", ver.Section()); + _config->SectionInSubTree("APT::Never-MarkAuto-Sections", ver.Section()); }; APT::PackageSet roots; |
