~ubuntu-core-dev/apt/oneiric

« back to all changes in this revision

Viewing changes to cmdline/apt-get.cc

  • Committer: Michael Vogt
  • Date: 2011-08-15 12:14:35 UTC
  • mfrom: (1327.97.57 debian-sid)
  • Revision ID: michael.vogt@ubuntu.com-20110815121435-ya00o0nicb1kiz2y
merged from the debian-sid branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
368
368
            
369
369
            if (Start == End)
370
370
               break;
371
 
            Start++;
 
371
            ++Start;
372
372
         }       
373
373
      }     
374
374
   }   
542
542
         continue;
543
543
 
544
544
      // Print out any essential package depenendents that are to be removed
545
 
      for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; D++)
 
545
      for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; ++D)
546
546
      {
547
547
         // Skip everything but depends
548
548
         if (D->Type != pkgCache::Dep::PreDepends &&
579
579
   unsigned long Downgrade = 0;
580
580
   unsigned long Install = 0;
581
581
   unsigned long ReInstall = 0;
582
 
   for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++)
 
582
   for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; ++I)
583
583
   {
584
584
      if (Dep[I].NewInstall() == true)
585
585
         Install++;
671
671
                                }
672
672
                                // if we found no candidate which provide this package, show non-candidates
673
673
                                if (provider == 0)
674
 
                                        for (I = Pkg.ProvidesList(); I.end() == false; I++)
 
674
                                        for (I = Pkg.ProvidesList(); I.end() == false; ++I)
675
675
                                                out << "  " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr()
676
676
                                                    << _(" [Not candidate version]") << endl;
677
677
                                else
687
687
                                SPtrArray<bool> Seen = new bool[Cache.GetPkgCache()->Head().PackageCount];
688
688
                                memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen));
689
689
                                for (pkgCache::DepIterator Dep = Pkg.RevDependsList();
690
 
                                     Dep.end() == false; Dep++) {
 
690
                                     Dep.end() == false; ++Dep) {
691
691
                                        if (Dep->Type != pkgCache::Dep::Replaces)
692
692
                                                continue;
693
693
                                        if (Seen[Dep.ParentPkg()->ID] == true)
874
874
struct TryToRemove {
875
875
   pkgCacheFile* Cache;
876
876
   pkgProblemResolver* Fix;
877
 
   bool FixBroken;
878
877
   bool PurgePkgs;
879
 
   unsigned long AutoMarkChanged;
880
878
 
881
879
   TryToRemove(pkgCacheFile &Cache, pkgProblemResolver *PM) : Cache(&Cache), Fix(PM),
882
880
                                PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
928
926
   List = new pkgCache::Package *[Cache->Head().PackageCount];
929
927
   memset(List,0,sizeof(*List)*Cache->Head().PackageCount);
930
928
   pkgCache::PkgIterator I = Cache->PkgBegin();
931
 
   for (;I.end() != true; I++)
 
929
   for (;I.end() != true; ++I)
932
930
      List[I->ID] = I;
933
931
 
934
932
   SortCache = *this;
960
958
      if ((DCache->PolicyBrokenCount() > 0))
961
959
      {
962
960
         // upgrade all policy-broken packages with ForceImportantDeps=True
963
 
         for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++)
 
961
         for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I)
964
962
            if ((*DCache)[I].NowPolicyBroken() == true) 
965
963
               DCache->MarkInstall(I,true,0, false, true);
966
964
      }
1051
1049
   if (_config->FindB("APT::Get::Purge",false) == true)
