~ubuntu-branches/ubuntu/natty/apt/natty

« back to all changes in this revision

Viewing changes to cmdline/apt-get.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-04-05 13:19:56 UTC
  • Revision ID: james.westby@ubuntu.com-20110405131956-u6sgfjr30zvy2fr3
Tags: 0.8.13.2ubuntu1
* merge fixes from debian-sid, most notable the handling of
  arch=all architectures in python-apt (LP: #733741)
* apt-pkg/aptconfiguration.cc:
  - fix comparing for a empty string

Show diffs side-by-side

added added

removed removed

Lines of Context:
764
764
   unsigned long AutoMarkChanged;
765
765
   APT::PackageSet doAutoInstallLater;
766
766
 
767
 
   TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM),
 
767
   TryToInstall(pkgCacheFile &Cache, pkgProblemResolver *PM, bool const &FixBroken) : Cache(&Cache), Fix(PM),
768
768
                        FixBroken(FixBroken), AutoMarkChanged(0) {};
769
769
 
770
770
   void operator() (pkgCache::VerIterator const &Ver) {
782
782
         ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"),
783
783
                  Pkg.FullName(true).c_str());
784
784
      else {
785
 
         Fix->Clear(Pkg);
786
 
         Fix->Protect(Pkg);
 
785
         if (Fix != NULL) {
 
786
            Fix->Clear(Pkg);
 
787
            Fix->Protect(Pkg);
 
788
         }
787
789
         Cache->GetDepCache()->MarkInstall(Pkg,false);
788
790
 
789
791
         if (State.Install() == false) {
871
873
   bool PurgePkgs;
872
874
   unsigned long AutoMarkChanged;
873
875
 
874
 
   TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM),
 
876
   TryToRemove(pkgCacheFile &Cache, pkgProblemResolver *PM) : Cache(&Cache), Fix(PM),
875
877
                                PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
876
878
 
877
879
   void operator() (pkgCache::VerIterator const &Ver)
878
880
   {
879
881
      pkgCache::PkgIterator Pkg = Ver.ParentPkg();
880
882
 
881
 
      Fix->Clear(Pkg);
882
 
      Fix->Protect(Pkg);
883
 
      Fix->Remove(Pkg);
 
883
      if (Fix != NULL)
 
884
      {
 
885
         Fix->Clear(Pkg);
 
886
         Fix->Protect(Pkg);
 
887
         Fix->Remove(Pkg);
 
888
      }
884
889
 
885
890
      if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
886
891
          (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
1385
1390
 
1386
1391
   if (Remove == true)
1387
1392
   {
1388
 
      TryToRemove RemoveAction(Cache, Fix);
 
1393
      TryToRemove RemoveAction(Cache, &Fix);
1389
1394
      RemoveAction(Pkg.VersionList());
1390
1395
   } else if (Cache[Pkg].CandidateVer != 0) {
1391
 
      TryToInstall InstallAction(Cache, Fix, BrokenFix);
 
1396
      TryToInstall InstallAction(Cache, &Fix, BrokenFix);
1392
1397
      InstallAction(Cache[Pkg].CandidateVerIter(Cache));
1393
1398
      InstallAction.doAutoInstall();
1394
1399
   } else
1791
1796
   bool BrokenFix = false;
1792
1797
   if (Cache->BrokenCount() != 0)
1793
1798
      BrokenFix = true;
1794
 
   
1795
 
   pkgProblemResolver Fix(Cache);
 
1799
 
 
1800
   pkgProblemResolver* Fix = NULL;
 
1801
   if (_config->FindB("APT::Get::CallResolver", true) == true)
 
1802
      Fix = new pkgProblemResolver(Cache);
1796
1803
 
1797
1804
   static const unsigned short MOD_REMOVE = 1;
1798
1805
   static const unsigned short MOD_INSTALL = 2;
1823
1830
   if (_error->PendingError() == true)
1824
1831
   {
1825
1832
      helper.showVirtualPackageErrors(Cache);
 
1833
      if (Fix != NULL)
 
1834
         delete Fix;
1826
1835
      return false;
1827
1836
   }
1828
1837
 
1837
1846
 
1838
1847
      for (unsigned short i = 0; order[i] != 0; ++i)
1839
1848
      {
1840
 
         if (order[i] == MOD_INSTALL) {
 
1849
         if (order[i] == MOD_INSTALL)
1841
1850
            InstallAction = std::for_each(verset[MOD_INSTALL].begin(), verset[MOD_INSTALL].end(), InstallAction);
 
1851
         else if (order[i] == MOD_REMOVE)
 
1852
            RemoveAction = std::for_each(verset[MOD_REMOVE].begin(), verset[MOD_REMOVE].end(), RemoveAction);
 
1853
      }
 
1854
 
 
1855
      if (Fix != NULL && _config->FindB("APT::Get::AutoSolving", true) == true)
 
1856
      {
 
1857
         for (unsigned short i = 0; order[i] != 0; ++i)
 
1858
         {
 
1859
            if (order[i] != MOD_INSTALL)
 
1860
               continue;
1842
1861
            InstallAction.propergateReleaseCandiateSwitching(helper.selectedByRelease, c0out);
1843
1862
            InstallAction.doAutoInstall();
1844
1863
         }
1845
 
         else if (order[i] == MOD_REMOVE)
1846
 
            RemoveAction = std::for_each(verset[MOD_REMOVE].begin(), verset[MOD_REMOVE].end(), RemoveAction);
1847
1864
      }
1848
1865
 
1849
1866
      if (_error->PendingError() == true)
 
1867
      {
 
1868
         if (Fix != NULL)
 
1869
            delete Fix;
1850
1870
         return false;
 
1871
      }
1851
1872
 
1852
1873
      /* If we are in the Broken fixing mode we do not attempt to fix the
1853
1874
         problems. This is if the user invoked install without -f and gave
1856
1877
      {
1857
1878
         c1out << _("You might want to run 'apt-get -f install' to correct these:") << endl;
1858
1879
         ShowBroken(c1out,Cache,false);
1859
 
 
 
1880
         if (Fix != NULL)
 
1881
            delete Fix;
1860
1882
         return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."));
1861
1883
      }
1862
 
   
1863
 
      // Call the scored problem resolver
1864
 
      Fix.InstallProtect();
1865
 
      if (Fix.Resolve(true) == false)
1866
 
         _error->Discard();
 
1884
 
 
1885
      if (Fix != NULL)
 
1886
      {
 
1887
         // Call the scored problem resolver
 
1888
         Fix->InstallProtect();
 
1889
         if (Fix->Resolve(true) == false)
 
1890
            _error->Discard();
 
1891
         delete Fix;
 
1892
      }
1867
1893
 
1868
1894
      // Now we check the state of the packages,
1869
1895
      if (Cache->BrokenCount() != 0)
3281
3307
   }
3282
3308
 
3283
3309
   // simulate user-friendly if apt-get has no root privileges
3284
 
   if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true)
 
3310
   if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true &&
 
3311
        (CmdL.FileSize() == 0 ||
 
3312
         (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
 
3313
          strcmp(CmdL.FileList[0], "changelog") != 0)))
3285
3314
   {
3286
3315
      if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
3287
3316
         cout << _("NOTE: This is only a simulation!\n"