]> git.saurik.com Git - apt.git/commitdiff
* merged with mainline
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 26 Jun 2006 04:30:09 +0000 (06:30 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 26 Jun 2006 04:30:09 +0000 (06:30 +0200)
1  2 
apt-pkg/depcache.cc
cmdline/apt-get.cc
debian/changelog
debian/rules
doc/examples/configure-index
share/debian-archive.gpg
share/debian-archive.gpg.moved

diff --combined apt-pkg/depcache.cc
index 22dd53f9779dff3885177a139e2ce24078dcdabd,58d1d25e54ed7c2b633f39d69dee14010773589f..6eb6c1d85283029f2bfeb0037d070dc7c74748fe
  #include <apt-pkg/error.h>
  #include <apt-pkg/sptr.h>
  #include <apt-pkg/algorithms.h>
 +
 +#include <apt-pkg/fileutl.h>
  #include <apt-pkg/configuration.h>
 +#include <apt-pkg/pkgsystem.h>
 +#include <apt-pkg/tagfile.h>
 +
 +#include <iostream>
 +#include <sstream>    
  #include <apti18n.h>    
 -                                                                      /*}}}*/
 +
 +pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) :
 +  cache(cache), released(false)
 +{
 +  ++cache.group_level;
 +}
 +
 +void pkgDepCache::ActionGroup::release()
 +{
 +  if(!released)
 +    {
 +      if(cache.group_level == 0)
 +      std::cerr << "W: Unbalanced action groups, expect badness" << std::endl;
 +      else
 +      {
 +        --cache.group_level;
 +
 +        if(cache.group_level == 0)
 +          cache.MarkAndSweep();
 +      }
 +
 +      released = false;
 +    }
 +}
 +
 +pkgDepCache::ActionGroup::~ActionGroup()
 +{
 +  release();
 +}
  
  // DepCache::pkgDepCache - Constructors                                       /*{{{*/
  // ---------------------------------------------------------------------
  /* */
  pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) :
 -                Cache(pCache), PkgState(0), DepState(0)
 +  group_level(0), Cache(pCache), PkgState(0), DepState(0)
  {
     delLocalPolicy = 0;
     LocalPolicy = Plcy;
@@@ -82,10 -48,6 +83,10 @@@ pkgDepCache::~pkgDepCache(
  /* This allocats the extension buffers and initializes them. */
  bool pkgDepCache::Init(OpProgress *Prog)
  {
 +   // Suppress mark updates during this operation (just in case) and
 +   // run a mark operation when Init terminates.
 +   ActionGroup actions(*this);
 +
     delete [] PkgState;
     delete [] DepState;
     PkgState = new StateCache[Head().PackageCount];
        // Find the proper cache slot
        StateCache &State = PkgState[I->ID];
        State.iFlags = 0;
 -      
 +
        // Figure out the install version
        State.CandidateVer = GetCandidateVer(I);
        State.InstallVer = I.CurrentVer();
  
     if(Prog != 0)
        Prog->Done();
 -   
 +
     return true;
  } 
                                                                        /*}}}*/
  
 +bool pkgDepCache::readStateFile(OpProgress *Prog)
 +{
 +   FileFd state_file;
 +   string state = _config->FindDir("Dir::State") + "pkgstates";
 +   if(FileExists(state)) {
 +      state_file.Open(state, FileFd::ReadOnly);
 +      int file_size = state_file.Size();
 +      if(Prog != NULL)
 +       Prog->OverallProgress(0, file_size, 1, 
 +                             _("Reading state information"));
 +
 +      pkgTagFile tagfile(&state_file);
 +      pkgTagSection section;
 +      int amt=0;
 +      while(tagfile.Step(section)) {
 +       string pkgname = section.FindS("Package");
 +       pkgCache::PkgIterator pkg=Cache->FindPkg(pkgname);
 +       // Silently ignore unknown packages and packages with no actual
 +       // version.
 +       if(!pkg.end() && !pkg.VersionList().end()) {
 +          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;
 +          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"));
 +      }
 +   }
 +
 +   return true;
 +}
 +
 +bool pkgDepCache::writeStateFile(OpProgress *prog)
 +{
 +   FileFd StateFile;
 +   string state = _config->FindDir("Dir::State") + "pkgstates";
 +
 +   if(_config->FindB("Debug::pkgAutoRemove",false))
 +      std::clog << "pkgDepCache::writeStateFile()" << std::endl;
 +
 +   if(!StateFile.Open(state, FileFd::WriteEmpty))
 +      return _error->Error(_("Failed to write StateFile %s"),
 +                         state.c_str());
 +
 +   std::ostringstream ostr;
 +   for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end();pkg++) {
 +
 +      if(PkgState[pkg->ID].Flags & Flag::Auto) {
 +       if(_config->FindB("Debug::pkgAutoRemove",false))
 +          std::clog << "AutoInstall: " << pkg.Name() << std::endl;
 +       ostr.str(string(""));
 +       ostr << "Package: " << pkg.Name() 
 +            << "\nAuto-Installed: 1\n\n";
 +       StateFile.Write(ostr.str().c_str(), ostr.str().size());
 +      }
 +   }
 +   return true;
 +}
 +
  // DepCache::CheckDep - Checks a single dependency                    /*{{{*/
  // ---------------------------------------------------------------------
  /* This first checks the dependency against the main target package and
@@@ -557,14 -453,12 +558,14 @@@ void pkgDepCache::Update(OpProgress *Pr
  
     if (Prog != 0)      
        Prog->Progress(Done);
 +
 +   readStateFile(Prog);
  }
                                                                        /*}}}*/
  // DepCache::Update - Update the deps list of a package                       /*{{{*/
  // ---------------------------------------------------------------------
  /* This is a helper for update that only does the dep portion of the scan. 
 -   It is mainly ment to scan reverse dependencies. */
 +   It is mainly meant to scan reverse dependencies. */
  void pkgDepCache::Update(DepIterator D)
  {
     // Update the reverse deps
@@@ -616,7 -510,7 +617,7 @@@ void pkgDepCache::Update(PkgIterator co
  // DepCache::MarkKeep - Put the package in the keep state             /*{{{*/
  // ---------------------------------------------------------------------
  /* */
 -void pkgDepCache::MarkKeep(PkgIterator const &Pkg,bool Soft)
 +void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
  {
     // Simplifies other routines.
     if (Pkg.end() == true)
         Pkg.CurrentVer().Downloadable() == false)
        return;
     
 +   /** \todo Can this be moved later in the method? */
 +   ActionGroup group(*this);
 +
     /* We changed the soft state all the time so the UI is a bit nicer
        to use */
     StateCache &P = PkgState[Pkg->ID];
     if (Pkg->VersionList == 0)
        return;
     
 -   P.Flags &= ~Flag::Auto;
 +   if(FromUser && !P.Marked)
 +     P.Flags &= ~Flag::Auto;
     RemoveSizes(Pkg);
     RemoveStates(Pkg);
  
@@@ -674,8 -564,6 +675,8 @@@ void pkgDepCache::MarkDelete(PkgIterato
     if (Pkg.end() == true)
        return;
  
 +   ActionGroup group(*this);
 +
     // Check that it is not already marked for delete
     StateCache &P = PkgState[Pkg->ID];
     P.iFlags &= ~(AutoKept | Purge);
     else
        P.Mode = ModeDelete;
     P.InstallVer = 0;
 -   P.Flags &= Flag::Auto;
  
     AddStates(Pkg);   
     Update(Pkg);
  // ---------------------------------------------------------------------
  /* */
  void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 -                            unsigned long Depth)
 +                            unsigned long Depth, bool FromUser)
  {
     if (Depth > 100)
        return;
     if (Pkg.end() == true)
        return;
     
 +   ActionGroup group(*this);
 +
     /* Check that it is not already marked for install and that it can be 
        installed */
     StateCache &P = PkgState[Pkg->ID];
        P.CandidateVer == (Version *)Pkg.CurrentVer()))
     {
        if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0)
 -       MarkKeep(Pkg);
 +       MarkKeep(Pkg, false, FromUser);
        return;
     }
  
     
     P.Mode = ModeInstall;
     P.InstallVer = P.CandidateVer;
 -   P.Flags &= ~Flag::Auto;
 +
 +   if(FromUser)
 +     {
 +       // Set it to manual if it's a new install or cancelling the
 +       // removal of a garbage package.
 +       if(P.Status == 2 || (!Pkg.CurrentVer().end() && !P.Marked))
 +       P.Flags &= ~Flag::Auto;
 +     }
 +   else
 +     {
 +       // Set it to auto if this is a new install.
 +       if(P.Status == 2)
 +       P.Flags |= Flag::Auto;
 +     }
     if (P.CandidateVer == (Version *)Pkg.CurrentVer())
        P.Mode = ModeKeep;
         
            }
         }
         
