]> git.saurik.com Git - apt.git/blobdiff - ftparchive/writer.cc
I know this is "bad", but a "full wedge" is worse.
[apt.git] / ftparchive / writer.cc
index dbeaa16a6a0b446151697c403118c1cc69096037..eb17521eb9938f55a40ebe615a72a243b656eda3 100644 (file)
@@ -969,11 +969,15 @@ bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompres
 /* */
 static std::string formatUTCDateTime(time_t const now)
 {
+   bool const NumericTimezone = _config->FindB("APT::FTPArchive::Release::NumericTimezone", true);
    // TimeRFC1123 uses GMT to satisfy HTTP/1.1
-   std::string datetime = TimeRFC1123(now);
-   auto const lastspace = datetime.rfind(' ');
-   if (likely(lastspace != std::string::npos))
-      datetime.replace(lastspace + 1, 3, "UTC");
+   std::string datetime = TimeRFC1123(now, NumericTimezone);
+   if (NumericTimezone == false)
+   {
+      auto const lastspace = datetime.rfind(' ');
+      if (likely(lastspace != std::string::npos))
+        datetime.replace(lastspace + 1, 3, "UTC");
+   }
    return datetime;
 }
 ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) : FTWScanner(GivenOutput)
@@ -988,6 +992,7 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) :
       AddPattern("Release");
       AddPattern("Contents-*");
       AddPattern("Index");
+      AddPattern("Index.*");
       AddPattern("icons-*.tar");
       AddPattern("icons-*.tar.*");
       AddPattern("Components-*.yml");
@@ -999,6 +1004,7 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) :
    time_t const now = time(NULL);
    time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0);
 
+   map<string,bool> BoolFields;
    map<string,string> Fields;
    Fields["Origin"] = "";
    Fields["Label"] = "";
@@ -1012,19 +1018,32 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) :
    Fields["Components"] = "";
    Fields["Description"] = "";
    Fields["Signed-By"] = "";
-   if (_config->FindB("APT::FTPArchive::DoByHash", false) == true)
-      Fields["Acquire-By-Hash"] = "true";
-   
-   for(map<string,string>::const_iterator I = Fields.begin();
-       I != Fields.end();
-       ++I)
+   BoolFields["Acquire-By-Hash"] = _config->FindB("APT::FTPArchive::DoByHash", false);
+   BoolFields["NotAutomatic"] = false;
+   BoolFields["ButAutomaticUpgrades"] = false;
+
+   // Read configuration for string fields, but don't output them
+   for (auto &&I : Fields)
    {
-      string Config = string("APT::FTPArchive::Release::") + (*I).first;
-      string Value = _config->Find(Config, (*I).second.c_str());
-      if (Value == "")
-         continue;
+      string Config = string("APT::FTPArchive::Release::") + I.first;
+      I.second = _config->Find(Config, I.second);
+   }
+
+   // Read configuration for bool fields, and add them to Fields if true
+   for (auto &&I : BoolFields)
+   {
+      string Config = string("APT::FTPArchive::Release::") + I.first;
+      I.second = _config->FindB(Config, I.second);
+      if (I.second)
+         Fields[I.first] = "yes";
+   }
 
-      std::string const out = I->first + ": " + Value + "\n";
+   // All configuration read and stored in Fields; output
+   for (auto &&I : Fields)
+   {
+      if (I.second.empty())
+         continue;
+      std::string const out = I.first + ": " + I.second + "\n";
       Output->Write(out.c_str(), out.length());
    }