summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-05-10 08:27:59 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-05-10 08:27:59 +0000
commitafb1e2e3bb580077c6c917e6ea98baad8f3c39b3 (patch)
treed5dbef0ff8bc398665ba3c3faec70f585af7d7ac /apt-pkg
parentfd355b32a65efa2fa0f5390b448ba5627c743080 (diff)
* ported/cleaned up the "Automatic dependency handling" patch from Michael Hofmann
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/dpkgpm.h2
-rw-r--r--apt-pkg/depcache.cc50
-rw-r--r--apt-pkg/depcache.h6
-rw-r--r--apt-pkg/pkgcache.h1
-rw-r--r--apt-pkg/pkgcachegen.cc2
5 files changed, 58 insertions, 3 deletions
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
index b59b9dc93..8bfdff5eb 100644
--- a/apt-pkg/deb/dpkgpm.h
+++ b/apt-pkg/deb/dpkgpm.h
@@ -40,7 +40,7 @@ class pkgDPkgPM : public pkgPackageManager
bool RunScripts(const char *Cnf);
bool RunScriptsWithPkgs(const char *Cnf);
bool SendV2Pkgs(FILE *F);
-
+
// The Actuall installation implementation
virtual bool Install(PkgIterator Pkg,string File);
virtual bool Configure(PkgIterator Pkg);
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index c6bf3185a..5da411e4d 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -16,6 +16,10 @@
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/algorithms.h>
+
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/tagfile.h>
#include <apti18n.h>
/*}}}*/
@@ -72,7 +76,10 @@ bool pkgDepCache::Init(OpProgress *Prog)
// Find the proper cache slot
StateCache &State = PkgState[I->ID];
State.iFlags = 0;
-
+ State.DirtyState = pkgCache::State::RemoveUnknown;
+ //State.AutomaticRemove = I->AutomaticRemove;
+ State.AutomaticRemove = pkgCache::State::RemoveUnknown;
+
// Figure out the install version
State.CandidateVer = GetCandidateVer(I);
State.InstallVer = I.CurrentVer();
@@ -447,6 +454,35 @@ void pkgDepCache::Update(OpProgress *Prog)
AddStates(I);
}
+ // read the state file ------------------------------
+ FileFd state_file;
+ string state = _config->FindDir("Dir::State") + "pkgstates";
+ if(FileExists(state)) {
+ state_file.Open(state, FileFd::ReadOnly);
+ int file_size = state_file.Size();
+ Prog->OverallProgress(0, file_size, 1, _("Reading extended state information"));
+
+ pkgTagFile tagfile(&state_file);
+ pkgTagSection section;
+ int amt=0;
+ while(tagfile.Step(section)) {
+ string pkgname = section.FindS("Package");
+ pkgCache::PkgIterator pkg=Cache->FindPkg(pkgname);
+ // Silently ignore unknown packages and packages with no actual
+ // version.
+ if(!pkg.end() && !pkg.VersionList().end()) {
+ short reason = section.FindI("Remove-Reason", pkgCache::State::RemoveManual);
+ PkgState[pkg->ID].AutomaticRemove = reason;
+ //std::cout << "Set: " << pkgname << " to " << reason << std::endl;
+ amt+=section.size();
+ Prog->OverallProgress(amt, file_size, 1, _("Reading extended state information"));
+ }
+ Prog->OverallProgress(file_size, file_size, 1, _("Reading extended state information"));
+ }
+ }
+ //--------------------------------------
+
+
if (Prog != 0)
Prog->Progress(Done);
}
@@ -582,7 +618,8 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
else
P.Mode = ModeDelete;
P.InstallVer = 0;
- P.Flags &= Flag::Auto;
+ // This was not inverted before, but I think it should be
+ P.Flags &= ~Flag::Auto;
AddStates(Pkg);
Update(Pkg);
@@ -754,6 +791,15 @@ void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
AddSizes(Pkg);
}
/*}}}*/
+// DepCache::SetDirty - Switch the package between dirty states /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgDepCache::SetDirty(PkgIterator const &Pkg, pkgCache::State::PkgRemoveState To)
+{
+ StateCache &P = PkgState[Pkg->ID];
+ P.DirtyState = To;
+}
+ /*}}}*/
// DepCache::SetCandidateVersion - Change the candidate version /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 6d51920e9..f974bfacf 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -79,6 +79,10 @@ class pkgDepCache : protected pkgCache::Namespace
unsigned short Flags;
unsigned short iFlags; // Internal flags
+ // Traversal status and state for automatic removal
+ unsigned char DirtyState;
+ unsigned char AutomaticRemove;
+
// Various tree indicators
signed char Status; // -1,0,1,2
unsigned char Mode; // ModeList
@@ -99,6 +103,7 @@ class pkgDepCache : protected pkgCache::Namespace
inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;};
inline bool Install() const {return Mode == ModeInstall;};
+ inline unsigned char Dirty() const {return DirtyState;};
inline VerIterator InstVerIter(pkgCache &Cache)
{return VerIterator(Cache,InstallVer);};
inline VerIterator CandidateVerIter(pkgCache &Cache)
@@ -189,6 +194,7 @@ class pkgDepCache : protected pkgCache::Namespace
unsigned long Depth = 0);
void SetReInstall(PkgIterator const &Pkg,bool To);
void SetCandidateVersion(VerIterator TargetVer);
+ void SetDirty(PkgIterator const &Pkg, pkgCache::State::PkgRemoveState To);
// This is for debuging
void Update(OpProgress *Prog = 0);
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index b07951dfb..083f20ac2 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -75,6 +75,7 @@ class pkgCache
enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
HalfInstalled=4,ConfigFiles=5,Installed=6};
+ enum PkgRemoveState {RemoveUnknown=0, RemoveManual=1,RemoveSuggested=2,RemoveRecommended=3,RemoveRequired=4};
};
struct Flag
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 075af3eec..e90c1e50d 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -26,6 +26,8 @@
#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/tagfile.h>
+
#include <apti18n.h>
#include <vector>