~ubuntu-branches/ubuntu/trusty/apt/trusty

« back to all changes in this revision

Viewing changes to apt-pkg/depcache.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt, Michael Vogt, David Kalnischkies
  • Date: 2010-06-10 14:02:22 UTC
  • mto: (1.4.5 sid)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20100610140222-hb01wb7kfe3eocrv
Tags: 0.7.26~exp6
[ Michael Vogt ]
* merge the remaining Ubuntu change:
  - on gpg verification failure warn and restore the last known
    good state
  - on failure display the IP of the server (useful for servers
    that use round robin DNS)
  - support Original-Maintainer in RewritePackageOrder
  - enable cdrom autodetection via libudev by default
  - show message about Vcs in use when apt-get source is run for
    packages maintained in a Vcs
  - better support transitional packages with mark auto-installed. 
    when the transitional package is in "oldlibs" the new package
    is not marked auto installed (same is true for section
    metapackages)
  - provide new "deb mirror://archive.foo/mirrors.list sid main"
    method expects a list of mirrors (generated on the server e.g.
    via geoip) and will use that, including cycle on failure
  - write apport crash file on package failure (disabled by default
    on debian until apport is available)
  - support mirror failure reporting (disabled by default on debian)

[ David Kalnischkies ]
* apt-pkg/deb/dpkgpm.cc:
  - write Disappeared also to the history.log
  - forward manual-installed bit on package disappearance
* apt-pkg/deb/debsystem.cc:
  - add better config item for extended_states file
* apt-pkg/pkgcache.h:
  - switch {,Install-}Size to unsigned long long
