From a21aca106ce93e8a2841d4a2c7a8432f9dfc7b6d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 6 Jun 2016 15:04:42 +0200 Subject: [PATCH] eipp: implement Immediate-Configuration flag APT has 3 modes: no immediate configuration, all packages are configured immediately and its default mode of configuring essentials and pseudo-essentials immediately only. While this seems like a job of different planers at first, it might be handy to have it as an option, too, in case a planer (like apts internal one) supports different modes where the introduction of individual planers would be counter intuitive. --- apt-pkg/edsp.cc | 12 +++++++++++- apt-pkg/edsp.h | 11 ++++++++++- apt-pkg/packagemanager.cc | 8 +++++++- cmdline/apt-internal-planer.cc | 2 ++ doc/external-installation-planer-protocol.txt | 8 ++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 21f7f3607..e79bb804c 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -1112,7 +1112,6 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output, /*{{{*/ unsigned int const flags, OpProgress * const Progress) { - (void)(flags); if (Progress != NULL) Progress->SubProgress(Cache.Head().PackageCount, _("Send request to planer")); unsigned long p = 0; @@ -1152,6 +1151,10 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output, /*{{{*/ if (reinst.empty() == false) WriteOkay(Okay, output, "ReInstall:", reinst, "\n"); WriteOkay(Okay, output, "Planer: ", _config->Find("APT::Planer", "internal"), "\n"); + if ((flags & Request::IMMEDIATE_CONFIGURATION_ALL) != 0) + WriteOkay(Okay, output, "Immediate-Configuration: yes\n"); + else if ((flags & Request::NO_IMMEDIATE_CONFIGURATION) != 0) + WriteOkay(Okay, output, "Immediate-Configuration: no\n"); return WriteOkay(Okay, output, "\n"); } /*}}}*/ @@ -1379,6 +1382,13 @@ bool EIPP::ReadRequest(int const input, std::listSet("APT::Architectures", SubstVar(line, " ", ",")); else if (LineStartsWithAndStrip(line, "Planer:")) ; // purely informational line + else if (LineStartsWithAndStrip(line, "Immediate-Configuration:")) + { + if (localStringToBool(line, true)) + flags |= Request::IMMEDIATE_CONFIGURATION_ALL; + else + flags |= Request::NO_IMMEDIATE_CONFIGURATION; + } else _error->Warning("Unknown line in EIPP Request stanza: %s", line.c_str()); diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index 271cbb6a8..e1ffdf598 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -239,8 +239,17 @@ namespace EDSP /*{{{*/ class pkgPackageManager; namespace EIPP /*{{{*/ { + namespace Request + { + enum Flags + { + IMMEDIATE_CONFIGURATION_ALL = (1 << 0), /*!< try to keep the least amount of packages unconfigured as possible at all times */ + NO_IMMEDIATE_CONFIGURATION = (1 << 1), /*!< do not perform immediate configuration at all */ + }; + } + APT_HIDDEN bool WriteRequest(pkgDepCache &Cache, FileFd &output, - unsigned int const version, OpProgress * const Progress); + unsigned int const flags, OpProgress * const Progress); APT_HIDDEN bool WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress * const Progress); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 173fa8085..d5afceb6d 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -1040,7 +1040,13 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() std::string const planer = _config->Find("APT::Planer", "internal"); if (planer != "internal") { - if (EIPP::OrderInstall(planer.c_str(), this, 0, nullptr)) + unsigned int flags = 0; + if (_config->FindB("APT::Immediate-Configure", true) == false) + flags |= EIPP::Request::NO_IMMEDIATE_CONFIGURATION; + else if (_config->FindB("APT::Immediate-Configure-All", false)) + flags |= EIPP::Request::IMMEDIATE_CONFIGURATION_ALL; + + if (EIPP::OrderInstall(planer.c_str(), this, flags, nullptr)) return Completed; else return Failed; diff --git a/cmdline/apt-internal-planer.cc b/cmdline/apt-internal-planer.cc index 676d84001..0657be3b2 100644 --- a/cmdline/apt-internal-planer.cc +++ b/cmdline/apt-internal-planer.cc @@ -150,6 +150,8 @@ int main(int argc,const char *argv[]) /*{{{*/ unsigned int flags; if (EIPP::ReadRequest(input, actions, flags) == false) DIE("Parsing the request failed!"); + _config->Set("APT::Immediate-Configure", (flags & EIPP::Request::NO_IMMEDIATE_CONFIGURATION) == 0); + _config->Set("APT::Immediate-Configure-All", (flags & EIPP::Request::IMMEDIATE_CONFIGURATION_ALL) != 0); EDSP::WriteProgress(5, "Read scenario…", output); diff --git a/doc/external-installation-planer-protocol.txt b/doc/external-installation-planer-protocol.txt index 028c4249f..7760ecf60 100644 --- a/doc/external-installation-planer-protocol.txt +++ b/doc/external-installation-planer-protocol.txt @@ -162,6 +162,14 @@ The following **preference fields** are supported in request stanzas: informational string specifying to which planer this request was send initially. +- *Immediate-Configuration:** (option, unset by default) A boolean value + defining if the planer should try to configure all packages as quickly + as possible (true) or shouldn't perform any kind of immediate + configuration at all (false). If not explicitly set with this field + the planer is free to pick either mode or implementing e.g. a mode + which configures only packages immediately if they are flagged as + `Essential` (or are dependencies of packages marked as `Essential`). + #### Package universe -- 2.45.2