]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
* apt-pkg/depcache.cc:
[apt.git] / apt-pkg / depcache.cc
index 369eae70b3418d3a73e86bd2a125c87e42214636..f5673dd5d1ec075d2ccce48d01a7939614719c35 100644 (file)
@@ -701,9 +701,18 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
    // We dont even try to keep virtual packages..
    if (Pkg->VersionList == 0)
       return;
-   
+
+#if 0 // reseting the autoflag here means we lose the 
+      // auto-mark information if a user selects a package for removal
+      // but changes  his mind then and sets it for keep again
+      // - this makes sense as default when all Garbage dependencies
+      //   are automatically marked for removal (as aptitude does).
+      //   setting a package for keep then makes it no longer autoinstalled
+      //   for all other use-case this action is rather suprising
    if(FromUser && !P.Marked)
      P.Flags &= ~Flag::Auto;
+#endif
+
    RemoveSizes(Pkg);
    RemoveStates(Pkg);
 
@@ -898,7 +907,22 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
               std::clog << "Installing " << InstPkg.Name() 
                         << " as dep of " << Pkg.Name() 
                         << std::endl;
-          MarkInstall(InstPkg, true, Depth + 1, false);
+           // now check if we should consider it a automatic dependency or not
+           string sec = _config->Find("APT::Never-MarkAuto-Section","");
+           if(Pkg.Section() && (string(Pkg.Section()) ==  sec))
+           {
+              if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
+                 std::clog << "Setting NOT as auto-installed because its a direct dep of a package in section " << sec << std::endl;
+              MarkInstall(InstPkg,true,Depth + 1, true);
+           }
+           else 
+           {
+              // mark automatic dependency
+              MarkInstall(InstPkg,true,Depth + 1, false);
+              // Set the autoflag, after MarkInstall because MarkInstall unsets it
+              if (P->CurrentVer == 0)
+                 PkgState[InstPkg->ID].Flags |= Flag::Auto;
+           }
         }
         continue;
       }
@@ -1264,9 +1288,13 @@ bool pkgDepCache::Sweep()
   {
      StateCache &state=PkgState[p->ID];
 
+     // skip required packages
+     if (!p.CurrentVer().end() && 
+        (p.CurrentVer()->Priority == pkgCache::State::Required))
+       continue;
+
      // if it is not marked and it is installed, it's garbage 
-     if(!state.Marked && (!p.CurrentVer().end() || state.Install()) &&
-       !state.Delete())
+     if(!state.Marked && (!p.CurrentVer().end() || state.Install()))
      {
        state.Garbage=true;
        if(_config->FindB("Debug::pkgAutoRemove",false))