]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
Bug fixes
[apt.git] / cmdline / apt-get.cc
index 18888b4d942a8ee3a70cace8a5f8d1ccb04c75ea..652e86e48544a80f4374790d476cdae99439c200 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-get.cc,v 1.72 1999/08/04 05:37:18 jgg Exp $
+// $Id: apt-get.cc,v 1.77 1999/09/30 06:30:34 jgg Exp $
 /* ######################################################################
    
    apt-get - Cover for dpkg
@@ -154,7 +154,7 @@ bool ShowList(ostream &out,string Title,string List)
 /* This prints out the names of all the packages that are broken along
    with the name of each each broken dependency and a quite version 
    description. */
-void ShowBroken(ostream &out,CacheFile &Cache)
+void ShowBroken(ostream &out,CacheFile &Cache,bool Now)
 {
    out << "Sorry, but the following packages have unmet dependencies:" << endl;
    for (unsigned J = 0; J < Cache->Head().PackageCount; J++)
@@ -198,15 +198,14 @@ void ShowBroken(ostream &out,CacheFile &Cache)
            ")";
         
         /* Show a summary of the target package if possible. In the case
-         of virtual packages we show nothing */
-        
+           of virtual packages we show nothing */       
         pkgCache::PkgIterator Targ = End.TargetPkg();
         if (Targ->ProvidesList == 0)
         {
            out << " but ";
            pkgCache::VerIterator Ver = Cache[Targ].InstVerIter(Cache);
            if (Ver.end() == false)
-              out << Ver.VerStr() << " is installed";
+              out << Ver.VerStr() << (Now?" is installed":" is to be installed");
            else
            {
               if (Cache[Targ].CandidateVerIter(Cache).end() == true)
@@ -217,7 +216,7 @@ void ShowBroken(ostream &out,CacheFile &Cache)
                     out << "it is a virtual package";
               }                  
               else
-                 out << "it is not installed";
+                 out << (Now?"it is not installed":"it is not going to be installed");
            }          
         }
         
@@ -270,15 +269,16 @@ void ShowDel(ostream &out,CacheFile &Cache)
 // ShowKept - Show kept packages                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void ShowKept(ostream &out,pkgDepCache &Dep)
+void ShowKept(ostream &out,CacheFile &Cache)
 {
-   pkgCache::PkgIterator I = Dep.PkgBegin();
    string List;
-   for (;I.end() != true; I++)
+   for (unsigned J = 0; J < Cache->Head().PackageCount; J++)
    {    
+      pkgCache::PkgIterator I(Cache,Cache.List[J]);
+      
       // Not interesting
-      if (Dep[I].Upgrade() == true || Dep[I].Upgradable() == false ||
-         I->CurrentVer == 0 || Dep[I].Delete() == true)
+      if (Cache[I].Upgrade() == true || Cache[I].Upgradable() == false ||
+         I->CurrentVer == 0 || Cache[I].Delete() == true)
         continue;
       
       List += string(I.Name()) + " ";
@@ -466,7 +466,7 @@ bool CacheFile::CheckDeps(bool AllowBroken)
       if (pkgFixBroken(*Cache) == false || Cache->BrokenCount() != 0)
       {
         c1out << " failed." << endl;
-        ShowBroken(c1out,*this);
+        ShowBroken(c1out,*this,true);
 
         return _error->Error("Unable to correct dependencies");
       }
@@ -478,7 +478,7 @@ bool CacheFile::CheckDeps(bool AllowBroken)
    else
    {
       c1out << "You might want to run `apt-get -f install' to correct these." << endl;
-      ShowBroken(c1out,*this);
+      ShowBroken(c1out,*this,true);
 
       return _error->Error("Unmet dependencies. Try using -f.");
    }
@@ -521,7 +521,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
    // Sanity check
    if (Cache->BrokenCount() != 0)
    {
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
       return _error->Error("Internal Error, InstallPackages was called with broken packages!");
    }
 
@@ -773,6 +773,8 @@ bool DoUpdate(CommandLine &)
 
       (*I)->Finished();
       
+      cerr << "Failed to fetch " << (*I)->DescURI() << endl;
+      cerr << "  " << (*I)->ErrorText << endl;
       Failed = true;
    }
    
@@ -807,7 +809,7 @@ bool DoUpgrade(CommandLine &CmdL)
    // Do the upgrade
    if (pkgAllUpgrade(Cache) == false)
    {
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
       return _error->Error("Internal Error, AllUpgrade broke stuff");
    }
    
@@ -950,7 +952,7 @@ bool DoInstall(CommandLine &CmdL)
    if (BrokenFix == true && Cache->BrokenCount() != 0)
    {
       c1out << "You might want to run `apt-get -f install' to correct these:" << endl;
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
 
       return _error->Error("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).");
    }
@@ -977,7 +979,7 @@ bool DoInstall(CommandLine &CmdL)
 
       c1out << "The following information may help to resolve the situation:" << endl;
       c1out << endl;
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
       return _error->Error("Sorry, broken packages");
    }   
    
@@ -1024,7 +1026,7 @@ bool DoDistUpgrade(CommandLine &CmdL)
    if (pkgDistUpgrade(*Cache) == false)
    {
       c0out << "Failed" << endl;
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
       return false;
    }
    
@@ -1092,7 +1094,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
    
       if (Fix.Resolve() == false)
       {
-        ShowBroken(c1out,Cache);
+        ShowBroken(c1out,Cache,false);
         return _error->Error("Internal Error, problem resolver broke stuff");
       }
    }
@@ -1100,7 +1102,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
    // Now upgrade everything
    if (pkgAllUpgrade(Cache) == false)
    {
-      ShowBroken(c1out,Cache);
+      ShowBroken(c1out,Cache,false);
       return _error->Error("Internal Error, problem resolver broke stuff");
    }
    
@@ -1276,6 +1278,16 @@ bool DoSource(CommandLine &CmdL)
         if (I->Path.find(".diff.gz") != string::npos)
            Comp = "diff";
         
+        // Diff only mode only fetches .diff files
+        if (_config->FindB("APT::Get::Diff-Only",false) == true &&
+            Comp != "diff")
+           continue;
+        
+        // Tar only mode only fetches .tar files
+        if (_config->FindB("APT::Get::Tar-Only",false) == true &&
+            Comp != "tar")
+           continue;
+        
         new pkgAcqFile(&Fetcher,Last->Source()->ArchiveURI(I->Path),
                        I->MD5Hash,I->Size,Last->Source()->SourceInfo(Src,
                        Last->Version(),Comp),Src);
@@ -1353,6 +1365,11 @@ bool DoSource(CommandLine &CmdL)
       {
         string Dir = Dsc[I].Package + '-' + pkgBaseVersion(Dsc[I].Version.c_str());
         
+        // Diff only mode only fetches .diff files
+        if (_config->FindB("APT::Get::Diff-Only",false) == true ||
+            _config->FindB("APT::Get::Tar-Only",false) == true)
+           continue;
+        
         // See if the package is already unpacked
         struct stat Stat;
         if (stat(Dir.c_str(),&Stat) == 0 &&
@@ -1513,6 +1530,8 @@ int main(int argc,const char *argv[])
       {0,"no-upgrade","APT::Get::no-upgrade",0},
       {0,"force-yes","APT::Get::force-yes",0},
       {0,"print-uris","APT::Get::Print-URIs",0},
+      {0,"diff-only","APT::Get::Diff-Only",0},
+      {0,"tar-only","APT::Get::tar-Only",0},
       {0,"purge","APT::Get::Purge",0},
       {0,"list-cleanup","APT::Get::List-Cleanup",0},
       {'c',"config-file",0,CommandLine::ConfigFile},