--       if (InstPkg.end() == false)
++       if (InstPkg.end() == false) 
+        {
+           if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
+              std::clog << "Installing " << InstPkg.Name() 
+                        << " as dep of " << Pkg.Name() 
+                        << std::endl;
 -          MarkInstall(InstPkg,true,Depth + 1);
 -
 -          // Set the autoflag, after MarkInstall because MarkInstall unsets it
 -          if (P->CurrentVer == 0)
 -             PkgState[InstPkg->ID].Flags |= Flag::Auto;
 +         MarkInstall(InstPkg, true, Depth + 1, false);
-        
+        }
 -       
         continue;
        }
        
            PkgIterator Pkg = Ver.ParentPkg();
        
            MarkDelete(Pkg);
 -          PkgState[Pkg->ID].Flags |= Flag::Auto;
         }
         continue;
        }      
  /* */
  void pkgDepCache::SetReInstall(PkgIterator const &Pkg,bool To)
  {
 +   ActionGroup group(*this);
 +
     RemoveSizes(Pkg);
     RemoveStates(Pkg);
     
  /* */
  void pkgDepCache::SetCandidateVersion(VerIterator TargetVer)
  {
 +   ActionGroup group(*this);
 +
     pkgCache::PkgIterator Pkg = TargetVer.ParentPkg();
     StateCache &P = PkgState[Pkg->ID];
 -   
 +
     RemoveSizes(Pkg);
     RemoveStates(Pkg);
  
     Update(Pkg);
     AddSizes(Pkg);
  }
 +
 +void pkgDepCache::MarkAuto(const PkgIterator &Pkg, bool Auto)
 +{
 +  StateCache &state = PkgState[Pkg->ID];
 +
 +  ActionGroup group(*this);
 +
 +  if(Auto)
 +    state.Flags |= Flag::Auto;
 +  else
 +    state.Flags &= ~Flag::Auto;
 +}
                                                                        /*}}}*/
  // StateCache::Update - Compute the various static display things     /*{{{*/
  // ---------------------------------------------------------------------
@@@ -1003,216 -872,3 +1009,216 @@@ bool pkgDepCache::Policy::IsImportantDe
     return Dep.IsCritical();
  }
                                                                        /*}}}*/
 +
 +pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc()
 +  : constructedSuccessfully(false)
 +{
 +  Configuration::Item const *Opts;
 +  Opts = _config->Tree("APT::NeverAutoRemove");
 +  if (Opts != 0 && Opts->Child != 0)
 +    {
 +      Opts = Opts->Child;
 +      for (; Opts != 0; Opts = Opts->Next)
 +      {
 +        if (Opts->Value.empty() == true)
 +          continue;
 +
 +        regex_t *p = new regex_t;
 +        if(regcomp(p,Opts->Value.c_str(),
 +                   REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
 +          {
 +            regfree(p);
 +            delete p;
 +            _error->Error("Regex compilation error for APT::NeverAutoRemove");
 +            return;
 +          }
 +
 +        rootSetRegexp.push_back(p);
 +      }
 +    }
 +
 +  constructedSuccessfully = true;
 +}
 +
 +pkgDepCache::DefaultRootSetFunc::~DefaultRootSetFunc()
 +{
 +  for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
 +    {
 +      regfree(rootSetRegexp[i]);
 +      delete rootSetRegexp[i];
 +    }
 +}
 +
 +
 +bool pkgDepCache::DefaultRootSetFunc::InRootSet(const pkgCache::PkgIterator &pkg)
 +{
 +   for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
 +      if (regexec(rootSetRegexp[i], pkg.Name(), 0, 0, 0) == 0)
 +       return true;
 +
 +   return false;
 +}
 +
 +pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()
 +{
 +  DefaultRootSetFunc *f = new DefaultRootSetFunc;
 +  if(f->wasConstructedSuccessfully())
 +    return f;
 +  else
 +    {
 +      delete f;
 +      return NULL;
 +    }
 +}
 +
 +bool pkgDepCache::MarkFollowsRecommends()
 +{
 +  return _config->FindB("APT::AutoRemove::RecommendsImportant", true);
 +}
 +
 +bool pkgDepCache::MarkFollowsSuggests()
 +{
 +  return _config->FindB("APT::AutoRemove::SuggestsImportant", false);
 +}
 +
 +// the main mark algorithm
 +bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
 +{
 +   bool follow_recommends;
 +   bool follow_suggests;
 +
 +   // init the states
 +   for(PkgIterator p = PkgBegin(); !p.end(); ++p)
 +   {
 +      PkgState[p->ID].Marked  = false;
 +      PkgState[p->ID].Garbage = false;
 +
 +      // debug output
 +      if(_config->FindB("Debug::pkgAutoRemove",false) 
 +       && PkgState[p->ID].Flags & Flag::Auto)
 +       std::clog << "AutoDep: " << p.Name() << std::endl;
 +   }
 +
 +   // init vars
 +   follow_recommends = MarkFollowsRecommends();
 +   follow_suggests   = MarkFollowsSuggests();
 +
 +
 +
 +   // do the mark part, this is the core bit of the algorithm
 +   for(PkgIterator p = PkgBegin(); !p.end(); ++p)
 +   {
 +      if(!(PkgState[p->ID].Flags & Flag::Auto) ||
 +        (p->Flags & Flag::Essential) ||
 +        userFunc.InRootSet(p))
 +          
 +      {
 +       // the package is installed (and set to keep)
 +       if(PkgState[p->ID].Keep() && !p.CurrentVer().end())
 +          MarkPackage(p, p.CurrentVer(),
 +                      follow_recommends, follow_suggests);
 +       // the package is to be installed 
 +       else if(PkgState[p->ID].Install())
 +          MarkPackage(p, PkgState[p->ID].InstVerIter(*this),
 +                      follow_recommends, follow_suggests);
 +      }
 +   }
 +
 +   return true;
 +}
 +
 +// mark a single package in Mark-and-Sweep
 +void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
 +                            const pkgCache::VerIterator &ver,
 +                            bool follow_recommends,
 +                            bool follow_suggests)
 +{
 +   pkgDepCache::StateCache &state = PkgState[pkg->ID];
 +   VerIterator candver            = state.CandidateVerIter(*this);
 +   VerIterator instver            = state.InstVerIter(*this);
 +
 +#if 0
 +   // If a package was garbage-collected but is now being marked, we
 +   // should re-select it 
 +   // For cases when a pkg is set to upgrade and this trigger the
 +   // removal of a no-longer used dependency.  if the pkg is set to
 +   // keep again later it will result in broken deps
 +   if(state.Delete() && state.RemoveReason = Unused) 
 +   {
 +      if(ver==candver)
 +       mark_install(pkg, false, false, NULL);
 +      else if(ver==pkg.CurrentVer())
 +       MarkKeep(pkg, false, false);
 +      
 +      instver=state.InstVerIter(*this);
 +   }
 +#endif
 +
 +   // Ignore versions other than the InstVer, and ignore packages
 +   // that are already going to be removed or just left uninstalled.
 +   if(!(ver == instver && !instver.end()))
 +      return;
 +
 +   // if we are marked already we are done
 +   if(state.Marked)
 +      return;
 +
 +   //std::cout << "Setting Marked for: " << pkg.Name() << std::endl;
 +   state.Marked=true;
 +
 +   if(!ver.end())
 +   {
 +     for(DepIterator d = ver.DependsList(); !d.end(); ++d)
 +     {
 +      if(d->Type == Dep::Depends ||
 +         d->Type == Dep::PreDepends ||
 +         (follow_recommends &&
 +          d->Type == Dep::Recommends) ||
 +         (follow_suggests &&
 +          d->Type == Dep::Suggests))
 +        {
 +         // Try all versions of this package.
 +         for(VerIterator V = d.TargetPkg().VersionList(); 
 +             !V.end(); ++V)
 +         {
 +            if(_system->VS->CheckDep(V.VerStr(), d->CompareOp, d.TargetVer()))
 +            {
 +               MarkPackage(V.ParentPkg(), V, 
 +                           follow_recommends, follow_suggests);
 +            }
 +         }
 +         // Now try virtual packages
 +         for(PrvIterator prv=d.TargetPkg().ProvidesList(); 
 +             !prv.end(); ++prv)
 +         {
 +            if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp, 
 +                                     d.TargetVer()))
 +            {
 +               MarkPackage(prv.OwnerPkg(), prv.OwnerVer(),
 +                           follow_recommends, follow_suggests);
 +            }
 +         }
 +      }
 +     }
 +   }
 +}
 +
 +bool pkgDepCache::Sweep()
 +{
 +   // do the sweep
 +   for(PkgIterator p=PkgBegin(); !p.end(); ++p)
 +  {
 +     StateCache &state=PkgState[p->ID];
 +
 +     // if it is not marked and it is installed, it's garbage 
 +     if(!state.Marked && (!p.CurrentVer().end() || state.Install()) &&
 +      !state.Delete())
 +     {
 +      state.Garbage=true;
 +      if(_config->FindB("Debug::pkgAutoRemove",false))
 +         std::cout << "Garbage: " << p.Name() << std::endl;
 +     }
 +  }   
 +
 +   return true;
 +}
