]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
* apt-pkg/contrib/configuration.cc:
[apt.git] / apt-pkg / depcache.cc
index ffa4fe71c0dd119c3a6c43f3258d8c6bef1b2128..0f07de2fea80068ec2ea2048e1c74bd01e67b5af 100644 (file)
@@ -257,7 +257,22 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)     /*{{{*/
         pkgCache::PkgIterator pkg = Cache->FindPkg(pkgname, pkgarch);
         if(pkg.end() || pkg.VersionList().end()) 
            continue;
-        bool const 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")) ||
+               (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;
@@ -277,14 +292,17 @@ 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.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)
+        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)
@@ -837,13 +855,16 @@ void pkgDepCache::Update(OpProgress *Prog)
               if (P.end() == true) continue;
               for (VerIterator V = P.VersionList(); V.end() != true; ++V)
               {
-                 // FIXME: String comparison isn't a save indicator!
-                 if (strcmp(allV.VerStr(),V.VerStr()) != 0)
+                 if (allV->Hash != V->Hash ||
+                     strcmp(allV.VerStr(),V.VerStr()) != 0)
                     continue;
                  unsigned char const CurDepState = VersionState(V.DependsList(),DepInstall,DepInstMin,DepInstPolicy);
                  if ((CurDepState & DepInstMin) != DepInstMin)
                     break; // we found the correct version, but it is broken. Better try another arch or later again
+                 RemoveSizes(P);
+                 RemoveStates(P);
                  P->CurrentVer = V.Index();
+                 PkgState[P->ID].InstallVer = V;
                  AddStates(P);
                  Update(P);
                  AddSizes(P);