summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc5
-rw-r--r--cmdline/apt-get.cc33
-rw-r--r--cmdline/apt-helper.cc16
3 files changed, 36 insertions, 18 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 88a323280..1447feb81 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1330,8 +1330,8 @@ static bool Search(CommandLine &CmdL)
ExDescFile *DFList = new ExDescFile[descCount];
memset(DFList,0,sizeof(*DFList) * descCount);
- bool PatternMatch[descCount * NumPatterns];
- memset(PatternMatch,false,sizeof(PatternMatch));
+ bool *PatternMatch = new bool[descCount * NumPatterns];
+ memset(PatternMatch,false,sizeof(*PatternMatch) * descCount * NumPatterns);
// Map versions that we want to write out onto the VerList array.
for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() == false; ++G)
@@ -1441,6 +1441,7 @@ static bool Search(CommandLine &CmdL)
}
delete [] DFList;
+ delete [] PatternMatch;
for (unsigned I = 0; I != NumPatterns; I++)
regfree(&Patterns[I]);
if (ferror(stdout))
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index cdbfa4708..d6cd94f72 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -955,18 +955,19 @@ static bool DoSource(CommandLine &CmdL)
else
{
// Call dpkg-source
- char S[500];
- snprintf(S,sizeof(S),"%s -x %s",
+ std::string const sourceopts = _config->Find("DPkg::Source-Options", "-x");
+ std::string S;
+ strprintf(S, "%s %s %s",
_config->Find("Dir::Bin::dpkg-source","dpkg-source").c_str(),
- Dsc[I].Dsc.c_str());
- if (system(S) != 0)
+ sourceopts.c_str(), Dsc[I].Dsc.c_str());
+ if (system(S.c_str()) != 0)
{
- fprintf(stderr,_("Unpack command '%s' failed.\n"),S);
- fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n"));
+ fprintf(stderr, _("Unpack command '%s' failed.\n"), S.c_str());
+ fprintf(stderr, _("Check if the 'dpkg-dev' package is installed.\n"));
_exit(1);
- }
+ }
}
-
+
// Try to compile it with dpkg-buildpackage
if (_config->FindB("APT::Get::Compile",false) == true)
{
@@ -982,20 +983,20 @@ static bool DoSource(CommandLine &CmdL)
buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
// Call dpkg-buildpackage
- char S[500];
- snprintf(S,sizeof(S),"cd %s && %s %s",
+ std::string S;
+ strprintf(S, "cd %s && %s %s",
Dir.c_str(),
_config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(),
buildopts.c_str());
-
- if (system(S) != 0)
+
+ if (system(S.c_str()) != 0)
{
- fprintf(stderr,_("Build command '%s' failed.\n"),S);
+ fprintf(stderr, _("Build command '%s' failed.\n"), S.c_str());
_exit(1);
- }
- }
+ }
+ }
}
-
+
_exit(0);
}
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index b0edafcbd..dd43ea1bc 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -16,6 +16,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/proxy.h>
#include <apt-private/acqprogress.h>
#include <apt-private/private-output.h>
@@ -29,6 +30,19 @@
#include <apti18n.h>
/*}}}*/
+static bool DoAutoDetectProxy(CommandLine &CmdL)
+{
+ if (CmdL.FileSize() != 2)
+ return _error->Error(_("Need one URL as argument"));
+ URI ServerURL(CmdL.FileList[1]);
+ AutoDetectProxy(ServerURL);
+ std::string SpecificProxy = _config->Find("Acquire::"+ServerURL.Access+"::Proxy::" + ServerURL.Host);
+ ioprintf(std::cout, "Using proxy '%s' for URL '%s'\n",
+ SpecificProxy.c_str(), std::string(ServerURL).c_str());
+
+ return true;
+}
+
static bool DoDownloadFile(CommandLine &CmdL)
{
if (CmdL.FileSize() <= 2)
@@ -70,6 +84,7 @@ static bool ShowHelp(CommandLine &)
"\n"
"Commands:\n"
" download-file - download the given uri to the target-path\n"
+ " auto-detect-proxy - detect proxy using apt.conf\n"
"\n"
" This APT helper has Super Meep Powers.\n");
return true;
@@ -80,6 +95,7 @@ int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp},
{"download-file", &DoDownloadFile},
+ {"auto-detect-proxy", &DoAutoDetectProxy},
{0,0}};
std::vector<CommandLine::Args> Args = getCommandArgs(