1052
1050
   {
1053
1051
      pkgCache::PkgIterator I = Cache->PkgBegin();
1054
 
      for (; I.end() == false; I++)
 
1052
      for (; I.end() == false; ++I)
1055
1053
      {
1056
1054
         if (I.Purge() == false && Cache[I].Mode == pkgDepCache::ModeDelete)
1057
1055
            Cache->MarkDelete(I,true);
1245
1243
   if (_config->FindB("APT::Get::Print-URIs") == true)
1246
1244
   {
1247
1245
      pkgAcquire::UriIterator I = Fetcher.UriBegin();
1248
 
      for (; I != Fetcher.UriEnd(); I++)
 
1246
      for (; I != Fetcher.UriEnd(); ++I)
1249
1247
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
1250
1248
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
1251
1249
      return true;
1269
1267
         {
1270
1268
            if ((*I)->Local == true)
1271
1269
            {
1272
 
               I++;
 
1270
               ++I;
1273
1271
               continue;
1274
1272
            }
1275
1273
 
1289
1287
      
1290
1288
      // Print out errors
1291
1289
      bool Failed = false;
1292
 
      for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
 
1290
      for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
1293
1291
      {
1294
1292
         if ((*I)->Status == pkgAcquire::Item::StatDone &&
1295
1293
             (*I)->Complete == true)
1449
1447
         // we have a default release, try to locate the pkg. we do it like
1450
1448
         // this because GetCandidateVer() will not "downgrade", that means
1451
1449
         // "apt-get source -t stable apt" won't work on a unstable system
1452
 
         for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++)
 
1450
         for (pkgCache::VerIterator Ver = Pkg.VersionList();; ++Ver)
1453
1451
         {
1454
1452
            // try first only exact matches, later fuzzy matches
1455
1453
            if (Ver.end() == true)
1470
1468
               continue;
1471
1469
 
1472
1470
            for (pkgCache::VerFileIterator VF = Ver.FileList();
1473
 
                 VF.end() == false; VF++) 
 
1471
                 VF.end() == false; ++VF)
1474
1472
            {
1475
1473
               /* If this is the status file, and the current version is not the
1476
1474
                  version in the status file (ie it is not installed, or somesuch)
1622
1620
         return false;
1623
1621
 
1624
1622
      pkgAcquire::UriIterator I = Fetcher.UriBegin();
1625
 
      for (; I != Fetcher.UriEnd(); I++)
 
1623
      for (; I != Fetcher.UriEnd(); ++I)
1626
1624
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
1627
1625
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
1628
1626
      return true;
2007
2005
               if(Start.TargetPkg().ProvidesList() != 0)
2008
2006
               {
2009
2007
                  pkgCache::PrvIterator I = Start.TargetPkg().ProvidesList();
2010
 
                  for (; I.end() == false; I++)
 
2008
                  for (; I.end() == false; ++I)
2011
2009
                  {
2012
2010
                     pkgCache::PkgIterator Pkg = I.OwnerPkg();
2013
2011
                     if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer() && 
2030
2028
 
2031
2029
               if (Start >= End)
2032
2030
                  break;
2033
 
               Start++;
 
2031
               ++Start;
2034
2032
            }
2035
2033
            
2036
2034
            if(foundInstalledInOrGroup == false)
2144
2142
 
2145
2143
   // Install everything with the install flag set
2146
2144
   pkgCache::PkgIterator I = Cache->PkgBegin();
2147
 
   for (;I.end() != true; I++)
 
2145
   for (;I.end() != true; ++I)
2148
2146
   {
2149
2147
      /* Install the package only if it is a new install, the autoupgrader
2150
2148
         will deal with the rest */
2154
2152
 
2155
2153
   /* Now install their deps too, if we do this above then order of
2156
2154
      the status file is significant for | groups */
2157
 
   for (I = Cache->PkgBegin();I.end() != true; I++)
 
2155
   for (I = Cache->PkgBegin();I.end() != true; ++I)
2158
2156
   {
2159
2157
      /* Install the package only if it is a new install, the autoupgrader
2160
2158
         will deal with the rest */
2163
2161
   }
2164
2162
   
2165
2163
   // Apply erasures now, they override everything else.
2166
 
   for (I = Cache->PkgBegin();I.end() != true; I++)
 
2164
   for (I = Cache->PkgBegin();I.end() != true; ++I)
2167
2165
   {
2168
2166
      // Remove packages 
2169
2167
      if (I->SelectedState == pkgCache::State::DeInstall ||
2180
2178
      // Hold back held packages.
2181
2179
      if (_config->FindB("APT::Ignore-Hold",false) == false)
2182
2180
      {
2183
 
         for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
 
2181
         for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; ++I)
2184
2182
         {
2185
2183
            if (I->SelectedState == pkgCache::State::Hold)
2186
2184
            {
2328
2326
   if (_config->FindB("APT::Get::Print-URIs") == true)
2329
2327
   {
2330
2328
      pkgAcquire::UriIterator I = Fetcher.UriBegin();
2331
 
      for (; I != Fetcher.UriEnd(); I++)
 
2329
      for (; I != Fetcher.UriEnd(); ++I)
2332
2330
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
2333
2331
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
2334
2332
      return true;
2446
2444
 
2447
2445
      // Load them into the fetcher
2448
2446
      for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
2449
 
           I != Lst.end(); I++)
 
2447
           I != Lst.end(); ++I)
2450
2448
      {
2451
2449
         // Try to guess what sort of file it is we are getting.
2452
2450
         if (I->Type == "dsc")
2548
2546
   if (_config->FindB("APT::Get::Print-URIs") == true)
2549
2547
   {
2550
2548
      pkgAcquire::UriIterator I = Fetcher.UriBegin();
2551
 
      for (; I != Fetcher.UriEnd(); I++)
 
2549
      for (; I != Fetcher.UriEnd(); ++I)
2552
2550
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
2553
2551
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
2554
2552
      delete[] Dsc;
2564
2562
 
2565
2563
   // Print error messages
2566
2564
   bool Failed = false;
2567
 
   for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
 
2565
   for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
2568
2566
   {
2569
2567
      if ((*I)->Status == pkgAcquire::Item::StatDone &&
2570
2568
          (*I)->Complete == true)
2593
2591
   if (Process == 0)
2594
2592
   {
2595
2593
      bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
2596
 
      for (unsigned I = 0; I != J; I++)
 
2594
      for (unsigned I = 0; I != J; ++I)
2597
2595
      {
2598
2596
         string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str());
2599
2597
         
2742
2740
         BuildDeps.push_back(rec);
2743
2741
      }
2744
2742
 
2745
 
      if (BuildDeps.size() == 0)
 
2743
      if (BuildDeps.empty() == true)
2746
2744
      {
2747
2745
         ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str());
2748
2746
         continue;
2752
2750
      vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
2753
2751
      pkgProblemResolver Fix(Cache);
2754
2752
      bool skipAlternatives = false; // skip remaining alternatives in an or group
2755
 
      for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
 
2753
      for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
2756
2754
      {
2757
2755
         bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
2758
2756
 
2931
2929
                * installed
2932
2930
                */
2933
2931
               pkgCache::PrvIterator Prv = Pkg.ProvidesList();
2934
 
               for (; Prv.end() != true; Prv++)
 
2932
               for (; Prv.end() != true; ++Prv)
2935
2933
               {
2936
2934
                  if (_config->FindB("Debug::BuildDeps",false) == true)
2937
2935
                     cout << "  Checking provider " << Prv.OwnerPkg().FullName() << endl;