]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-install.cc
Merge remote-tracking branch 'upstream/debian/sid' into debian/experimental
[apt.git] / apt-private / private-install.cc
index d9d46dba0b38d9acaa500ca617fa0b129f1c3177..d9e4854620dc9d479bd8dedceb3bd746ef3c1248 100644 (file)
@@ -1,56 +1,48 @@
 // 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.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/algorithms.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/cmndline.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
 #include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/sptr.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/sourcelist.h>
 #include <apt-pkg/install-progress.h>
 
-#include <set>
-#include <locale.h>
-#include <langinfo.h>
-#include <fstream>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/statfs.h>
 #include <sys/statvfs.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <regex.h>
-#include <sys/wait.h>
-#include <sstream>
+#include <algorithm>
+#include <iostream>
+#include <set>
+#include <vector>
+#include <map>
 
-#include "private-install.h"
-#include "private-download.h"
-#include "private-cachefile.h"
-#include "private-output.h"
-#include "private-cacheset.h"
-#include "acqprogress.h"
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-install.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-download.h>
+#include <apt-private/private-output.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
+class pkgSourceList;
 
 // InstallPackages - Actually download and install the packages                /*{{{*/
 // ---------------------------------------------------------------------
@@ -105,12 +97,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
    {
       pkgSimulate PM(Cache);
 
-      int status_fd = _config->FindI("APT::Status-Fd",-1);
-      APT::Progress::PackageManager *progress = NULL;
-      if (status_fd > 0)
-         progress = new APT::Progress::PackageManagerProgressFd(status_fd);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+      APT::Progress::PackageManager *progress = APT::Progress::PackageManagerProgressFactory();
       pkgPackageManager::OrderResult Res = PM.DoInstall(progress);
       delete progress;
+#else
+      int status_fd = _config->FindI("APT::Status-Fd",-1);
+      pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd);
+#endif
 
       if (Res == pkgPackageManager::Failed)
         return false;
@@ -153,7 +147,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
    if (DebBytes != Cache->DebSize())
    {
       c0out << DebBytes << ',' << Cache->DebSize() << std::endl;
-      c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << std::endl;
+      c0out << _("How odd... The sizes didn't match, email apt@packages.debian.org") << std::endl;
    }
    
    // Number of bytes
@@ -340,26 +334,14 @@ 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);
-      int status_deb822_fd = _config->FindI("APT::Status-deb822-Fd", -1);
-
-      APT::Progress::PackageManager *progress = NULL;
-      if (status_deb822_fd > 0)
-         progress = new APT::Progress::PackageManagerProgressDeb822Fd(
-            status_deb822_fd);
-      else 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();
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
+      APT::Progress::PackageManager *progress = APT::Progress::PackageManagerProgressFactory();
       pkgPackageManager::OrderResult Res = PM->DoInstall(progress);
       delete progress;
+#else
+      int status_fd = _config->FindI("APT::Status-Fd", -1);
+      pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd);
+#endif
 
       if (Res == pkgPackageManager::Failed || _error->PendingError() == true)
         return false;
@@ -395,7 +377,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
 // DoAutomaticRemove - Remove all automatic unused packages            /*{{{*/
 // ---------------------------------------------------------------------
 /* Remove unused automatic packages */
-bool DoAutomaticRemove(CacheFile &Cache)
+static bool DoAutomaticRemove(CacheFile &Cache)
 {
    bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
    bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
@@ -690,10 +672,34 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
 bool DoInstall(CommandLine &CmdL)
 {
    CacheFile Cache;
+   // first check for local pkgs and add them to the cache
+   for (const char **I = CmdL.FileList; *I != 0; I++)
+   {
+      if(FileExists(*I))
+      {
+         // FIXME: make this more elegant
+         std::string TypeStr = flExtension(*I) + "-file";
+         pkgSourceList::Type *Type = pkgSourceList::Type::GetType(TypeStr.c_str());
+         if(Type != 0)
+         {
+            std::vector<metaIndex *> List;
+            std::map<std::string, std::string> Options;
+            if(Type->CreateItem(List, *I, "", "", Options))
+            {
+               // we have our own CacheFile that gives us a SourceList
+               // with superpowerz
+               SourceList *sources = (SourceList*)Cache.GetSourceList();
+               sources->AddMetaIndex(List[0]);
+            }
+         }
+      }
+   }
+
+   // then open the cache
    if (Cache.OpenForInstall() == false || 
        Cache.CheckDeps(CmdL.FileSize() != 1) == false)
       return false;
-
+   
    std::map<unsigned short, APT::VersionSet> verset;
 
    if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset))