]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-helper.cc
Merge branch 'debian/sid' into debian/experimental
[apt.git] / cmdline / apt-helper.cc
index 8ff2fa0377a47f57931c9a931a5c9aa79578b674..2c1107d9053e7845acaee798ac00541c87b2312b 100644 (file)
@@ -7,6 +7,7 @@
 // Include Files                                                       /*{{{*/
 #include <config.h>
 
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/init.h>
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-output.h>
+#include <apt-private/private-download.h>
 #include <apt-private/private-cmndline.h>
 
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-
+#include <iostream>
+#include <string>
+#include <vector>
 
 #include <apti18n.h>
                                                                        /*}}}*/
-using namespace std;
 
 static bool DoDownloadFile(CommandLine &CmdL)
 {
@@ -44,26 +40,28 @@ static bool DoDownloadFile(CommandLine &CmdL)
    Fetcher.Setup(&Stat);
    std::string download_uri = CmdL.FileList[1];
    std::string targetfile = CmdL.FileList[2];
-   new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", 
+   std::string hash;
+   if (CmdL.FileSize() > 3)
+      hash = CmdL.FileList[3];
+   new pkgAcqFile(&Fetcher, download_uri, hash, 0, "desc", "short-desc", 
                   "dest-dir-ignored", targetfile);
    Fetcher.Run();
-   if (!FileExists(targetfile))
-   {
-      _error->Error(_("Download Failed"));
-      return false;
-   }
+   bool Failed = false;
+   if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true ||
+        FileExists(targetfile) == false)
+      return _error->Error(_("Download Failed"));
    return true;
 }
 
 static bool ShowHelp(CommandLine &)
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
+   ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
            COMMON_ARCH,__DATE__,__TIME__);
 
    if (_config->FindB("version") == true)
      return true;
 
-   cout << 
+   std::cout <<
     _("Usage: apt-helper [options] command\n"
       "       apt-helper [options] download-file uri target-path\n"
       "\n"