]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-install.cc
move the status-fd progress reporting out of the pkgDPkgPM class, at this point,...
[apt.git] / apt-private / private-install.cc
index 643a6b370475dc9b2eeded856b9a8b568db175c7..d1066c86943caa21ce2e7a2f33810014fec558df 100644 (file)
@@ -23,6 +23,7 @@
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/indexfile.h>
+#include <apt-pkg/iprogress.h>
 
 #include <set>
 #include <locale.h>
@@ -104,7 +105,11 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
    {
       pkgSimulate PM(Cache);
       int status_fd = _config->FindI("APT::Status-Fd",-1);
-      pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd);
+      APT::Progress::PackageManager *progress = NULL;
+      if (status_fd > 0)
+         progress = new APT::Progress::PackageManagerProgressFd(status_fd);
+      pkgPackageManager::OrderResult Res = PM.DoInstall(progress);
+      delete progress;
       if (Res == pkgPackageManager::Failed)
         return false;
       if (Res != pkgPackageManager::Completed)
@@ -332,8 +337,23 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
       }
 
       _system->UnLock();
+      
+      // FIXME: make this a factory
+      // select the right progress
       int status_fd = _config->FindI("APT::Status-Fd",-1);
-      pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd);
+      APT::Progress::PackageManager *progress = NULL;
+      if (status_fd > 0)
+         progress = new APT::Progress::PackageManagerProgressFd(status_fd);
+      else if(_config->FindB("Dpkg::Progress-Fancy", false) == true)
+         progress = new APT::Progress::PackageManagerFancy();
+      else if (_config->FindB("Dpkg::Progress", 
+                _config->FindB("DpkgPM::Progress", false)) == true)
+         progress = new APT::Progress::PackageManagerText();
+      else
+         progress = new APT::Progress::PackageManager();
+      pkgPackageManager::OrderResult Res = PM->DoInstall(progress);
+      delete progress;
+
       if (Res == pkgPackageManager::Failed || _error->PendingError() == true)
         return false;
       if (Res == pkgPackageManager::Completed)