summaryrefslogtreecommitdiff
path: root/apt-private/private-cmndline.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-10-16 18:03:52 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-04 18:04:02 +0100
commitc3ded84c6f99bda4caf63c8662416ffb0189d31b (patch)
tree0b9c03d3ba4d44501091f13122e06d9d9cc6ad20 /apt-private/private-cmndline.cc
parent73fe49f9b4748eddb5a2dad4f0abb51a8f63564c (diff)
add binary-specific options via Binary scope
Especially with apt now, it can be useful to set an option only for apt and not for apt-get. Using a binary-specific subtree which is merged into the root seems like a simple enough trick to achieve this.
Diffstat (limited to 'apt-private/private-cmndline.cc')
-rw-r--r--apt-private/private-cmndline.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 5d6fd3c2e..81352d757 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -3,6 +3,7 @@
#include <apt-pkg/cmndline.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/init.h>
#include <apt-pkg/error.h>
@@ -322,8 +323,21 @@ void ParseCommandLine(CommandLine &CmdL, CommandLine::Dispatch * const Cmds, Com
Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &CmdL))
{
CmdL = CommandLine(Args,_config);
- if ((Cnf != NULL && pkgInitConfig(**Cnf) == false) ||
- CmdL.Parse(argc,argv) == false ||
+ if (Cnf != NULL && pkgInitConfig(**Cnf) == false)
+ {
+ _error->DumpErrors();
+ exit(100);
+ }
+
+ if (likely(argc != 0 && argv[0] != NULL))
+ {
+ std::string const binary = flNotDir(argv[0]);
+ _config->Set("Binary", binary);
+ std::string const conf = "Binary::" + binary;
+ _config->MoveSubTree(conf.c_str(), NULL);
+ }
+
+ if (CmdL.Parse(argc,argv) == false ||
(Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
{
if (_config->FindB("version") == true)