Просмотр исходного кода

* moved most of the real work into depcache::writeStateFile

Michael Vogt лет назад: 21
Родитель
Сommit
80fa0d8a1a
3 измененных файлов с 24 добавлено и 4 удалено
  1. 11 0
      apt-pkg/algorithms.cc
  2. 11 0
      apt-pkg/depcache.cc
  3. 2 4
      cmdline/apt-get.cc

+ 11 - 0
apt-pkg/algorithms.cc

@@ -1061,6 +1061,17 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
       return _error->Error(_("Unable to correct problems, you have held broken packages."));
    }
    
+   // set the auto-flags (mvo: I'm not sure if we _really_ need this, but
+   // I didn't managed 
+   pkgCache::PkgIterator I = Cache.PkgBegin();
+   for (;I.end() != true; I++) {
+      if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) {
+	 std::cout << "Resolve installed new pkg: " << I.Name() << " (now marking it as auto)" << std::endl;
+	 Cache[I].Flags |= pkgCache::Flag::Auto;
+      }
+   }
+
+
    return true;
 }
 									/*}}}*/

+ 11 - 0
apt-pkg/depcache.cc

@@ -151,6 +151,17 @@ 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].AutomaticRemove = pkgCache::State::RemoveUnknown;
+
+      // check if we have new information
+      if(PkgState[pkg->ID].Flags & pkgCache::Flag::Auto) {
+	 std::cout << "pkg: " << pkg.Name() << " is auto-dep" << std::endl;
+	 PkgState[pkg->ID].AutomaticRemove = pkgCache::State::RemoveRequired;
+      }
+
       if(PkgState[pkg->ID].AutomaticRemove != pkgCache::State::RemoveUnknown) {
 	 ostr.str(string(""));
 	 ostr << "Package: " << pkg.Name()

+ 2 - 4
cmdline/apt-get.cc

@@ -1703,10 +1703,8 @@ bool DoInstall(CommandLine &CmdL)
 	 
 	 if (*J == 0) {
 	    List += string(I.Name()) + " ";
-	    // mark each pkg as auto-installed 
-	    Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired;
-        VersionsList += string(Cache[I].CandVersion) + "\n";
-     }
+	    VersionsList += string(Cache[I].CandVersion) + "\n";
+	 }
       }
       
       ShowList(c1out,_("The following extra packages will be installed:"),List,VersionsList);