]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp.cc
eipp: implement Immediate-Configuration flag
[apt.git] / apt-pkg / edsp.cc
index ae5c7a3733d88a6ffbf6a1dca6f51026b3372ae5..e79bb804c60bd41b1317a227033d5593086cb9f2 100644 (file)
@@ -1094,6 +1094,14 @@ bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM,
 
    if (Progress != NULL)
       Progress->OverallProgress(25, 100, 75, _("Execute external planer"));
+
+   // we don't tell the external planers about boring things
+   for (auto Pkg = PM->Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
+   {
+      if (Pkg->CurrentState == pkgCache::State::ConfigFiles && PM->Cache[Pkg].Purge() == true)
+        PM->Remove(Pkg, true);
+   }
+
    if (Okay && EIPP::ReadResponse(solver_out, PM, Progress) == false)
       return false;
 
@@ -1104,19 +1112,18 @@ 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;
-   string del, purge, inst, reinst;
+   string del, inst, reinst;
    for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p)
    {
       if (Progress != NULL && p % 100 == 0)
          Progress->Progress(p);
       string* req;
       pkgDepCache::StateCache &P = Cache[Pkg];
-      if (P.Purge() == true)
-        req = &purge;
+      if (P.Purge() == true && Pkg->CurrentState == pkgCache::State::ConfigFiles)
+        continue;
       if (P.Delete() == true)
         req = &del;
       else if (P.NewInstall() == true || P.Upgrade() == true || P.Downgrade() == true)
@@ -1137,8 +1144,6 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,               /*{{{*/
        WriteOkay(Okay, output, " ", *a);
    WriteOkay(Okay, output, "\n");
 
-   if (purge.empty() == false)
-      WriteOkay(Okay, output, "Purge:", purge, "\n");
    if (del.empty() == false)
       WriteOkay(Okay, output, "Remove:", del, "\n");
    if (inst.empty() == false)
@@ -1146,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");
 }
                                                                        /*}}}*/
@@ -1212,6 +1221,35 @@ bool EIPP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress * const
               pkgset[PV->ID] = true;
         }
         pkgset[P->ID] = true;
+        if (strcmp(P.Arch(), "any") == 0)
+        {
+           APT::StringView const pkgname(P.Name());
+           auto const idxColon = pkgname.find(':');
+           if (idxColon != APT::StringView::npos)
+           {
+              pkgCache::PkgIterator PA;
+              if (pkgname.substr(idxColon + 1) == "any")
+              {
+                 auto const GA = Cache.FindGrp(pkgname.substr(0, idxColon).to_string());
+                 for (auto PA = GA.PackageList(); PA.end() == false; PA = GA.NextPkg(PA))
+                 {
+                    pkgset[PA->ID] = true;
+                 }
+              }
+              else
+              {
+                 auto const PA = Cache.FindPkg(pkgname.to_string());
+                 if (PA.end() == false)
+                    pkgset[PA->ID] = true;
+              }
+           }
+        }
+        else
+        {
+           auto const PA = Cache.FindPkg(P.FullName(false), "any");
+           if (PA.end() == false)
+              pkgset[PA->ID] = true;
+        }
       }
    };
    for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
@@ -1344,6 +1382,13 @@ bool EIPP::ReadRequest(int const input, std::list<std::pair<std::string,PKG_ACTI
            _config->Set("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());