]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
test/test-indexes.sh: Stop hardcoding archive gpg key ID, get it from first failed...
[apt.git] / apt-pkg / depcache.cc
index e17b7b0e82308240aeadab5d2855b6671987f046..0f30f13c244f824fb7aed35e6b836f7b1ca859d9 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,17 +185,17 @@ 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))
-              std::cout << "Auto-Installed : " << pkgname << std::endl;
+           if(debug_autoremove)
+              std::clog << "Auto-Installed : " << pkgname << std::endl;
            amt+=section.size();
            if(Prog != NULL)
               Prog->OverallProgress(amt, file_size, 1, 
                                     _("Reading state information"));
         }
-        if(Prog != NULL)
-           Prog->OverallProgress(file_size, file_size, 1, 
-                                 _("Reading state information"));
       }
+      if(Prog != NULL)
+        Prog->OverallProgress(file_size, file_size, 1,
+                              _("Reading state information"));
    }
 
    return true;
@@ -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;
@@ -240,7 +243,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)      /*{{{*/
            continue;
         bool newAuto = (PkgState[pkg->ID].Flags & Flag::Auto);
         if(_config->FindB("Debug::pkgAutoRemove",false))
-           std::clog << "Update exisiting AutoInstall info: " 
+           std::clog << "Update existing AutoInstall info: " 
                      << pkg.Name() << std::endl;
         TFRewriteData rewrite[2];
         rewrite[0].Tag = "Auto-Installed";
@@ -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(""));
@@ -820,7 +823,7 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge,
 bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
                              unsigned long Depth, bool FromUser)
 {
-   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold)
+   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false)
    {
       if (DebugMarker == true)
         std::clog << OutputInDepth(Depth) << "Hold prevents MarkDelete of " << Pkg << " FU=" << FromUser << std::endl;
@@ -1082,7 +1085,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst,
                              unsigned long Depth, bool FromUser)
 {
-   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold)
+   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false)
    {
       if (DebugMarker == true)
         std::clog << OutputInDepth(Depth) << "Hold prevents MarkInstall of " << Pkg << " FU=" << FromUser << std::endl;
@@ -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,8 +1510,8 @@ bool pkgDepCache::Sweep()                                         /*{{{*/
      if(!state.Marked && (!p.CurrentVer().end() || state.Install()))
      {
        state.Garbage=true;
-       if(_config->FindB("Debug::pkgAutoRemove",false))
-          std::cout << "Garbage: " << p.Name() << std::endl;
+       if(debug_autoremove)
+          std::clog << "Garbage: " << p.Name() << std::endl;
      }
   }