// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: depcache.cc,v 1.13 1998/12/22 07:58:50 jgg Exp $
+// $Id: depcache.cc,v 1.21 1999/10/22 05:58:54 jgg Exp $
/* ######################################################################
Dependency Cache - Caches Dependency information.
#pragma implementation "apt-pkg/depcache.h"
#endif
#include <apt-pkg/depcache.h>
-#include <apt-pkg/configuration.h>
#include <apt-pkg/version.h>
#include <apt-pkg/error.h>
// ---------------------------------------------------------------------
/* The default just returns the target version if it exists or the
highest version. */
-pkgDepCache::VerIterator pkgDepCache::GetCandidateVer(PkgIterator Pkg)
+pkgDepCache::VerIterator pkgDepCache::GetCandidateVer(PkgIterator Pkg,
+ bool AllowCurrent)
{
// Try to use an explicit target
- if (Pkg->TargetVer == 0)
- {
- string DistHack = _config->Find("to");
-
- /* If disthack is set then we look for a dist by that name to install
- from */
- if (DistHack.empty() == false)
- {
- for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
- {
- for (VerFileIterator J = I.FileList(); J.end() == false; J++)
- if ((J.File()->Flags & Flag::NotSource) == 0 &&
- (J.File()->Flags & Flag::NotAutomatic) == 0 &&
- J.File().Archive() == DistHack)
- return I;
- }
-
- // Hmm, target is current if there is no alternative.
- if (Pkg->CurrentVer != 0)
- return Pkg.CurrentVer();
- }
- else
- {
- /* Not source/not automatic versions cannot be a candidate version
- unless they are already installed */
- for (VerIterator I = Pkg.VersionList(); I.end() == false; I++)
- {
- if (Pkg.CurrentVer() == I)
- return I;
- for (VerFileIterator J = I.FileList(); J.end() == false; J++)
- if ((J.File()->Flags & Flag::NotSource) == 0 &&
- (J.File()->Flags & Flag::NotAutomatic) == 0)
- return I;
- }
- }
-
- return VerIterator(*this,0);
- }
+ if (Pkg->TargetVer == 0 ||
+ (AllowCurrent == false && Pkg.TargetVer() == Pkg.CurrentVer()))
+ return pkgCache::GetCandidateVer(Pkg,AllowCurrent);
else
return Pkg.TargetVer();
}
{
StateCache &P = PkgState[Pkg->ID];
- if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure)
- {
- iUsrSize += Mult*P.InstVerIter(*this)->InstalledSize;
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ P.Keep() == true)
return;
- }
// Compute the size data
if (P.NewInstall() == true)
}
// Upgrading
- if (Pkg->CurrentVer != 0 && P.InstallVer != (Version *)Pkg.CurrentVer() &&
- P.InstallVer != 0)
+ if (Pkg->CurrentVer != 0 &&
+ (P.InstallVer != (Version *)Pkg.CurrentVer() ||
+ (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
{
iUsrSize += Mult*((signed)P.InstVerIter(*this)->InstalledSize -
(signed)Pkg.CurrentVer()->InstalledSize);
// 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.Upgradable() == false)
- {
+ {
if (State.Mode == ModeDelete)
iDelCount += Add;
- if (State.Mode == ModeInstall)
- iInstCount += Add;
+ else
+ if ((State.iFlags & ReInstall) == ReInstall)
+ iInstCount += Add;
+
return;
}
Update(P.ParentPkg().RevDependsList());
// Update the provides map for the candidate ver
- for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList();
- P.end() != true; P++)
- Update(P.ParentPkg().RevDependsList());
+ if (PkgState[Pkg->ID].CandidateVer != 0)
+ for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList();
+ P.end() != true; P++)
+ Update(P.ParentPkg().RevDependsList());
}
/*}}}*/
// Simplifies other routines.
if (Pkg.end() == true)
return;
+
+ /* Reject an attempt to keep a non-source broken installed package, those
+ must be upgraded */
+ if (Pkg.State() == PkgIterator::NeedsUnpack &&
+ Pkg.CurrentVer().Downloadable() == false)
+ return;
/* We changed the soft state all the time so the UI is a bit nicer
to use */
// DepCache::MarkDelete - Put the package in the delete state /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgDepCache::MarkDelete(PkgIterator const &Pkg)
+void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
{
// Simplifies other routines.
if (Pkg.end() == true)
// Check that it is not already marked for delete
StateCache &P = PkgState[Pkg->ID];
- P.iFlags &= ~AutoKept;
- if (P.Mode == ModeDelete || P.InstallVer == 0)
+ P.iFlags &= ~(AutoKept | Purge);
+ if (rPurge == true)
+ P.iFlags |= Purge;
+
+ if ((P.Mode == ModeDelete || P.InstallVer == 0) &&
+ (Pkg.Purge() == true || rPurge == false))
return;
-
+
// We dont even try to delete virtual packages..
if (Pkg->VersionList == 0)
return;
RemoveSizes(Pkg);
RemoveStates(Pkg);
- if (Pkg->CurrentVer == 0)
+ if (Pkg->CurrentVer == 0 && (Pkg.Purge() == true || rPurge == false))
P.Mode = ModeKeep;
else
P.Mode = ModeDelete;
}
}
/*}}}*/
-
+// DepCache::SetReInstall - Set the reinstallation flag /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
+{
+ RemoveSizes(Pkg);
+ RemoveStates(Pkg);
+
+ StateCache &P = PkgState[Pkg->ID];
+ if (To == true)
+ P.iFlags |= ReInstall;
+ else
+ P.iFlags &= ~ReInstall;
+
+ AddStates(Pkg);
+ AddSizes(Pkg);
+}
+ /*}}}*/
// StateCache::Update - Compute the various static display things /*{{{*/
// ---------------------------------------------------------------------
/* This is called whenever the Candidate version changes. */