summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-03-14 21:48:14 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-03-14 21:48:14 +0100
commitc176c4d0adad246ac0768f9e2b60aa8e4c56fffb (patch)
treeda08c8a9b514a8f6347271defe0f596590a2eb40
parent7f912c325b207beac9deb5daafb7ec34b9db067a (diff)
* apt-pkg/depcache.cc:
- remove Auto-Installed information from extended_states together with the package itself (Closes: #572364)
-rw-r--r--apt-pkg/depcache.cc31
-rw-r--r--apt-pkg/depcache.h2
-rw-r--r--apt-pkg/tagfile.cc13
-rw-r--r--apt-pkg/tagfile.h15
-rw-r--r--debian/changelog3
5 files changed, 44 insertions, 20 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 5943d858a..e9fb5f76a 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -235,16 +235,30 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
std::set<string> pkgs_seen;
const char *nullreorderlist[] = {0};
while(tagfile.Step(section)) {
- string pkgname = section.FindS("Package");
+ string const pkgname = section.FindS("Package");
// Silently ignore unknown packages and packages with no actual
// version.
pkgCache::PkgIterator pkg=Cache->FindPkg(pkgname);
if(pkg.end() || pkg.VersionList().end())
continue;
- bool newAuto = (PkgState[pkg->ID].Flags & Flag::Auto);
+ 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")))
+ continue;
+ else
+ newAuto = false;
+ }
if(_config->FindB("Debug::pkgAutoRemove",false))
std::clog << "Update existing AutoInstall info: "
- << pkg.Name() << std::endl;
+ << pkgname << std::endl;
TFRewriteData rewrite[2];
rewrite[0].Tag = "Auto-Installed";
rewrite[0].Rewrite = newAuto ? "1" : "0";
@@ -258,15 +272,18 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
// then write the ones we have not seen yet
std::ostringstream ostr;
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
- if(PkgState[pkg->ID].Flags & Flag::Auto) {
+ StateCache const &P = PkgState[pkg->ID];
+ if(P.Flags & Flag::Auto) {
if (pkgs_seen.find(pkg.Name()) != pkgs_seen.end()) {
if(debug_autoremove)
std::clog << "Skipping already written " << pkg.Name() << std::endl;
continue;
}
- // skip not installed ones if requested
- if(InstalledOnly && pkg->CurrentVer == 0)
- continue;
+ // skip not installed ones if requested
+ if (InstalledOnly && (
+ (pkg->CurrentVer == 0 && P.Mode != ModeInstall) ||
+ (pkg->CurrentVer != 0 && P.Mode == ModeDelete)))
+ continue;
if(debug_autoremove)
std::clog << "Writing new AutoInstall: "
<< pkg.Name() << std::endl;
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 0306861a1..fd1f202be 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -447,7 +447,7 @@ class pkgDepCache : protected pkgCache::Namespace
// read persistent states
bool readStateFile(OpProgress *prog);
- bool writeStateFile(OpProgress *prog, bool InstalledOnly=false);
+ bool writeStateFile(OpProgress *prog, bool InstalledOnly=true);
// Size queries
inline double UsrSize() {return iUsrSize;};
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 7c5d15a58..0d4999ee7 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -193,17 +193,8 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
/*}}}*/
// TagSection::Scan - Scan for the end of the header information /*{{{*/
// ---------------------------------------------------------------------
-/* This looks for the first double new line in the data stream. It also
- indexes the tags in the section. This very simple hash function for the
- last 8 letters gives very good performance on the debian package files */
-inline static unsigned long AlphaHash(const char *Text, const char *End = 0)
-{
- unsigned long Res = 0;
- for (; Text != End && *Text != ':' && *Text != 0; Text++)
- Res = ((unsigned long)(*Text) & 0xDF) ^ (Res << 1);
- return Res & 0xFF;
-}
-
+/* This looks for the first double new line in the data stream.
+ It also indexes the tags in the section. */
bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
{
const char *End = Start + MaxLength;
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index 321329a23..f63a51d07 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -33,7 +33,18 @@ class pkgTagSection
unsigned int AlphaIndexes[0x100];
unsigned int TagCount;
-
+
+ /* This very simple hash function for the last 8 letters gives
+ very good performance on the debian package files */
+ inline static unsigned long AlphaHash(const char *Text, const char *End = 0)
+ {
+ unsigned long Res = 0;
+ for (; Text != End && *Text != ':' && *Text != 0; Text++)
+ Res = ((unsigned long)(*Text) & 0xDF) ^ (Res << 1);
+ return Res & 0xFF;
+ }
+
+
protected:
const char *Stop;
@@ -54,6 +65,8 @@ class pkgTagSection
virtual void TrimRecord(bool BeforeRecord, const char* &End);
inline unsigned int Count() const {return TagCount;};
+ inline bool Exists(const char* const Tag) {return AlphaIndexes[AlphaHash(Tag)] != 0;}
+
inline void Get(const char *&Start,const char *&Stop,unsigned int I) const
{Start = Section + Indexes[I]; Stop = Section + Indexes[I+1];}
diff --git a/debian/changelog b/debian/changelog
index 142577e42..415a6fd8d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,9 @@ apt (0.7.26) UNRELEASED; urgency=low
[ David Kalnischkies ]
* Switch to dpkg-source 3.0 (native) format
+ * apt-pkg/depcache.cc:
+ - remove Auto-Installed information from extended_states
+ together with the package itself (Closes: #572364)
* cmdline/apt-mark:
- don't crash if no arguments are given (Closes: #570962)
* debian/control: