]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-update.cc
add support for Build-Depends/Conflicts-Arch
[apt.git] / apt-private / private-update.cc
index f6c12c26a272dc8262de59585ede74e9c9a83580..ba953a088f714136d37556d61fc442d5dcc02868 100644 (file)
@@ -1,37 +1,24 @@
 // Include files                                                       /*{{{*/
 #include<config.h>
 
 // Include files                                                       /*{{{*/
 #include<config.h>
 
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/cmndline.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/algorithms.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-item.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/clean.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/cachefile.h>
-#include <apt-pkg/cacheset.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/md5.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/sourcelist.h>
 #include <apt-pkg/update.h>
 #include <apt-pkg/update.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/configuration.h>
 
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-download.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-update.h>
 
 
-#include "private-cachefile.h"
-#include "private-output.h"
-#include "acqprogress.h"
+#include <ostream>
+#include <string>
 
 #include <apti18n.h>
                                                                        /*}}}*/
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -51,35 +38,38 @@ bool DoUpdate(CommandLine &CmdL)
       return false;
    pkgSourceList *List = Cache.GetSourceList();
 
       return false;
    pkgSourceList *List = Cache.GetSourceList();
 
-   // Create the progress
-   AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
-      
    // Just print out the uris an exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
    {
       // force a hashsum for compatibility reasons
       _config->CndSet("Acquire::ForceHash", "md5sum");
 
    // Just print out the uris an exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
    {
       // force a hashsum for compatibility reasons
       _config->CndSet("Acquire::ForceHash", "md5sum");
 
-      // get a fetcher
-      pkgAcquire Fetcher;
-      if (Fetcher.Setup(&Stat) == false)
-        return false;
-
-      // Populate it with the source selection and get all Indexes 
+      // Populate it with the source selection and get all Indexes
       // (GetAll=true)
       // (GetAll=true)
+      aptAcquireWithTextStatus Fetcher;
       if (List->GetIndexes(&Fetcher,true) == false)
         return false;
 
       if (List->GetIndexes(&Fetcher,true) == false)
         return false;
 
+      std::string compExt = APT::Configuration::getCompressionTypes()[0];
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); ++I)
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); ++I)
-        c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
-            I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl;
+      {
+         std::string FileName = flNotDir(I->Owner->DestFile);
+         if(compExt.empty() == false && 
+            APT::String::Endswith(FileName, compExt))
+            FileName = FileName.substr(0, FileName.size() - compExt.size() - 1);
+        c1out << '\'' << I->URI << "' " << FileName << ' ' <<
+           std::to_string(I->Owner->FileSize) << ' ' << I->Owner->HashSum() << std::endl;
+      }
       return true;
    }
 
    // do the work
    if (_config->FindB("APT::Get::Download",true) == true)
       return true;
    }
 
    // do the work
    if (_config->FindB("APT::Get::Download",true) == true)
-       ListUpdate(Stat, *List);
+   {
+      AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
+      ListUpdate(Stat, *List);
+   }
 
    // Rebuild the cache.
    if (_config->FindB("pkgCacheFile::Generate", true) == true)
 
    // Rebuild the cache.
    if (_config->FindB("pkgCacheFile::Generate", true) == true)
@@ -89,6 +79,28 @@ bool DoUpdate(CommandLine &CmdL)
         return false;
    }
 
         return false;
    }
 
+   // show basic stats (if the user whishes)
+   if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true)
+   {
+      int upgradable = 0;
+      if (Cache.Open() == false)
+         return false;
+      for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
+      {
+         pkgDepCache::StateCache &state = Cache[I];
+         if (I->CurrentVer != 0 && state.Upgradable() && state.CandidateVer != NULL)
+            upgradable++;
+      }
+      const char *msg = P_(
+         "%i package can be upgraded. Run 'apt list --upgradable' to see it.\n",
+         "%i packages can be upgraded. Run 'apt list --upgradable' to see them.\n",
+         upgradable);
+      if (upgradable == 0)
+         c1out << _("All packages are up to date.") << std::endl;
+      else
+         ioprintf(c1out, msg, upgradable);
+   }
+
    return true;
 }
                                                                        /*}}}*/
    return true;
 }
                                                                        /*}}}*/