diff options
author | James Clarke <jrtc27@jrtc27.com> | 2016-11-11 16:33:25 +0000 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-11-11 23:40:39 +0100 |
commit | a658ffbf1911ae9b9838615d0a60f4613e642553 (patch) | |
tree | 714a30f2b7c343ac1bdeee3c629def1a106b99a9 /ftparchive | |
parent | 7434f15cb688f3a394accba2ce10615adcb9c48a (diff) | |
download | apt-a658ffbf1911ae9b9838615d0a60f4613e642553.tar.gz |
apt-ftparchive: Support NotAutomatic and ButAutomaticUpgrades fields
This also changes Acquire-By-Hash to be "yes" rather than "true", so it
is consistent with dak's output.
Closes: #272557
Diffstat (limited to 'ftparchive')
-rw-r--r-- | ftparchive/writer.cc | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 018cf0052..eb17521eb 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -1004,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"] = ""; @@ -1017,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); + } - std::string const out = I->first + ": " + Value + "\n"; + // 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"; + } + + // 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()); } |