From 11bcbdb93e13e0b2c1625fc0f926378bce43fead Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 11:54:15 +0200 Subject: load the dpkg base arguments only one time and reuse them later --- apt-pkg/deb/dpkgpm.cc | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c17419819..5eb6406c6 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -905,6 +905,28 @@ bool pkgDPkgPM::Go(int OutStatusFd) // create log OpenLog(); + // Generate the base argument list for dpkg + std::vector Args; + unsigned long StartSize = 0; + string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); + Args.push_back(Tmp.c_str()); + StartSize += Tmp.length(); + + // Stick in any custom dpkg options + Configuration::Item const *Opts = _config->Tree("DPkg::Options"); + if (Opts != 0) + { + Opts = Opts->Child; + for (; Opts != 0; Opts = Opts->Next) + { + if (Opts->Value.empty() == true) + continue; + Args.push_back(Opts->Value.c_str()); + StartSize += Opts->Value.length(); + } + } + size_t const BaseArgs = Args.size(); + // this loop is runs once per operation for (vector::const_iterator I = List.begin(); I != List.end();) { @@ -926,11 +948,13 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (; J != List.end() && J->Op == I->Op; ++J) /* nothing */; - // Generate the argument list - std::vector Args; // keep track of allocated strings for multiarch package names std::vector Packages; + // start with the baseset of arguments + unsigned long Size = StartSize; + Args.erase(Args.begin() + BaseArgs, Args.end()); + // Now check if we are within the MaxArgs limit // // this code below is problematic, because it may happen that @@ -948,24 +972,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) Args.reserve((J - I) + 10); } - unsigned long Size = 0; - string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); - Args.push_back(Tmp.c_str()); - Size += Tmp.length(); - - // Stick in any custom dpkg options - Configuration::Item const *Opts = _config->Tree("DPkg::Options"); - if (Opts != 0) - { - Opts = Opts->Child; - for (; Opts != 0; Opts = Opts->Next) - { - if (Opts->Value.empty() == true) - continue; - Args.push_back(Opts->Value.c_str()); - Size += Opts->Value.length(); - } - } int fd[2]; pipe(fd); @@ -1042,7 +1048,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) continue; if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end()) continue; - if (false && (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))) + if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")) { char const * const name = I->Pkg.Name(); ADDARG(name); @@ -1067,7 +1073,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (std::vector::const_iterator a = Args.begin(); a != Args.end(); ++a) clog << *a << ' '; - clog << "size=" << Size << endl; + clog << endl; continue; } Args.push_back(NULL); -- cgit v1.2.3