summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc2
-rw-r--r--apt-pkg/depcache.cc25
-rw-r--r--apt-pkg/depcache.h7
-rw-r--r--apt-pkg/packagemanager.h7
4 files changed, 14 insertions, 27 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index bed90f5d0..c679e76f6 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1349,7 +1349,7 @@ bool pkgMarkUsed(pkgDepCache &Cache)
// do the mark part
for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p)
{
- if(Cache[p].InstallReason==pkgDepCache::Manual ||
+ if(!(Cache[p].Flags & pkgCache::Flag::Auto) ||
(p->Flags & pkgCache::Flag::Essential))
{
if(Cache[p].Keep() && !p.CurrentVer().end())
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 52b43d83d..05512e179 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -78,7 +78,6 @@ bool pkgDepCache::Init(OpProgress *Prog)
// Find the proper cache slot
StateCache &State = PkgState[I->ID];
State.iFlags = 0;
- State.InstallReason = Manual;
// Figure out the install version
State.CandidateVer = GetCandidateVer(I);
@@ -125,8 +124,9 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)
// Silently ignore unknown packages and packages with no actual
// version.
if(!pkg.end() && !pkg.VersionList().end()) {
- short reason = section.FindI("Install-Reason",pkgDepCache::Manual);
- PkgState[pkg->ID].InstallReason = (ChangedReason)reason;
+ short reason = section.FindI("Install-Reason", 0);
+ if(reason > 0)
+ PkgState[pkg->ID].Flags |= pkgCache::Flag::Auto;
if(_config->FindB("Debug::pkgAutoRemove",false))
std::cout << "Install-Reason for: " << pkgname
<< " is " << reason << std::endl;
@@ -147,6 +147,9 @@ bool pkgDepCache::writeStateFile(OpProgress *prog)
FileFd StateFile;
string state = _config->FindDir("Dir::State") + "pkgstates";
+ if(_config->FindB("Debug::pkgAutoRemove",false))
+ std::clog << "pkgDepCache::writeStateFile()" << std::endl;
+
if(!StateFile.Open(state, FileFd::WriteEmpty))
return _error->Error(_("Failed to write StateFile %s"),
state.c_str());
@@ -154,22 +157,12 @@ bool pkgDepCache::writeStateFile(OpProgress *prog)
std::ostringstream ostr;
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end();pkg++) {
- // clear out no longer installed pkg
- if(PkgState[pkg->ID].Delete() || pkg.CurrentVer() == NULL)
- PkgState[pkg->ID].InstallReason = Manual;
-
- // check if we have new information
if(PkgState[pkg->ID].Flags & pkgCache::Flag::Auto) {
- if(_config->FindI("Debug::pkgAutoRemove",false))
- std::clog << "pkg: " << pkg.Name() << " is auto-dep" << std::endl;
- PkgState[pkg->ID].InstallReason = Libapt;
- }
-
- if(PkgState[pkg->ID].InstallReason != Manual) {
+ if(_config->FindB("Debug::pkgAutoRemove",false))
+ std::clog << "AutoInstal: " << pkg.Name() << std::endl;
ostr.str(string(""));
ostr << "Package: " << pkg.Name()
- << "\nInstall-Reason: "
- << (int)(PkgState[pkg->ID].InstallReason) << "\n\n";
+ << "\nInstall-Reason: 1\n\n";
StateFile.Write(ostr.str().c_str(), ostr.str().size());
}
}
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index c91e09ab3..619daf8f6 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -64,9 +64,6 @@ class pkgDepCache : protected pkgCache::Namespace
enum VersionTypes {NowVersion, InstallVersion, CandidateVersion};
enum ModeList {ModeDelete = 0, ModeKeep = 1, ModeInstall = 2};
- // Flags for the GC
- enum ChangedReason {Manual, UserAuto, Libapt, FromResolver, PkgIsUnused};
-
struct StateCache
{
// Epoch stripped text versions of the two version fields
@@ -84,10 +81,6 @@ class pkgDepCache : protected pkgCache::Namespace
unsigned short iFlags; // Internal flags
// mark and sweep flags
- ChangedReason InstallReason;
-#if 0
- ChangedReason RemoveReason;
-#endif
bool Marked;
bool Garbage;
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index da1f21e6c..f95b2ab56 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -28,6 +28,7 @@
#endif
#include <string>
+#include <iostream>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/depcache.h>
@@ -101,11 +102,11 @@ class pkgPackageManager : protected pkgCache::Namespace
bool goResult = Go(statusFd);
if(goResult == false)
return Failed;
-
+
// if all was fine update the state file
- if(Res == Completed)
+ if(Res == Completed) {
Cache.writeStateFile(NULL);
-
+ }
return Res;
};