* apt-pkg/depcache.cc:
  - do the autoremove mark process also for required packages to handle
    these illegally depending on lower priority packages (Closes: #583517)
  - try harder to find the other pseudo versions for autoremove multiarch
  - correct "Dangerous iterator usage" pointed out by cppcheck
  - deal with long long, not with int to remove 2GB Limit (LP: #250909)
  - deprecate AddSize with Multiplier as it is unused and switch to
    boolean instead to handle the sizes more gracefully.
  - switch i{Download,Usr}Size from double to (un)signed long long
* apt-pkg/aptconfiguration.cc:
  - remove duplicate architectures in getArchitectures()
* apt-pkg/indexrecords.{cc,h}:
  - backport forgotten Valid-Until patch from the obsolete experimental
    branch to prevent replay attacks better, thanks to Thomas Viehmann
    for the initial patch! (Closes: #499897)
  - add a constant Exists check for MetaKeys
* apt-pkg/acquire-item.cc:
  - do not try PDiff if it is not listed in the Meta file
  - sent Last-Modified header also for Translation files
* apt-pkg/cacheiterator.h:
  - let pkgCache::Iterator inherent std::iterator
* ftparchive/writer.h:
  - add a virtual destructor to FTWScanner class (for cppcheck)
* apt-pkg/cacheset.{cc,h}:
  - add simple wrapper around std::set for cache structures
  - move regex magic from apt-get to new FromRegEx method
  - move cmdline parsing from apt-cache to new FromCommandLine method
  - support special release-modifier 'installed' and 'candidate'
* apt-pkg/contrib/cmdline.cc:
  - fix segfault in SaveInConfig caused by writing over char[] sizes
* apt-pkg/pkgcache.cc:
  - get the best matching arch package from a group with FindPreferredPkg
* cmdline/apt-cache.cc:
  - make the search multiarch compatible by using GrpIterator instead
  - use pkgCacheFile and the new CacheSets all over the place
  - add --target-release option (Closes: #115520)
  - accept pkg/release and pkg=version in show and co. (Closes: #236270)
  - accept package versions in the unmet command
* cmdline/apt-get.cc:
  - use unsigned long long instead of double to store values it gets
* apt-pkg/cachefile.{cc,h}:
  - split Open() into submethods to be able to build only parts
  - make the OpProgress optional in the Cache buildprocess
  - store also the SourceList we use internally for export
* doc/apt.conf.5.xml:
  - document the new Valid-Until related options
* apt-pkg/contrib/strutl.cc:
  - split StrToTime() into HTTP1.1 and FTP date parser methods and
    use strptime() instead of some self-made scanf mangling
  - use the portable timegm shown in his manpage instead of a strange
    looking code copycat from wget
* ftparchive/writer.cc:
  - add ValidTime option to generate a Valid-Until header in Release file
* apt-pkg/policy.cc:
  - get the candidate right for a not-installed pseudo package if
    his non-pseudo friend is installed
* apt-pkg/indexcopy.cc:
  - move the gpg codecopy to a new method and use it also in methods/gpgv.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
bool pkgDepCache::readStateFile(OpProgress *Prog)                       /*{{{*/
166
166
{
167
167
   FileFd state_file;
168
 
   string const state = _config->FindDir("Dir::State") + "extended_states";
 
168
   string const state = _config->FindFile("Dir::State::extended_states");
169
169
   if(FileExists(state)) {
170
170
      state_file.Open(state, FileFd::ReadOnly);
171
171
      int const file_size = state_file.Size();
222
222
      std::clog << "pkgDepCache::writeStateFile()" << std::endl;
223
223
 
224
224
   FileFd StateFile;
225
 
   string const state = _config->FindDir("Dir::State") + "extended_states";
 
225
   string const state = _config->FindFile("Dir::State::extended_states");
226
226
 
227
227
   // if it does not exist, create a empty one
228
228
   if(!FileExists(state)) 
407
407
                                                                        /*}}}*/
408
408
// DepCache::AddSizes - Add the packages sizes to the counters          /*{{{*/
409
409
// ---------------------------------------------------------------------
410
 
/* Call with Mult = -1 to preform the inverse opration */
411
 
void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
412
 
{
413
 
   StateCache &P = PkgState[Pkg->ID];
414
 
   
415
 
   if (Pkg->VersionList == 0)
416
 
      return;
417
 
   
418
 
   if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && 
419
 
       P.Keep() == true)
420
 
      return;
421
 
   
422
 
   // Compute the size data
423
 
   if (P.NewInstall() == true)
424
 
   {
425
 
      iUsrSize += (signed)(Mult*P.InstVerIter(*this)->InstalledSize);
426
 
      iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
427
 
      return;
428
 
   }
429
 
   
430
 
   // Upgrading
431
 
   if (Pkg->CurrentVer != 0 && 
432
 
       (P.InstallVer != (Version *)Pkg.CurrentVer() || 
433
 
        (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
434
 
   {
435
 
      iUsrSize += (signed)(Mult*((signed)P.InstVerIter(*this)->InstalledSize - 
436
 
                        (signed)Pkg.CurrentVer()->InstalledSize));
437
 
      iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
438
 
      return;
439
 
   }
440
 
   
441
 
   // Reinstall
442
 
   if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
443
 
       P.Delete() == false)
444
 
   {
445
 
      iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
446
 
      return;
447
 
   }
448
 
   
449
 
   // Removing
450
 
   if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
451
 
   {
452
 
      iUsrSize -= (signed)(Mult*Pkg.CurrentVer()->InstalledSize);
 
410
/* Call with Mult = -1 to preform the inverse opration
 
411
   The Mult increases the complexity of the calulations here and is unused -
 
412
   or do we really have a usecase for removing the size of a package two
 
413
   times? So let us replace it with a simple bool and be done with it… */
 
414
__deprecated void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
 
415
{
 
416
   StateCache &P = PkgState[Pkg->ID];
 
417
   
 
418
   if (Pkg->VersionList == 0)
 
419
      return;
 
420
   
 
421
   if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && 
 
422
       P.Keep() == true)
 
423
      return;
 
424
   
 
425
   // Compute the size data
 
426
   if (P.NewInstall() == true)
 
427
   {
 
428
      iUsrSize += (signed long long)(Mult*P.InstVerIter(*this)->InstalledSize);
 
429
      iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
 
430
      return;
 
431
   }
 
432
   
 
433
   // Upgrading
 
434
   if (Pkg->CurrentVer != 0 && 
 
435
       (P.InstallVer != (Version *)Pkg.CurrentVer() || 
 
436
        (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
 
437
   {
 
438
      iUsrSize += (signed long long)(Mult*((signed long long)P.InstVerIter(*this)->InstalledSize - 
 
439
                        (signed long long)Pkg.CurrentVer()->InstalledSize));
 
440
      iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
 
441
      return;
 
442
   }
 
443
   
 
444
   // Reinstall
 
445
   if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
 
446
       P.Delete() == false)
 
447
   {
 
448
      iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
 
449
      return;
 
450
   }
 
451
   
 
452
   // Removing
 
453
   if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
 
454
   {
 
455
      iUsrSize -= (signed long long)(Mult*Pkg.CurrentVer()->InstalledSize);
 
456
      return;
 
457
   }   
 
458
}
 
459
                                                                        /*}}}*/
 
460
// DepCache::AddSizes - Add the packages sizes to the counters          /*{{{*/
 
461
// ---------------------------------------------------------------------
 
462
/* Call with Inverse = true to preform the inverse opration */
 
463
void pkgDepCache::AddSizes(const PkgIterator &Pkg, bool const &Inverse)
 
464
{
 
465
   StateCache &P = PkgState[Pkg->ID];
 
466
   
 
467
   if (Pkg->VersionList == 0)
 
468
      return;
 
469
   
 
470
   if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && 
 
471
       P.Keep() == true)
 
472
      return;
 
473
   
 
474
   // Compute the size data
 
475
   if (P.NewInstall() == true)
 
476
   {
 
477
      if (Inverse == false) {
 
478
         iUsrSize += P.InstVerIter(*this)->InstalledSize;
 
479
         iDownloadSize += P.InstVerIter(*this)->Size;
 
480
      } else {
 
481
         iUsrSize -= P.InstVerIter(*this)->InstalledSize;
 
482
         iDownloadSize -= P.InstVerIter(*this)->Size;
 
483
      }
 
484
      return;
 
485
   }
 
486
   
 
487
   // Upgrading
 
488
   if (Pkg->CurrentVer != 0 && 
 
489
       (P.InstallVer != (Version *)Pkg.CurrentVer() || 
 
490
        (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
 
491
   {
 
492
      if (Inverse == false) {
 
493
         iUsrSize -= Pkg.CurrentVer()->InstalledSize;
 
494
         iUsrSize += P.InstVerIter(*this)->InstalledSize;
 
495
         iDownloadSize += P.InstVerIter(*this)->Size;
 
496
      } else {
 
497
         iUsrSize -= P.InstVerIter(*this)->InstalledSize;
 
498
         iUsrSize += Pkg.CurrentVer()->InstalledSize;
 
499
         iDownloadSize -= P.InstVerIter(*this)->Size;
 
500
      }
 
501
      return;
 
502
   }
 
503
   
 
504
   // Reinstall
 
505
   if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
 
506
       P.Delete() == false)
 
507
   {
 
508
      if (Inverse == false)
 
509
         iDownloadSize += P.InstVerIter(*this)->Size;
 
510
      else
 
511
         iDownloadSize -= P.InstVerIter(*this)->Size;
 
512
      return;
 
513
   }
 
514
   
 
515
   // Removing
 
516
   if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
 
517
   {
 
518
      if (Inverse == false)
 
519
         iUsrSize -= Pkg.CurrentVer()->InstalledSize;
 
520
      else
 
521
         iUsrSize += Pkg.CurrentVer()->InstalledSize;
453
522
      return;
454
523
   }   
455
524
}
806
875
                a bit we increase with a kill, but we should do something more clever… */
807
876
      while(recheck.empty() == false)
808
877
         for (std::set<unsigned long>::const_iterator p = recheck.begin();
809
 
             p != recheck.end(); ++p) {
 
878
             p != recheck.end();) {
810
879
            if (Prog != 0 && Done%20 == 0)
811
880
               Prog->Progress(Done);
812
881
            PkgIterator P = PkgIterator(*Cache, Cache->PkgP + *p);
814
883
               ++killed;
815
884
               ++Done;
816
885
            }
817
 
            recheck.erase(p);
 
886
            recheck.erase(p++);
818
887
         }
819
888
 
820
889
      /* Okay, we have killed a great amount of pseudopackages -
849
918
         unsigned long const G = *g;
850
919
         recheck.erase(g);
851
920
         if (unlikely(ReInstallPseudoForGroup(G, recheck) == false))
852
 
            _error->Warning(_("Internal error, group '%s' has no installable pseudo package"), GrpIterator(*Cache, Cache->GrpP + *g).Name());
 
921
            _error->Warning(_("Internal error, group '%s' has no installable pseudo package"), GrpIterator(*Cache, Cache->GrpP + G).Name());
853
922
      }
854
923
   }
855
924
 
1638
1707
   {
1639
1708
      if(!(PkgState[p->ID].Flags & Flag::Auto) ||
1640
1709
          (p->Flags & Flag::Essential) ||
1641
 
          userFunc.InRootSet(p))
1642
 
          
 
1710
          userFunc.InRootSet(p) ||
 
1711
          // be nice even then a required package violates the policy (#583517)
 
1712
          // and do the full mark process also for required packages
 
1713
          (p.CurrentVer().end() != true &&
 
1714
           p.CurrentVer()->Priority == pkgCache::State::Required))
1643
1715
      {
1644
1716
         // the package is installed (and set to keep)
1645
1717
         if(PkgState[p->ID].Keep() && !p.CurrentVer().end())
1716
1788
 
1717
1789
   // If the version belongs to a Multi-Arch all package
1718
1790
   // we will mark all others in this Group with this version also
1719
 
   // Beware: We compare versions here the lazy way: string comparision
1720
 
   // this is bad if multiple repositories provide different versions
1721
 
   // of the package with an identical version number - but even in this
1722
 
   // case the dependencies are likely the same.
1723
1791
   if (ver->MultiArch == pkgCache::Version::All &&
1724
1792
        strcmp(ver.Arch(true), "all") == 0)
1725
1793
   {
1731
1799
         for (VerIterator V = P.VersionList();
1732
1800
              V.end() != true; ++V)
1733
1801
         {
1734
 
            if (strcmp(VerStr, V.VerStr()) != 0)
 
1802
            if (ver->Hash != V->Hash ||
 
1803
                strcmp(VerStr, V.VerStr()) != 0)
1735
1804
               continue;
1736
1805
            MarkPackage(P, V, follow_recommends, follow_suggests);
1737
1806
            break;