]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/dpkgpm.cc
* Patch from Koblinger Egmont <egmont@uhulinux.hu> to f...
[apt.git] / apt-pkg / deb / dpkgpm.cc
index c3f255401ffd24157d31b42ee589648f84a5ab60..1548a47d4b179b066e1205bd2441336d521ede51 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: dpkgpm.cc,v 1.24 2002/04/02 06:42:39 jgg Exp $
+// $Id: dpkgpm.cc,v 1.27 2003/07/26 00:25:44 mdz Exp $
 /* ######################################################################
 
    DPKG Package Manager - Provide an interface to dpkg
 /* ######################################################################
 
    DPKG Package Manager - Provide an interface to dpkg
@@ -144,7 +144,6 @@ bool pkgDPkgPM::RunScripts(const char *Cnf)
    
    return true;
 }
    
    return true;
 }
-
                                                                         /*}}}*/
 // DPkgPM::SendV2Pkgs - Send version 2 package info                    /*{{{*/
 // ---------------------------------------------------------------------
                                                                         /*}}}*/
 // DPkgPM::SendV2Pkgs - Send version 2 package info                    /*{{{*/
 // ---------------------------------------------------------------------
@@ -323,13 +322,15 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
 
    return true;
 }
 
    return true;
 }
-
                                                                        /*}}}*/
 // DPkgPM::Go - Run the sequence                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* This globs the operations and calls dpkg */
 bool pkgDPkgPM::Go()
 {
                                                                        /*}}}*/
 // 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",8192);
+
    if (RunScripts("DPkg::Pre-Invoke") == false)
       return false;
 
    if (RunScripts("DPkg::Pre-Invoke") == false)
       return false;
 
@@ -342,9 +343,9 @@ bool pkgDPkgPM::Go()
       for (; J != List.end() && J->Op == I->Op; J++);
 
       // Generate the argument list
       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;
       
       unsigned int n = 0;
       unsigned long Size = 0;
@@ -400,7 +401,7 @@ bool pkgDPkgPM::Go()
       // Write in the file or package names
       if (I->Op == Item::Install)
       {
       // 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());
         {
            if (I->File[0] != '/')
               return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str());
@@ -410,7 +411,7 @@ bool pkgDPkgPM::Go()
       }      
       else
       {
       }      
       else
       {
-        for (;I != J && Size < 1024; I++)
+        for (;I != J && Size < MaxArgBytes; I++)
         {
            Args[n++] = I->Pkg.Name();
            Size += strlen(Args[n-1]);
         {
            Args[n++] = I->Pkg.Name();
            Size += strlen(Args[n-1]);
@@ -447,7 +448,7 @@ bool pkgDPkgPM::Go()
         if (chdir(_config->FindDir("DPkg::Run-Directory","/").c_str()) != 0)
            _exit(100);
         
         if (chdir(_config->FindDir("DPkg::Run-Directory","/").c_str()) != 0)
            _exit(100);
         
-        if (_config->FindB("DPkg::FlushSTDIN",true) == true)
+        if (_config->FindB("DPkg::FlushSTDIN",true) == true && isatty(STDIN_FILENO))
         {
            int Flags,dummy;
            if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0)
         {
            int Flags,dummy;
            if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0)