You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1899 lines
58 KiB

// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: depcache.cc,v 1.25 2001/05/27 05:36:04 jgg Exp $
/* ######################################################################
Dependency Cache - Caches Dependency information.
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include <apt-pkg/depcache.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
* merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'.
17 years ago
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/tagfile.h>
#include <iostream>
17 years ago
#include <sstream>
#include <set>
#include <sys/stat.h>
#include <apti18n.h>
/*}}}*/
// helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/
static bool
ConfigValueInSubTree(const char* SubTree, const char *needle)
{
Configuration::Item const *Opts;
Opts = _config->Tree(SubTree);
if (Opts != 0 && Opts->Child != 0)
{
Opts = Opts->Child;
for (; Opts != 0; Opts = Opts->Next)
{
if (Opts->Value.empty() == true)
continue;
if (strcmp(needle, Opts->Value.c_str()) == 0)
return true;
}
}
return false;
}
/*}}}*/
pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) : /*{{{*/
* merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'.
17 years ago
cache(cache), released(false)
{
++cache.group_level;
}
void pkgDepCache::ActionGroup::release()
{
if(!released)
{
if(cache.group_level == 0)
std::cerr << "W: Unbalanced action groups, expect badness" << std::endl;
else
{
--cache.group_level;
if(cache.group_level == 0)
cache.MarkAndSweep();
}
released = false;
}
}
pkgDepCache::ActionGroup::~ActionGroup()
{
release();
}
/*}}}*/
// DepCache::pkgDepCache - Constructors /*{{{*/
// ---------------------------------------------------------------------
/* */
pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) :
* merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'.
17 years ago
group_level(0), Cache(pCache), PkgState(0), DepState(0)
{
DebugMarker = _config->FindB("Debug::pkgDepCache::Marker", false);
DebugAutoInstall = _config->FindB("Debug::pkgDepCache::AutoInstall", false);
delLocalPolicy = 0;
LocalPolicy = Plcy;
if (LocalPolicy == 0)
delLocalPolicy = LocalPolicy = new Policy;
}
/*}}}*/
// DepCache::~pkgDepCache - Destructor /*{{{*/
// ---------------------------------------------------------------------
/* */
pkgDepCache::~pkgDepCache()
{
delete [] PkgState;
delete [] DepState;
delete delLocalPolicy;
}
/*}}}*/
// DepCache::Init - Generate the initial extra structures. /*{{{*/
// ---------------------------------------------------------------------
/* This allocats the extension buffers and initializes them. */
bool pkgDepCache::Init(OpProgress *Prog)
{
* merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'.
17 years ago
// Suppress mark updates during this operation (just in case) and
// run a mark operation when Init terminates.
ActionGroup actions(*this);
delete [] PkgState;
delete [] DepState;
PkgState = new StateCache[Head().PackageCount];
DepState = new unsigned char[Head().DependsCount];
memset(PkgState,0,sizeof(*PkgState)*Head().PackageCount);
memset(DepState,0,sizeof(*DepState)*Head().DependsCount);
if (Prog != 0)
{
Prog->OverallProgress(0,2*Head().PackageCount,Head().PackageCount,
_("Building dependency tree"));
Prog->SubProgress(Head().PackageCount,_("Candidate versions"));
}
/* Set the current state of everything. In this state all of the
packages are kept exactly as is. See AllUpgrade */
int Done = 0;
for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
{
if (Prog != 0 && Done%20 == 0)
Prog->Progress(Done);
// Find the proper cache slot
StateCache &State = PkgState[I->ID];
State.iFlags = 0;
// Figure out the install version
State.CandidateVer = GetCandidateVer(I);
State.InstallVer = I.CurrentVer();
State.Mode = ModeKeep;
State.Update(I,*this);
}
if (Prog != 0)
{
Prog->OverallProgress(Head().PackageCount,2*Head().PackageCount,
Head().PackageCount,
_("Building dependency tree"));
Prog->SubProgress(Head().PackageCount,_("Dependency generation"));
}
Update(Prog);
* merged with mainline Patches applied: * andrelop@debian.org/apt--translation--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-79 * andrelop@debian.org/apt--translation--0--patch-1 Sync with Matt version. * andrelop@debian.org/apt--translation--0--patch-2 Update pt_BR translation * andrelop@debian.org/apt--translation--0--patch-3 Sync with bubulle's branch. * apt@packages.debian.org/apt--main--0--patch-89 Branch for Debian * apt@packages.debian.org/apt--main--0--patch-90 Update version in configure * apt@packages.debian.org/apt--main--0--patch-91 Fix French man page build * apt@packages.debian.org/apt--main--0--patch-92 Add the current Debian archive signing key * apt@packages.debian.org/apt--main--0--patch-93 Merge with mvo * apt@packages.debian.org/apt--main--0--patch-94 Update changelog * apt@packages.debian.org/apt--main--0--patch-95 Merge Christian's branch * apt@packages.debian.org/apt--main--0--patch-96 Update changelog * apt@packages.debian.org/apt--main--0--patch-97 Update priority of apt-utils to important, to match the override file * bubulle@debian.org--2005/apt--main--0--patch-82 Fix permissions * bubulle@debian.org--2005/apt--main--0--patch-83 French translation spellchecked * bubulle@debian.org--2005/apt--main--0--patch-84 Spell corrections in German translations * bubulle@debian.org--2005/apt--main--0--patch-85 Correct some file permissions * bubulle@debian.org--2005/apt--main--0--patch-86 Correct Hebrew translation * bubulle@debian.org--2005/apt--main--0--patch-87 Sync Portuguese translation with the POT file * bubulle@debian.org--2005/apt--main--0--patch-88 Updated Danish translation (not yet complete) * bubulle@debian.org--2005/apt--main--0--patch-89 Sync with Andre Luis Lopes and Otavio branches * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-22 * added myself to uploaders, changelog is signed with mvo@debian.org and in sync with the debian/experimental upload * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-23 * apt-cache show <virtual-pkg> shows all virtual packages instead of nothing (thanks to otavio) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-24 * changelog updated * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-25 * make pinning on component work again (we just use the section, as apt-0.6 don't use per-section Release files anymore) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-27 * updated the changelog * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-28 * merged with my apt--fixes--0 branch * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-29 * added a missing OpProgress::Done() in depCache::Init(), removed the show-virtual-packages patch in apt-cache because matt does not like him :/ * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-30 * fix a stupid bug in the depcache::Init() code * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-31 * merged/removed conflicts with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-32 * merged apt--main and make sure that the po files come from apt--main (because they are more recent)
17 years ago
if(Prog != 0)
Prog->Done();
* merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'.
17 years ago
return true;
}
/*}}}*/
bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/
17 years ago
{
FileFd state_file;
string const state = _config->FindFile("Dir::State::extended_states");
17 years ago
if(FileExists(state)) {
state_file.Open(state, FileFd::ReadOnly);
int const file_size = state_file.Size();
if(Prog != NULL)
Prog->OverallProgress(0, file_size, 1,
_("Reading state information"));
17 years ago
pkgTagFile tagfile(&state_file);
pkgTagSection section;
int amt = 0;
bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
17 years ago
while(tagfile.Step(section)) {
string const pkgname = section.FindS("Package");
string pkgarch = section.FindS("Architecture");
if (pkgarch.empty() == true)
pkgarch = "any";
pkgCache::PkgIterator pkg = Cache->FindPkg(pkgname, pkgarch);
// Silently ignore unknown packages and packages with no actual version.
if(pkg.end() == true || pkg->VersionList == 0)
continue;
short const reason = section.FindI("Auto-Installed", 0);
if(reason > 0)
{
PkgState[pkg->ID].Flags |= Flag::Auto;
if (unlikely(debug_autoremove))
std::clog << "Auto-Installed : " << pkg.FullName() << std::endl;
if (pkgarch == "any")
{
pkgCache::GrpIterator G = pkg.Group();
for (pkg = G.NextPkg(pkg); pkg.end() != true; pkg = G.NextPkg(pkg))
if (pkg->VersionList != 0)
PkgState[pkg->ID].Flags |= Flag::Auto;
}
17 years ago
}
amt += section.size();
if(Prog != NULL)
Prog->OverallProgress(amt, file_size, 1,
_("Reading state information"));
17 years ago
}
if(Prog != NULL)
Prog->OverallProgress(file_size, file_size, 1,
_("Reading state information"));
17 years ago
}
return true;
}
/*}}}*/
bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
17 years ago
{
bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
if(debug_autoremove)
std::clog << "pkgDepCache::writeStateFile()" << std::endl;
FileFd StateFile;
string const state = _config->FindFile("Dir::State::extended_states");
// if it does not exist, create a empty one
if(!FileExists(state))
{
StateFile.Open(state, FileFd::WriteEmpty);
StateFile.Close();
}
// open it
if(!StateFile.Open(state, FileFd::ReadOnly))
return _error->Error(_("Failed to open StateFile %s"),
17 years ago
state.c_str());
FILE *OutFile;
string const outfile = state + ".tmp";
if((OutFile = fopen(outfile.c_str(),"w")) == NULL)
return _error->Error(_("Failed to write temporary StateFile %s"),
outfile.c_str());
// first merge with the existing sections
pkgTagFile tagfile(&StateFile);
pkgTagSection section;
std::set<string> pkgs_seen;
const char *nullreorderlist[] = {0};
while(tagfile.Step(section)) {
string const pkgname = section.FindS("Package");
string pkgarch = section.FindS("Architecture");
if (pkgarch.empty() == true)
pkgarch = "native";
// Silently ignore unknown packages and packages with no actual
// version.
pkgCache::PkgIterator pkg = Cache->FindPkg(pkgname, pkgarch);
if(pkg.end() || pkg.VersionList().end())
continue;
StateCache const &P = PkgState[pkg->ID];
bool newAuto = (P.Flags & Flag::Auto);
// skip not installed or now-removed ones if requested
if (InstalledOnly && (
(pkg->CurrentVer == 0 && P.Mode != ModeInstall) ||
(pkg->CurrentVer != 0 && P.Mode == ModeDelete)))
{
// The section is obsolete if it contains no other tag
unsigned int const count = section.Count();
if (count < 2 ||
(count == 2 && section.Exists("Auto-Installed")) ||
(count == 3 && section.Exists("Auto-Installed") && section.Exists("Architecture")))
continue;
else
newAuto = false;
}
if(_config->FindB("Debug::pkgAutoRemove",false))
std::clog << "Update existing AutoInstall info: "
<< pkg.FullName() << std::endl;
TFRewriteData rewrite[3];
rewrite[0].Tag = "Architecture";
rewrite[0].Rewrite = pkg.Arch();
rewrite[0].NewTag = 0;
rewrite[1].Tag = "Auto-Installed";
rewrite[1].Rewrite = newAuto ? "1" : "0";
rewrite[1].NewTag = 0;
rewrite[2].Tag = 0;
TFRewrite(OutFile, section, nullreorderlist, rewrite);
fprintf(OutFile,"\n");
pkgs_seen.insert(pkg.FullName());
}
// then write the ones we have not seen yet
std::ostringstream ostr;
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
StateCache const &P = PkgState[pkg->ID];
if(P.Flags & Flag::Auto) {
if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) {
if(debug_autoremove)
std::clog << "Skipping already written " << pkg.FullName() << std::endl;
continue;
}
// skip not installed ones if requested
if (InstalledOnly && (
(pkg->CurrentVer == 0 && P.Mode != ModeInstall) ||
(pkg->CurrentVer != 0 && P.Mode == ModeDelete)))
continue;
const char* const pkgarch = pkg.Arch();
if (strcmp(pkgarch, "all") == 0)
continue;
if(debug_autoremove)
std::clog << "Writing new AutoInstall: " << pkg.FullName() << std::endl;
17 years ago
ostr.str(string(""));
ostr << "Package: " << pkg.Name()
<< "\nArchitecture: " << pkgarch
<< "\nAuto-Installed: 1\n\n";
fprintf(OutFile,"%s",ostr.str().c_str());
17 years ago
}
}
fclose(OutFile);
// move the outfile over the real file and set permissions
rename(outfile.c_str(), state.c_str());
chmod(state.c_str(), 0644);
17 years ago
return true;
}
/*}}}*/
// DepCache::CheckDep - Checks a single dependency /*{{{*/
// ---------------------------------------------------------------------
/* This first checks the dependency against the main target package and
then walks along the package provides list and checks if each provides
will be installed then checks the provides against the dep. Res will be
set to the package which was used to satisfy the dep. */
bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
{
Res = Dep.TargetPkg();
/* Check simple depends. A depends -should- never self match but
we allow it anyhow because dpkg does. Technically it is a packaging
bug. Conflicts may never self match */
if (Dep.TargetPkg() != Dep.ParentPkg() ||
(Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes))
{
PkgIterator Pkg = Dep.TargetPkg();
// Check the base package
if (Type == NowVersion && Pkg->CurrentVer != 0)
if (VS().CheckDep(Pkg.CurrentVer().VerStr(),Dep->CompareOp,
Dep.TargetVer()) == true)
return true;
if (Type == InstallVersion && PkgState[Pkg->ID].InstallVer != 0)
if (VS().CheckDep(PkgState[Pkg->ID].InstVerIter(*this).VerStr(),
Dep->CompareOp,Dep.TargetVer()) == true)
return true;
if (Type == CandidateVersion && PkgState[Pkg->ID].CandidateVer != 0)
if (VS().CheckDep(PkgState[Pkg->ID].CandidateVerIter(*this).VerStr(),
Dep->CompareOp,Dep.TargetVer()) == true)
return true;
}
if (Dep->Type == Dep::Obsoletes)
return false;
// Check the providing packages
PrvIterator P = Dep.TargetPkg().ProvidesList();
PkgIterator Pkg = Dep.ParentPkg();
for (; P.end() != true; P++)
{
/* Provides may never be applied against the same package if it is
a conflicts. See the comment above. */
if (P.OwnerPkg() == Pkg &&
(Dep->Type == Dep::Conflicts || Dep->Type == Dep::DpkgBreaks))
continue;
// Check if the provides is a hit
if (Type == NowVersion)
{
if (P.OwnerPkg().CurrentVer() != P.OwnerVer())
continue;
}
if (Type == InstallVersion)
{
StateCache &State = PkgState[P.OwnerPkg()->ID];
if (State.InstallVer != (Version *)P.OwnerVer())
continue;
}
if (Type == CandidateVersion)
{
StateCache &State = PkgState[P.OwnerPkg()->ID];
if (State.CandidateVer != (Version *)P.OwnerVer())
continue;
}
// Compare the versions.
if (VS().CheckDep(P.ProvideVersion(),Dep->CompareOp,Dep.TargetVer()) == true)
{
Res = P.OwnerPkg();
return true;
}
}
return false;
}
/*}}}*/
// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
// ---------------------------------------------------------------------
/* Call with Mult = -1 to preform the inverse opration
The Mult increases the complexity of the calulations here and is unused -
or do we really have a usecase for removing the size of a package two
times? So let us replace it with a simple bool and be done with it… */
__deprecated void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
{
StateCache &P = PkgState[Pkg->ID];
if (Pkg->VersionList == 0)
return;
if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
P.Keep() == true)
return;
// Compute the size data
if (P.NewInstall() == true)
{
iUsrSize += (signed long long)(Mult*P.InstVerIter(*this)->InstalledSize);
iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
// Upgrading
if (Pkg->CurrentVer != 0 &&
(P.InstallVer != (Version *)Pkg.CurrentVer() ||
(P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
{
iUsrSize += (signed long long)(Mult*((signed long long)P.InstVerIter(*this)->InstalledSize -
(signed long long)Pkg.CurrentVer()->InstalledSize));
iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
// Reinstall
if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
P.Delete() == false)
{
iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
// Removing
if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
{
iUsrSize -= (signed long long)(Mult*Pkg.CurrentVer()->InstalledSize);
return;
}
}
/*}}}*/
// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
// ---------------------------------------------------------------------
/* Call with Inverse = true to preform the inverse opration */
void pkgDepCache::AddSizes(const PkgIterator &Pkg, bool const &Inverse)
{
StateCache &P = PkgState[Pkg->ID];
if (Pkg->VersionList == 0)
return;
if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
P.Keep() == true)
return;
// Compute the size data
if (P.NewInstall() == true)
{
if (Inverse == false) {
iUsrSize += P.InstVerIter(*this)->InstalledSize;
iDownloadSize += P.InstVerIter(*this)->Size;
} else {
iUsrSize -= P.InstVerIter(*this)->InstalledSize;
iDownloadSize -= P.InstVerIter(*this)->Size;
}
return;
}
// Upgrading
if (Pkg->CurrentVer != 0 &&
(P.InstallVer != (Version *)Pkg.CurrentVer() ||
(P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
{
if (Inverse == false) {
iUsrSize -= Pkg.CurrentVer()->InstalledSize;
iUsrSize += P.InstVerIter(*this)->InstalledSize;
iDownloadSize += P.InstVerIter(*this)->Size;
} else {
iUsrSize -= P.InstVerIter(*this)->InstalledSize;
iUsrSize += Pkg.CurrentVer()->InstalledSize;
iDownloadSize -= P.InstVerIter(*this)->Size;
}
return;
}
// Reinstall
if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
P.Delete() == false)
{
if (Inverse == false)
iDownloadSize += P.InstVerIter(*this)->Size;
else
iDownloadSize -= P.InstVerIter(*this)->Size;
return;
}
// Removing
if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
{
if (Inverse == false)
iUsrSize -= Pkg.CurrentVer()->InstalledSize;
else
iUsrSize += Pkg.CurrentVer()->InstalledSize;
return;
}
}
/*}}}*/
// DepCache::AddStates - Add the package to the state counter /*{{{*/
// ---------------------------------------------------------------------
/* This routine is tricky to use, you must make sure that it is never
called twice for the same package. This means the Remove/Add section
should be as short as possible and not encompass any code that will
calld Remove/Add itself. Remember, dependencies can be circular so
while processing a dep for Pkg it is possible that Add/Remove
will be called on Pkg */
void pkgDepCache::AddStates(const PkgIterator &Pkg,int Add)
{
StateCache &State = PkgState[Pkg->ID];
// The Package is broken (either minimal dep or policy dep)
if ((State.DepState & DepInstMin) != DepInstMin)
iBrokenCount += Add;
if ((State.DepState & DepInstPolicy) != DepInstPolicy)
iPolicyBrokenCount += Add;
// Bad state
if (Pkg.State() != PkgIterator::NeedsNothing)
iBadCount += Add;
// Not installed
if (Pkg->CurrentVer == 0)
{
if (State.Mode == ModeDelete &&
(State.iFlags | Purge) == Purge && Pkg.Purge() == false)
iDelCount += Add;
if (State.Mode == ModeInstall)
iInstCount += Add;
return;
}
// Installed, no upgrade
if (State.Status == 0)
{
if (State.Mode == ModeDelete)
iDelCount += Add;
else
if ((State.iFlags & ReInstall) == ReInstall)
iInstCount += Add;
return;
}
// Alll 3 are possible
if (State.Mode == ModeDelete)
iDelCount += Add;
if (State.Mode == ModeKeep)
iKeepCount += Add;
if (State.Mode == ModeInstall)
iInstCount += Add;
}
/*}}}*/
// DepCache::BuildGroupOrs - Generate the Or group dep data /*{{{*/
// ---------------------------------------------------------------------
/* The or group results are stored in the last item of the or group. This
allows easy detection of the state of a whole or'd group. */
void pkgDepCache::BuildGroupOrs(VerIterator const &V)
{
unsigned char Group = 0;
for (DepIterator D = V.DependsList(); D.end() != true; D++)
{
// Build the dependency state.
unsigned char &State = DepState[D->ID];
/* Invert for Conflicts. We have to do this twice to get the
right sense for a conflicts group */
if (D->Type == Dep::Conflicts ||
D->Type == Dep::DpkgBreaks ||
D->Type == Dep::Obsoletes)
State = ~State;
// Add to the group if we are within an or..
State &= 0x7;
Group |= State;
State |= Group << 3;
if ((D->CompareOp & Dep::Or) != Dep::Or)
Group = 0;
// Invert for Conflicts
if (D->Type == Dep::Conflicts ||
D->Type == Dep::DpkgBreaks ||
D->Type == Dep::Obsoletes)
State = ~State;
}
}
/*}}}*/
// DepCache::VersionState - Perform a pass over a dependency list /*{{{*/
// ---------------------------------------------------------------------
/* This is used to run over a dependency list and determine the dep
state of the list, filtering it through both a Min check and a Policy
check. The return result will have SetMin/SetPolicy low if a check
fails. It uses the DepState cache for it's computations. */
unsigned char pkgDepCache::VersionState(DepIterator D,unsigned char Check,
unsigned char SetMin,
unsigned char SetPolicy)
{
unsigned char Dep = 0xFF;
while (D.end() != true)
{
// Compute a single dependency element (glob or)
DepIterator Start = D;
unsigned char State = 0;
for (bool LastOR = true; D.end() == false && LastOR == true; D++)
{
State |= DepState[D->ID];
LastOR = (D->CompareOp & Dep::Or) == Dep::Or;
}
// Minimum deps that must be satisfied to have a working package
if (Start.IsCritical() == true)
if ((State & Check) != Check)
Dep &= ~SetMin;
// Policy deps that must be satisfied to install the package
if (IsImportantDep(Start) == true &&
(State & Check) != Check)
Dep &= ~SetPolicy;
}
return Dep;
}
/*}}}*/
// DepCache::DependencyState - Compute the 3 results for a dep /*{{{*/
// ---------------------------------------------------------------------
/* This is the main dependency computation bit. It computes the 3 main
results for a dependencys, Now, Install and Candidate. Callers must
invert the result if dealing with conflicts. */
unsigned char pkgDepCache::DependencyState(DepIterator &D)
{
unsigned char State = 0;
if (CheckDep(D,NowVersion) == true)
State |= DepNow;
if (CheckDep(D,InstallVersion) == true)
State |= DepInstall;
if (CheckDep(D,CandidateVersion) == true)
State |= DepCVer;
return State;
}
/*}}}*/
// DepCache::UpdateVerState - Compute the Dep member of the state /*{{{*/
// ---------------------------------------------------------------------
/* This determines the combined dependency representation of a package
for its two states now and install. This is done by using the pre-generated
dependency information. */
void pkgDepCache::UpdateVerState(PkgIterator Pkg)
{
// Empty deps are always true
StateCache &State = PkgState[Pkg->ID];
State.DepState = 0xFF;
// Check the Current state
if (Pkg->CurrentVer != 0)
{
DepIterator D = Pkg.CurrentVer().DependsList();
State.DepState &= VersionState(D,DepNow,DepNowMin,DepNowPolicy);
}
/* Check the candidate state. We do not compare against the whole as
a candidate state but check the candidate version against the
install states */
if (State.CandidateVer != 0)
{
DepIterator D = State.CandidateVerIter(*this).DependsList();
State.DepState &= VersionState(D,DepInstall,DepCandMin,DepCandPolicy);
}
// Check target state which can only be current or installed
if (State.InstallVer != 0)
{
DepIterator D = State.InstVerIter(*this).DependsList();
State.DepState &= VersionState(D,DepInstall,DepInstMin,DepInstPolicy);
}
}
/*}}}*/
// DepCache::RemovePseudoInstalledPkg - MultiArch helper for Update() /*{{{*/
// ---------------------------------------------------------------------
/* We "install" arch all packages for all archs if it is installed. Many
of these will be broken. This method will look at these broken Pkg and
"remove" it. */
bool pkgDepCache::RemovePseudoInstalledPkg(PkgIterator &Pkg, std::set<unsigned long> &recheck) {
if (unlikely(Pkg->CurrentVer == 0))
return false;
VerIterator V = Pkg.CurrentVer();
if (V->MultiArch != Version::All)
return false;
// Never ever kill an "all" package - they have no dependency so they can't be broken
if (strcmp(Pkg.Arch(),"all") == 0)
return false;
unsigned char const CurDepState = VersionState(V.DependsList(),DepInstall,DepInstMin,DepInstPolicy);
if ((CurDepState & DepInstMin) == DepInstMin) {
// okay, the package isn't broken, but is the package also required?
// If it has no real dependencies, no installed rdepends and doesn't
// provide something of value, we will kill it as not required.
// These pseudopackages have otherwise interesting effects if they get
// a new dependency in a newer version…
for (pkgCache::DepIterator D = V.DependsList();
D.end() != true; ++D)
if (D.IsCritical() == true && D.ParentPkg()->Group != Pkg->Group)
return false;
for (DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D)
{
if (D.IsCritical() == false)