diff --combined cmdline/apt-get.cc
index 54c464a37e63aeb0a87819bf2b4d93aaa402c18f,d4a6bee3215152324c2ec7a38ad3d03d5ce94dc3..30d0464476aa49f7af1db4b5f247c9a592dcdb96
@@@ -38,6 -38,7 +38,7 @@@
  #include <apt-pkg/version.h>
  #include <apt-pkg/cachefile.h>
  #include <apt-pkg/sptr.h>
+ #include <apt-pkg/md5.h>
  #include <apt-pkg/versionmatch.h>
      
  #include <config.h>
@@@ -45,6 -46,7 +46,7 @@@
  
  #include "acqprogress.h"
  
+ #include <set>
  #include <locale.h>
  #include <langinfo.h>
  #include <fstream>
@@@ -58,7 -60,6 +60,7 @@@
  #include <errno.h>
  #include <regex.h>
  #include <sys/wait.h>
 +#include <sstream>
                                                                        /*}}}*/
  
  using namespace std;
@@@ -994,7 -995,7 +996,7 @@@ bool InstallPackages(CacheFile &Cache,b
         cerr << _("Unable to correct missing packages.") << endl;
         return _error->Error(_("Aborting install."));
        }
 -               
 +
        _system->UnLock();
        int status_fd = _config->FindI("APT::Status-Fd",-1);
        pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd);
