From 22dcc318d978813b3c4d1ae1a1f41933d0e1d69b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Jun 2005 08:53:45 +0000 Subject: * added APT::NeverAutoRemove (a list of regexp for package names that should never be automatically removed) --- apt-pkg/algorithms.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 11f5b5671..8e55649ca 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -26,7 +26,8 @@ #include - +#include +#include #include /*}}}*/ using namespace std; @@ -1329,6 +1330,19 @@ void pkgMarkPackage(pkgDepCache &Cache, } +// Helper for APT::NeverAutoRemove, always include the packages matching +// this regexp into the root-set +inline bool +pkgMarkAlwaysInclude(pkgCache::PkgIterator p, vector alwaysMark) +{ + for(unsigned int i=0;iFindB("APT::AutoRemove::SuggestsImportant", false); + // init the "NeverAutoRemove" variable + vector neverAutoRemoveRegexp; + Configuration::Item const *Opts; + Opts = _config->Tree("APT::NeverAutoRemove"); + if (Opts != 0 && Opts->Child != 0) + { + Opts = Opts->Child; + for (; Opts != 0; Opts = Opts->Next) + { + if (Opts->Value.empty() == true) + continue; + + regex_t *p = new regex_t; + if(regcomp(p,Opts->Value.c_str(), + REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0) + { + regfree(p); + for(unsigned int i=0;iError("Regex compilation error for APT::NeverAutoRemove"); + } + neverAutoRemoveRegexp.push_back(p); + } + } + + // do the mark part for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p) { if( (func != NULL ? (*func)(p) : false) || + pkgMarkAlwaysInclude(p, neverAutoRemoveRegexp) || !(Cache[p].Flags & pkgCache::Flag::Auto) || (p->Flags & pkgCache::Flag::Essential)) @@ -1434,5 +1475,11 @@ bool pkgMarkUsed(pkgDepCache &Cache, InRootSetFunc func) #endif } } + + // cleanup + for(unsigned int i=0;i