]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
merged from the mvo branch
[apt.git] / apt-pkg / depcache.cc
index e17b7b0e82308240aeadab5d2855b6671987f046..13abbe5ed2ae5c7bedf29e1614a2708ccdc5f21f 100644 (file)
@@ -129,7 +129,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
    int Done = 0;
    for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
    {
-      if (Prog != 0)
+      if (Prog != 0 && Done%20 == 0)
         Prog->Progress(Done);
       
       // Find the proper cache slot
@@ -175,6 +175,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)                   /*{{{*/
       pkgTagFile tagfile(&state_file);
       pkgTagSection section;
       int amt=0;
+      bool debug_autoremove=_config->FindB("Debug::pkgAutoRemove",false);
       while(tagfile.Step(section)) {
         string pkgname = section.FindS("Package");
         pkgCache::PkgIterator pkg=Cache->FindPkg(pkgname);
@@ -184,7 +185,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)                   /*{{{*/
            short reason = section.FindI("Auto-Installed", 0);
            if(reason > 0)
               PkgState[pkg->ID].Flags  |= Flag::Auto;
-           if(_config->FindB("Debug::pkgAutoRemove",false))
+           if(debug_autoremove)
               std::cout << "Auto-Installed : " << pkgname << std::endl;
            amt+=section.size();
            if(Prog != NULL)
@@ -202,7 +203,9 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)                   /*{{{*/
                                                                        /*}}}*/
 bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
 {
-   if(_config->FindB("Debug::pkgAutoRemove",false))
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
+   
+   if(debug_autoremove)
       std::clog << "pkgDepCache::writeStateFile()" << std::endl;
 
    FileFd StateFile;
@@ -257,14 +260,14 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)    /*{{{*/
    for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
       if(PkgState[pkg->ID].Flags & Flag::Auto) {
         if (pkgs_seen.find(pkg.Name()) != pkgs_seen.end()) {
-           if(_config->FindB("Debug::pkgAutoRemove",false))
+           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;
-        if(_config->FindB("Debug::pkgAutoRemove",false))
+        if(debug_autoremove)
            std::clog << "Writing new AutoInstall: " 
                      << pkg.Name() << std::endl;
         ostr.str(string(""));
@@ -1326,6 +1329,7 @@ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
 {
    bool follow_recommends;
    bool follow_suggests;
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
 
    // init the states
    for(PkgIterator p = PkgBegin(); !p.end(); ++p)
@@ -1334,8 +1338,7 @@ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
       PkgState[p->ID].Garbage = false;
 
       // debug output
-      if(_config->FindB("Debug::pkgAutoRemove",false) 
-        && PkgState[p->ID].Flags & Flag::Auto)
+      if(debug_autoremove && PkgState[p->ID].Flags & Flag::Auto)
         std::clog << "AutoDep: " << p.Name() << std::endl;
    }
 
@@ -1406,7 +1409,9 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
    if(state.Marked)
       return;
 
-   if(_config->FindB("Debug::pkgAutoRemove",false))
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove", false);
+   
+   if(debug_autoremove)
      {
        std::clog << "Marking: " << pkg.Name();
        if(!ver.end())
@@ -1437,7 +1442,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
           {
              if(_system->VS->CheckDep(V.VerStr(), d->CompareOp, d.TargetVer()))
              {
-               if(_config->FindB("Debug::pkgAutoRemove",false))
+               if(debug_autoremove)
                  {
                    std::clog << "Following dep: " << d.ParentPkg().Name()
                              << " " << d.ParentVer().VerStr() << " "
@@ -1461,7 +1466,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
              if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp, 
                                       d.TargetVer()))
              {
-               if(_config->FindB("Debug::pkgAutoRemove",false))
+               if(debug_autoremove)
                  {
                    std::clog << "Following dep: " << d.ParentPkg().Name()
                              << " " << d.ParentVer().VerStr() << " "
@@ -1489,9 +1494,11 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
                                                                        /*}}}*/
 bool pkgDepCache::Sweep()                                              /*{{{*/
 {
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
+
    // do the sweep
    for(PkgIterator p=PkgBegin(); !p.end(); ++p)
-  {
+   {
      StateCache &state=PkgState[p->ID];
 
      // skip required packages
@@ -1503,7 +1510,7 @@ bool pkgDepCache::Sweep()                                         /*{{{*/
      if(!state.Marked && (!p.CurrentVer().end() || state.Install()))
      {
        state.Garbage=true;
-       if(_config->FindB("Debug::pkgAutoRemove",false))
+       if(debug_autoremove)
           std::cout << "Garbage: " << p.Name() << std::endl;
      }
   }