@@@ -1367,7 -1368,7 +1369,7 @@@ bool DoUpdate(CommandLine &CmdL
     }
     
     // Clean out any old list files
-    if (_config->FindB("APT::Get::List-Cleanup",true) == true)
+    if (!Failed && _config->FindB("APT::Get::List-Cleanup",true) == true)
     {
        if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false ||
          Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
     return true;
  }
                                                                        /*}}}*/
 +// DoAutomaticRemove - Remove all automatic unused packages           /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Remove unused automatic packages */
 +bool DoAutomaticRemove(CacheFile &Cache)
 +{
 +   if(_config->FindI("Debug::pkgAutoRemove",false))
 +      std::cout << "DoAutomaticRemove()" << std::endl;
 +
 +   if (_config->FindB("APT::Get::Remove",true) == false)
 +      return _error->Error(_("We are not supposed to delete stuff, can't "
 +                           "start AutoRemover"));
 +
 +   {
 +     pkgDepCache::ActionGroup group(*Cache);
 +
 +     // look over the cache to see what can be removed
 +     for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
 +       {
 +       if (Cache[Pkg].Garbage)
 +         {
 +           if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
 +             fprintf(stdout,"We could delete %s\n", Pkg.Name());
 +
 +           if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles)
 +             Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false));
 +           else
 +             Cache->MarkKeep(Pkg, false, false);
 +         }
 +       }
 +   }
 +
 +   // Now see if we destroyed anything
 +   if (Cache->BrokenCount() != 0)
 +   {
 +      c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n"
 +               "shouldn't happen. Please file a bug report against apt.") << endl;
 +      c1out << endl;
 +      c1out << _("The following information may help to resolve the situation:") << endl;
 +      c1out << endl;
 +      ShowBroken(c1out,Cache,false);
 +
 +      return _error->Error(_("Internal Error, AutoRemover broke stuff"));
 +   }
 +   return true;
 +}
 +
  // DoUpgrade - Upgrade all packages                                   /*{{{*/
  // ---------------------------------------------------------------------
  /* Upgrade all packages without installing new packages or erasing old
@@@ -1456,15 -1411,6 +1458,6 @@@ bool DoUpgrade(CommandLine &CmdL
  /* Install named packages */
  bool DoInstall(CommandLine &CmdL)
  {
-    // Lock the list directory
-    FileFd Lock;
-    if (_config->FindB("Debug::NoLocking",false) == false)
-    {
-       Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock"));
-       if (_error->PendingError() == true)
-         return _error->Error(_("Unable to lock the list directory"));
-    }
-    
     CacheFile Cache;
     if (Cache.OpenForInstall() == false || 
         Cache.CheckDeps(CmdL.FileSize() != 1) == false)
     bool DefRemove = false;
     if (strcasecmp(CmdL.FileList[0],"remove") == 0)
        DefRemove = true;
 +   else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0)
 +     {
 +       _config->Set("APT::Get::AutomaticRemove", "true");
 +       DefRemove = true;
 +     }
  
     for (const char **I = CmdL.FileList + 1; *I != 0; I++)
     {
        return _error->Error(_("Broken packages"));
     }   
     
 +   if (_config->FindB("APT::Get::AutomaticRemove")) {
 +      if (!DoAutomaticRemove(Cache)) 
 +       return false;
 +   }
 +
     /* Print out a list of packages that are going to be installed extra
        to what the user asked */
     if (Cache->InstCount() != ExpectedInst)
         
         if (*J == 0) {
            List += string(I.Name()) + " ";
 -        VersionsList += string(Cache[I].CandVersion) + "\n";
 -     }
 +          VersionsList += string(Cache[I].CandVersion) + "\n";
 +       }
        }
        
        ShowList(c1out,_("The following extra packages will be installed:"),List,VersionsList);
