summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/contrib/configuration.cc33
-rw-r--r--apt-pkg/contrib/configuration.h3
-rw-r--r--apt-pkg/depcache.cc42
-rw-r--r--cmdline/apt-mark.cc36
4 files changed, 41 insertions, 73 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();
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index b66f2bc66..970b4c01d 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -68,40 +68,6 @@ class DefaultRootSetFunc2 : public pkgDepCache::DefaultRootSetFunc
};
/*}}}*/
-// helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/
-// FIXME: Has verbatim copy in cmdline/apt-mark.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));
-}
- /*}}}*/
pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) : /*{{{*/
d(NULL), cache(cache), released(false)
{
@@ -1068,7 +1034,7 @@ bool pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge,
// We do not check for or-groups here as we don't know which package takes care of
// providing the feature the user likes e.g.: browser1 | browser2 | browser3
// Temporary removals are effected by this as well, which is bad, but unlikely in practice
- bool const PinNeverMarkAutoSection = (PV->Section != 0 && SectionInSubTree("APT::Never-MarkAuto-Sections", PV.Section()));
+ bool const PinNeverMarkAutoSection = (PV->Section != 0 && _config->SectionInSubTree("APT::Never-MarkAuto-Sections", PV.Section()));
if (PinNeverMarkAutoSection)
{
for (DepIterator D = PV.DependsList(); D.end() != true; ++D)
@@ -1782,8 +1748,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst,
VerIterator const CurVer = Pkg.CurrentVer();
if (not CurVer.end() && CurVer->Section != 0 && strcmp(CurVer.Section(), PV.Section()) != 0)
{
- bool const CurVerInMoveSection = SectionInSubTree("APT::Move-Autobit-Sections", CurVer.Section());
- bool const InstVerInMoveSection = SectionInSubTree("APT::Move-Autobit-Sections", PV.Section());
+ bool const CurVerInMoveSection = _config->SectionInSubTree("APT::Move-Autobit-Sections", CurVer.Section());
+ bool const InstVerInMoveSection = _config->SectionInSubTree("APT::Move-Autobit-Sections", PV.Section());
return (not CurVerInMoveSection && InstVerInMoveSection);
}
return false;
@@ -2275,7 +2241,7 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator const &Dep) const
// FIXME: this is a meant as a temporary solution until the
// recommends are cleaned up
const char *sec = Dep.ParentVer().Section();
- if (sec && SectionInSubTree("APT::Install-Recommends-Sections", sec))
+ if (sec && _config->SectionInSubTree("APT::Install-Recommends-Sections", sec))
return true;
}
else if(Dep->Type == pkgCache::Dep::Suggests)
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;