[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [patch] EDSP 0.5 w/ multi-arch support for external solvers



On Sat, Nov 09, 2013 at 01:58:09PM +0100, David Kalnischkies wrote:
> > +   std::set<string> Releases;
> > +   for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; ++I) {
> > +      pkgCache::PkgFileIterator File = I.File();
> > +      signed short const p = Cache.GetPolicy().GetPriority(File);
> >        if (Pin < p)
> >          Pin = p;
> > +      if ((File->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource)
> > +        Releases.insert(File.RelStr());
> >     }
> > +   fprintf(output, "APT-Release:\n");
> > +   for (std::set<string>::iterator R = Releases.begin(); R != Releases.end(); ++R)
> > +      fprintf(output, " %s\n", R->c_str());
> 
> Have you tested this with (flat) archives without a Release file?
> I have the feeling that those return an empty string, which is probably
> going to confuse EDSP readers. Maybe don't insert empty strings into
> Releases set and don't print 'APT-Release:' if Releases is empty.

Gotcha!  With the above patch and a flat Packages archive APT will
indeed produce weird stanzas like this one:

  Package: foo
  Source: foo
  Architecture: all
  Version: 1.0
  APT-ID: 40763
  Priority: optional
  Section: misc
  APT-Release:
   
  APT-Pin: 500
  APT-Candidate: yes

they are not necessarily broken, but you're absolutely right that is
better not to go there :)

Also, given APT-Release is declared as an optional field, the correct
solution is indeed the one you suggested of not outputing the
APT-Release field in this case.  This is now implemented in the attached
patch, which is a new revision of the former 6/6 patch.  An up to date
and complete patch series is available at
http://git.upsilon.cc/?p=apt.git;a=shortlog;h=refs/heads/zack/edsp-0.5

Cheers.

PS more on the more problematic patch in a separate follow-up
-- 
Stefano Zacchiroli  . . . . . . .  zack@upsilon.cc . . . . o . . . o . o
Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o
Former Debian Project Leader  . . @zack on identi.ca . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »
From 118c50aa967fbb3d3bfcb03f7a50de956a6c58d7 Mon Sep 17 00:00:00 2001
From: Stefano Zacchiroli <zack@debian.org>
Date: Thu, 5 Sep 2013 10:54:12 +0200
Subject: [PATCH] EDSP: add APT-Release field to Package stanzas

---
 apt-pkg/edsp.cc                             | 16 ++++++++++++++--
 doc/external-dependency-solver-protocol.txt |  9 +++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 70b3654..ab6fc80 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -104,10 +104,22 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI
    else if ((Ver->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
       fprintf(output, "Multi-Arch: same\n");
    signed short Pin = std::numeric_limits<signed short>::min();
-   for (pkgCache::VerFileIterator File = Ver.FileList(); File.end() == false; ++File) {
-      signed short const p = Cache.GetPolicy().GetPriority(File.File());
+   std::set<string> Releases;
+   for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; ++I) {
+      pkgCache::PkgFileIterator File = I.File();
+      signed short const p = Cache.GetPolicy().GetPriority(File);
       if (Pin < p)
 	 Pin = p;
+      if ((File->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource) {
+	 string Release = File.RelStr();
+	 if (!Release.empty())
+	    Releases.insert(Release);
+      }
+   }
+   if (!Releases.empty()) {
+       fprintf(output, "APT-Release:\n");
+       for (std::set<string>::iterator R = Releases.begin(); R != Releases.end(); ++R)
+	   fprintf(output, " %s\n", R->c_str());
    }
    fprintf(output, "APT-Pin: %d\n", Pin);
    if (Cache.GetCandidateVer(Pkg) == Ver)
diff --git a/doc/external-dependency-solver-protocol.txt b/doc/external-dependency-solver-protocol.txt
index 4eafdcf..bf16131 100644
--- a/doc/external-dependency-solver-protocol.txt
+++ b/doc/external-dependency-solver-protocol.txt
@@ -211,6 +211,15 @@ field. The following fields are supported in package stanzas:
   should be removed by the solver only when the Autoremove action is
   requested (see Request section).
 
+- **APT-Release:** (optional) The releases the package belongs to, according to
+  APT. The format of this field is multiline with one value per line and the
+  first line (the one containing the field name) empty. Each subsequent line
+  corresponds to one of the releases the package belongs to and looks like
+  this: `o=Debian,a=unstable,n=sid,l=Debian,c=main`. That is, each release line
+  is a comma-separated list of "key=value" pairs, each of which denotes a
+  Release file entry (Origin, Label, Codename, etc.) in the format of
+  APT_PREFERENCES(5).
+
 ### Answer
 
 An answer from the external solver to APT is either a *solution* or an
-- 
1.8.5.1

Attachment: signature.asc
Description: Digital signature


Reply to: