]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-config.cc
ensure that apti18n.h is included last as advertised (Closes: #671623)
[apt.git] / cmdline / apt-config.cc
index 589ee7ada62a5d68cc3b47676d2f5ae7e9110a63..397ce32df71bead27ca4f62eb0b0ad280271e2c4 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include<config.h>
+
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/init.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
-
-#include <config.h>
-#include <apti18n.h>
+#include <apt-pkg/pkgsystem.h>
 
 #include <locale.h>
 #include <iostream>
 #include <string>
 #include <vector>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 using namespace std;
 
@@ -61,7 +63,13 @@ bool DoShell(CommandLine &CmdL)
 /* */
 bool DoDump(CommandLine &CmdL)
 {
-   _config->Dump(cout);
+   bool const empty = _config->FindB("APT::Config::Dump::EmptyValue", true);
+   std::string const format = _config->Find("APT::Config::Dump::Format", "%f \"%v\";\n");
+   if (CmdL.FileSize() == 1)
+      _config->Dump(cout, NULL, format.c_str(), empty);
+   else
+      for (const char **I = CmdL.FileList + 1; *I != 0; ++I)
+        _config->Dump(cout, *I, format.c_str(), empty);
    return true;
 }
                                                                        /*}}}*/
@@ -70,7 +78,7 @@ bool DoDump(CommandLine &CmdL)
 /* */
 int ShowHelp()
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,VERSION,
+   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
            COMMON_ARCH,__DATE__,__TIME__);
    if (_config->FindB("version") == true)
       return 0;
@@ -98,6 +106,8 @@ int main(int argc,const char *argv[])                                        /*{{{*/
       {'v',"version","version",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
+      {0,"empty","APT::Config::Dump::EmptyValue",CommandLine::Boolean},
+      {0,"format","APT::Config::Dump::Format",CommandLine::HasArg},
       {0,0,0,0}};
    CommandLine::Dispatch Cmds[] = {{"shell",&DoShell},
                                    {"dump",&DoDump},
@@ -132,6 +142,22 @@ int main(int argc,const char *argv[])                                      /*{{{*/
    for (std::vector<std::string>::const_iterator a = archs.begin(); a != archs.end(); ++a)
       _config->Set("APT::Architectures::", *a);
 
+   std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors();
+   _config->Clear("APT::Compressor");
+   string conf = "APT::Compressor::";
+   for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin(); c != compressors.end(); ++c)
+   {
+      string comp = conf + c->Name + "::";
+      _config->Set(comp + "Name", c->Name);
+      _config->Set(comp + "Extension", c->Extension);
+      _config->Set(comp + "Binary", c->Binary);
+      _config->Set(std::string(comp + "Cost").c_str(), c->Cost);
+      for (std::vector<std::string>::const_iterator a = c->CompressArgs.begin(); a != c->CompressArgs.end(); ++a)
+        _config->Set(comp + "CompressArg::", *a);
+      for (std::vector<std::string>::const_iterator a = c->UncompressArgs.begin(); a != c->UncompressArgs.end(); ++a)
+        _config->Set(comp + "UncompressArg::", *a);
+   }
+
    // Match the operation
    CmdL.DispatchArg(Cmds);