]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/dpkgpm.cc
fix for #161593
[apt.git] / apt-pkg / deb / dpkgpm.cc
index 34c19ef4b2ab984c9ec4b0e0a83162e89f68175a..70c78fbb71dd6c0076e508232f7d18a410efb7f7 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: dpkgpm.cc,v 1.18 2001/02/20 07:03:17 jgg Exp $
+// $Id: dpkgpm.cc,v 1.25 2002/04/24 05:40:47 jgg Exp $
 /* ######################################################################
 
    DPKG Package Manager - Provide an interface to dpkg
@@ -16,7 +16,7 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/strutl.h>
-    
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <errno.h>
 #include <stdio.h>
+#include <iostream>
                                                                        /*}}}*/
 
+using namespace std;
+
 // DPkgPM::pkgDPkgPM - Constructor                                     /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -141,7 +144,6 @@ bool pkgDPkgPM::RunScripts(const char *Cnf)
    
    return true;
 }
-
                                                                         /*}}}*/
 // DPkgPM::SendV2Pkgs - Send version 2 package info                    /*{{{*/
 // ---------------------------------------------------------------------
@@ -250,8 +252,6 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
       string::size_type Pos;
       if ((Pos = OptSec.find(' ')) == string::npos || Pos == 0)
         Pos = OptSec.length();
-      else
-        Pos--;
       OptSec = "DPkg::Tools::Options::" + string(Opts->Value.c_str(),Pos);
       
       unsigned int Version = _config->FindI(OptSec+"::Version",1);
@@ -314,12 +314,6 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
         Die = !SendV2Pkgs(F);
 
       fclose(F);
-      if (Die == true)
-      {
-        kill(Process,SIGINT);
-        ExecWait(Process,Opts->Value.c_str(),true);
-        return _error->Error("Failure running script %s",Opts->Value.c_str());
-      }
       
       // Clean up the sub process
       if (ExecWait(Process,Opts->Value.c_str()) == false)
@@ -328,13 +322,15 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
 
    return true;
 }
-
                                                                        /*}}}*/
 // DPkgPM::Go - Run the sequence                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* This globs the operations and calls dpkg */
 bool pkgDPkgPM::Go()
 {
+   unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",350);   
+   unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",1024);
+
    if (RunScripts("DPkg::Pre-Invoke") == false)
       return false;
 
@@ -347,13 +343,14 @@ bool pkgDPkgPM::Go()
       for (; J != List.end() && J->Op == I->Op; J++);
 
       // Generate the argument list
-      const char *Args[400];
-      if (J - I > 350)
-        J = I + 350;
+      const char *Args[MaxArgs + 50];
+      if (J - I > (signed)MaxArgs)
+        J = I + MaxArgs;
       
       unsigned int n = 0;
       unsigned long Size = 0;
-      Args[n++] = _config->Find("Dir::Bin::dpkg","dpkg").c_str();
+      string Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+      Args[n++] = Tmp.c_str();
       Size += strlen(Args[n-1]);
       
       // Stick in any custom dpkg options
@@ -404,7 +401,7 @@ bool pkgDPkgPM::Go()
       // Write in the file or package names
       if (I->Op == Item::Install)
       {
-        for (;I != J && Size < 1024; I++)
+        for (;I != J && Size < MaxArgBytes; I++)
         {
            if (I->File[0] != '/')
               return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
@@ -414,7 +411,7 @@ bool pkgDPkgPM::Go()
       }      
       else
       {
-        for (;I != J && Size < 1024; I++)
+        for (;I != J && Size < MaxArgBytes; I++)
         {
            Args[n++] = I->Pkg.Name();
            Size += strlen(Args[n-1]);