@@@ -1956,6 -1892,9 +1949,9 @@@ bool DoSource(CommandLine &CmdL
  
     DscFile *Dsc = new DscFile[CmdL.FileSize()];
     
+    // insert all downloaded uris into this set to avoid downloading them
+    // twice
+    set<string> queued;
     // Load the requestd sources into the fetcher
     unsigned J = 0;
     for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
         if (_config->FindB("APT::Get::Tar-Only",false) == true &&
             I->Type != "tar")
            continue;
-        
+        // don't download the same uri twice (should this be moved to
+        // the fetcher interface itself?)
+        if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end())
+           continue;
+        queued.insert(Last->Index().ArchiveURI(I->Path));
+           
+        // check if we have a file with that md5 sum already localy
+        if(!I->MD5Hash.empty() && FileExists(flNotDir(I->Path)))  
+        {
+           FileFd Fd(flNotDir(I->Path), FileFd::ReadOnly);
+           MD5Summation sum;
+           sum.AddFD(Fd.Fd(), Fd.Size());
+           Fd.Close();
+           if((string)sum.Result() == I->MD5Hash) 
+           {
+              ioprintf(c1out,_("Skipping already downloaded file '%s'\n"),
+                       flNotDir(I->Path).c_str());
+              continue;
+           }
+        }
         new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
                        I->MD5Hash,I->Size,
                        Last->Index().SourceInfo(*Last,*I),Src);
@@@ -2506,7 -2466,6 +2523,7 @@@ void GetInitialize(
     _config->Set("APT::Get::Fix-Broken",false);
     _config->Set("APT::Get::Force-Yes",false);
     _config->Set("APT::Get::List-Cleanup",true);
 +   _config->Set("APT::Get::AutomaticRemove",false);
  }
                                                                        /*}}}*/
  // SigWinch - Window size change signal handler                               /*{{{*/
@@@ -2562,7 -2521,6 +2579,7 @@@ int main(int argc,const char *argv[]
        {0,"remove","APT::Get::Remove",0},
        {0,"only-source","APT::Get::Only-Source",0},
        {0,"arch-only","APT::Get::Arch-Only",0},
 +      {0,"auto-remove","APT::Get::AutomaticRemove",0},
        {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
        {'c',"config-file",0,CommandLine::ConfigFile},
        {'o',"option",0,CommandLine::ArbItem},
                                     {"upgrade",&DoUpgrade},
                                     {"install",&DoInstall},
                                     {"remove",&DoInstall},
 +                                 {"autoremove",&DoInstall},
                                     {"dist-upgrade",&DoDistUpgrade},
                                     {"dselect-upgrade",&DoDSelectUpgrade},
                                   {"build-dep",&DoBuildDep},
diff --combined debian/changelog
index ed893114bf9e0d6663e2db12f82ec97ebcf867cc,0c31db6bd7cf8181358517fcf620251b558e1756..8b11ff0da37fb181ba677161bc246d23f39e6131
+ apt (0.6.44.2) unstable; urgency=low
+   * apt-pkg/depcache.cc:
+     - added Debug::pkgDepCache::AutoInstall (thanks to infinity)
+   * merged from 
+     http://www.perrier.eu.org/debian/packages/d-i/level4/apt-main:
+       * sk.po: Completed to 512t
+       * eu.po: Completed to 512t
+       * fr.po: Completed to 512t
+       * sv.po: Completed to 512t
+       * Update all PO and the POT. Gives 506t6f for formerly
+         complete translations
+  --
+ apt (0.6.44.1-0.1) unstable; urgency=low
+   * Non-maintainer upload.
+   * Don't give an error when parsing empty Packages/Sources files.
+     (Closes: #366931, #367086, #370160)
+  -- Steinar H. Gunderson <sesse@debian.org>  Fri,  9 Jun 2006 00:52:21 +0200
+ apt (0.6.44.1) unstable; urgency=low
+   * merged from 
+     http://www.perrier.eu.org/debian/packages/d-i/level4/apt-main:
+     - po/LINGUAS: added "bg" Closes: #360262
+     - po/gl.po: Galician translation update. Closes: #366849
+     - po/hu.po: Hungarian translation update. Closes: #365448
+     - po/cs.po: Czech translation updated. Closes: #367244
+  -- Michael Vogt <mvo@debian.org>  Tue, 16 May 2006 21:51:16 +0200
+ apt (0.6.44) unstable; urgency=low
+   * apt-pkg/acquire.cc: don't show ETA if it is 0 or absurdely large
+   * apt-pkg/deb/dpkgpm.cc: 
+     - wording fixes (thanks to Matt Zimmerman)
+     - fix error in dpkg interaction (closes: #364513, 
+       thanks to Martin Dickopp)
+   * apt-pkg/tagfile.{cc,h}:
+     - use MMap to read the entries (thanks to Zephaniah E. Hull for the
+       patch) Closes: #350025
+   * Merge from http://www.perrier.eu.org/debian/packages/d-i/level4/apt-main:
+       * bg.po: Added, complete to 512t. Closes: #360262
+   * doc/apt-ftparchive.1.xml:
+     - fix documentation for "SrcPackages" -> "Sources" 
+       (thanks to Bart Martens for the patch, closes: #307756)
+   * debian/libapt-pkg-doc.doc-base.cache:
+     - remove broken charackter from description (closes: #361129)
+   * apt-inst/deb/dpkgdb.cc, methods/gpgv.cc: 
+     - i18n fixes (closes: #349298)
+   * debian/postinst: dont fail on not available
+     /usr/share/doc/apt/examples/sources.list (closes: #361130)
+   * methods/ftp.cc:
+     - unlink empty file in partial if the download failed because
+       the file is missing on the server (closes: #316337)
+   * apt-pkg/deb/debversion.cc:
+     - treats a version string with explicit zero epoch equal
+       than the same without epoch (Policy 5.6.12, closes: #363358)
+       Thanks to Lionel Elie Mamane for the patch
+   
+  -- Michael Vogt <mvo@debian.org>  Mon,  8 May 2006 22:28:53 +0200
+ apt (0.6.43.3) unstable; urgency=low
+   * Merge bubulle@debian.org--2005/apt--main--0 up to patch-186:
+     * ca.po: Completed to 512t. Closes: #351592
+     * eu.po: Completed to 512t. Closes: #350483
+     * ja.po: Completed to 512t. Closes: #349806
+     * pl.po: Completed to 512t. Closes: #349514
+     * sk.po: Completed to 512t. Closes: #349474
+     * gl.po: Completed to 512 strings Closes: #349407
+     * sv.po: Completed to 512 strings Closes: #349210
+     * ru.po: Completed to 512 strings Closes: #349154
+     * da.po: Completed to 512 strings Closes: #349084
+     * fr.po: Completed to 512 strings
+     * vi.po: Completed to 511 strings  Closes: #348968
+     * zh_CN.po: Completed to 512t. Closes: #353936
+     * it.po: Completed to 512t. Closes: #352803
+     * pt_BR.po: Completed to 512t. Closes: #352419
+     * LINGUAS: Add Welsh
+     * *.po: Updated from sources (512 strings)
+   * apt-pkg/deb/deblistparser.cc:
+     - don't explode on a DepCompareOp in a Provides line, but warn about
+       it and ignore it otherwise (thanks to James Troup for reporting it)
+   * cmdline/apt-get.cc:
+     - don't lock the lists directory in DoInstall, breaks --print-uri 
+       (thanks to James Troup for reporting it)
+   * debian/apt.dirs: create /etc/apt/sources.list.d 
+   * make apt-cache madison work without deb-src entries (#352583)
+   * cmdline/apt-get.cc: only run the list-cleaner if a update was 
+     successfull
+  -- Michael Vogt <mvo@debian.org>  Wed, 22 Feb 2006 10:13:04 +0100
+ apt (0.6.43.2) unstable; urgency=low
+   * Merge bubulle@debian.org--2005/apt--main--0 up to patch-166:
+     - en_GB.po, de.po: fix spaces errors in "Ign " translations Closes: #347258
+     - makefile: make update-po a pre-requisite of clean target so
+               that POT and PO files are always up-to-date
+     - sv.po: Completed to 511t. Closes: #346450
+     - sk.po: Completed to 511t. Closes: #346369
+     - fr.po: Completed to 511t
+     - *.po: Updated from sources (511 strings)
+     - el.po: Completed to 511 strings Closes: #344642
+     - da.po: Completed to 511 strings Closes: #348574
+     - es.po: Updated to 510t1f Closes: #348158
+     - gl.po: Completed to 511 strings Closes: #347729
+     - it.po: Yet another update Closes: #347435
+   * added debian-archive-keyring to the Recommends (closes: #347970)
+   * fixed message in apt-key to install debian-archive-keyring 
+   * typos fixed in apt-cache.8 (closes: #348348, #347349)
+   * add patch to fix http download corruption problem (thanks to
+     Petr Vandrovec, closes: #280844, #290694)
+  -- Michael Vogt <mvo@debian.org>  Thu, 19 Jan 2006 00:06:33 +0100
  apt (0.6.43.1) unstable; urgency=low
  
-   * Merge bubulle@debian.org--2005/apt--main--0 up to patch-133:
+   * Merge bubulle@debian.org--2005/apt--main--0 up to patch-148:
      * fr.po: Completed to 510 strings
+     * it.po: Completed to 510t
+     * en_GB.po: Completed to 510t
+     * cs.po: Completed to 510t
+     * zh_CN.po: Completed to 510t
+     * el.po: Updated to 510t
+     * vi.po: Updated to 383t93f34u
+     * tl.po: Completed to 510 strings (Closes: #344306)
+     * sv.po: Completed to 510 strings (Closes: #344056)
+     * LINGUAS: disabled Hebrew translation. (Closes: #313283)
+     * eu.po: Completed to 510 strings (Closes: #342091)
+   * apt-get source won't download already downloaded files again
+     (closes: #79277)
+   * share/debian-archive.gpg: new 2006 ftp-archive signing key added
+     (#345891)
+   * redownload the Release file if IMS-Hit and gpg failure
+   * deal with multiple signatures on a Release file
  
-  -- Michael Vogt <michael.vogt@ubuntu.com>  Wed, 30 Nov 2005 10:14:02 +0100
+  -- Michael Vogt <mvo@debian.org>  Fri,  6 Jan 2006 01:17:08 +0100
  
  apt (0.6.43) unstable; urgency=medium
  
@@@ -197,7 -333,6 +333,7 @@@ apt (0.6.37) breezy; urgency=lo
    * Add Welsh translation from Dafydd Harries
      (daf@muse.19inch.net--2005/apt--main--0--patch-1)
    * Change debian/bugscript to use #!/bin/bash (Closes: #313402)
 +  * Fix a incorrect example in the man-page (closes: #282918)
  
   -- Matt Zimmerman <mdz@ubuntu.com>  Tue, 24 May 2005 14:38:25 -0700
  
diff --combined debian/rules
index 94e3e2216a9c548fd675fe92ee115132bf64d7e8,a8bf88762e4fed8821d9f3f8bf480caf4cd94759..044f742d0a392c3bfe8266afd1a569c56f125fbb
@@@ -36,6 -36,7 +36,7 @@@ endi
  # Default rule
  build:
  
+ PKG=apt
  DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS)
  APT_DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p')
  APT_CONFVER=$(shell sed -n -e 's/^AC_DEFINE_UNQUOTED(VERSION,"\(.*\)")/\1/p' configure.in)
@@@ -335,6 -336,6 +336,6 @@@ cvs-mkul
  arch-build:
        rm -rf debian/arch-build
        mkdir -p debian/arch-build/apt-$(APT_DEBVER)
-       baz inventory -s | xargs cp -a --parents --target=debian/arch-build/apt-$(APT_DEBVER)
+       tar -c --exclude=arch-build --no-recursion -f - `bzr inventory` | (cd debian/arch-build/$(PKG)-$(APT_DEBVER);tar xf -)
        $(MAKE) -C debian/arch-build/apt-$(APT_DEBVER) startup doc
 -      (cd debian/arch-build/apt-$(APT_DEBVER); $(DEB_BUILD_PROG))
 +      (cd debian/arch-build/apt-$(APT_DEBVER); $(DEB_BUILD_PROG); dpkg-genchanges -S > ../apt_$(APT_DEBVER)_source.changes)
index 8a68e2892120027566872831126e1a87f2248716,b87e8503049e8ced9ce112aa9a55a57936fb2126..d9e78559dc48fdcdfcd34a07b8f74d19e0faa2a0
@@@ -24,15 -24,11 +24,15 @@@ AP
  {
    Architecture "i386";
    Build-Essential "build-essential";
 -  
 +
 +  NeverAutoRemove  { "linux-kernel.*";  };  // packages that should never
 +                                            // considered for autoRemove
 +
    // Options for apt-get
    Get 
    {
       Arch-Only "false";
 +     AutomaticRemove "false";       
       Download-Only "false";
       Simulate "false";
       Assume-Yes "false";
@@@ -248,13 -244,13 +248,14 @@@ DPk
  Debug 
  {
    pkgProblemResolver "false";
+   pkgDepCache::AutoInstall "false"; // what packages apt install to satify dependencies
    pkgAcquire "false";
    pkgAcquire::Worker "false";
    pkgDPkgPM "false";
    pkgDPkgProgressReporting "false";
    pkgOrderList "false";
 -  
 +  pkgAutoRemove "false";   // show information about automatic removes
 +
    pkgInitialize "false";   // This one will dump the configuration space
    NoLocking "false";
    Acquire::Ftp "false";    // Show ftp command traffic
diff --combined share/debian-archive.gpg
index bb5ed5033368a3699a03fe69d5e4ed70b9fc94c6,ce412117ddd0c333f393327189a18af47fc0016a..0000000000000000000000000000000000000000
deleted file mode 100644,100644
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..bb5ed5033368a3699a03fe69d5e4ed70b9fc94c6
new file mode 100644 (file)
Binary files differ