summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-11-11 11:58:56 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-11-11 23:40:39 +0100
commita9b724eedd0c9d8c36725c5b8f57d51ea9f7dcd1 (patch)
tree052993f7efd9e74bffd3d0c1243c28100a7c2072 /apt-pkg/deb
parent11c96d7618faecc8fab9edfd83b2b2e0afefda3b (diff)
add hidden config to set packages as Essential/Important
You can pretty much achieve the same with a local dummy package if you want to, but libapt has an inbuilt setting for essential: "apt" which can be overridden with this option as well – it could be helpful in quick tests and what not so adding this alternative shouldn't really hurt much. We aren't going to document them much through as care must be taken in regards to the binary caches as they aren't invalidated by config options alone, so the effects of old settings could still be in them, similar to the other already existing pkgCacheGen option(s). Closes: 767891 Thanks: Anthony Towns for initial patch
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc16
-rw-r--r--apt-pkg/deb/deblistparser.h4
2 files changed, 16 insertions, 4 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 99e806470..0f9fe310f 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -50,8 +50,18 @@ static const debListParser::WordList PrioList[] = {
in Step(), if no Architecture is given we will accept every arch
we would accept in general with checkArchitecture() */
debListParser::debListParser(FileFd *File) :
- pkgCacheListParser(), d(NULL), Tags(File)
+ pkgCacheListParser(), Tags(File)
{
+ // this dance allows an empty value to override the default
+ if (_config->Exists("pkgCacheGen::ForceEssential"))
+ {
+ forceEssential = _config->FindVector("pkgCacheGen::ForceEssential");
+ if (forceEssential.empty() == false && _config->Find("pkgCacheGen::ForceEssential").empty())
+ forceEssential.emplace_back("apt");
+ }
+ else
+ forceEssential.emplace_back("apt");
+ forceImportant = _config->FindVector("pkgCacheGen::ForceImportant");
}
/*}}}*/
// ListParser::Package - Return the package name /*{{{*/
@@ -311,7 +321,7 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
if (Section.FindFlag("Important",Pkg->Flags,pkgCache::Flag::Important) == false)
return false;
- if (strcmp(Pkg.Name(),"apt") == 0)
+ if (std::find(forceEssential.begin(), forceEssential.end(), Pkg.Name()) != forceEssential.end())
{
if ((essential == "native" && Pkg->Arch != 0 && myArch == Pkg.Arch()) ||
essential == "all")
@@ -319,6 +329,8 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
else
Pkg->Flags |= pkgCache::Flag::Important;
}
+ else if (std::find(forceImportant.begin(), forceImportant.end(), Pkg.Name()) != forceImportant.end())
+ Pkg->Flags |= pkgCache::Flag::Important;
if (ParseStatus(Pkg,Ver) == false)
return false;
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index a78312f9d..102cd62aa 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -43,8 +43,8 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
#endif
private:
- /** \brief dpointer placeholder (for later in case we need it) */
- void * const d;
+ std::vector<std::string> forceEssential;
+ std::vector<std::string> forceImportant;
protected:
pkgTagFile Tags;