summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-03-03 11:20:52 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-03-03 11:21:55 +0100
commit45b04762e1990a761a7c308f9e73a286a92f908a (patch)
tree80062a0bc3aa8c8ac8b248868e77680e4972f92a
parentb33677749142e0997121d358277b18136bdbef87 (diff)
edsp: Write 'Size' to the EDSP files
This allows solvers to optimize by download size; and gives us a better means of interpreting "downloadable" debs (they must have a size > 0 after all).
-rw-r--r--apt-pkg/edsp.cc2
-rw-r--r--apt-pkg/edsp/edsplistparser.cc7
-rwxr-xr-xtest/integration/test-external-dependency-solver-protocol2
3 files changed, 9 insertions, 2 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 6e02369c9..196f9d307 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -243,6 +243,8 @@ static bool WriteScenarioEDSPVersion(pkgDepCache &Cache, FileFd &output, pkgCach
WriteOkay(Okay, output, "\nPriority: ", Prio);
if (Ver->Section != 0)
WriteOkay(Okay, output, "\nSection: ", Ver.Section());
+ if (Ver->Size != 0)
+ WriteOkay(Okay, output, "\nSize: ", Ver->Size);
if (Pkg.CurrentVer() == Ver)
WriteOkay(Okay, output, "\nInstalled: yes");
if (Pkg->SelectedState == pkgCache::State::Hold ||
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index 14967e110..a3cdf794f 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -56,8 +56,11 @@ bool edspLikeListParser::NewVersion(pkgCache::VerIterator &Ver)
}
}
- // Fake a size such that the deb appears downloadable if it has a source
- Ver->Size = Section.Exists("APT-Release");
+ // If we have a Size field, use it, otherwise fake one based on APT-Release to
+ // be able to distinguish downloadable debs from installed ones.
+ Ver->Size = Section.Exists(pkgTagSection::Key::Size)
+ ? Section.FindI(pkgTagSection::Key::Size)
+ : Section.Exists("APT-Release");
return true;
}
/*}}}*/
diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol
index 81204fc19..bc32886c5 100755
--- a/test/integration/test-external-dependency-solver-protocol
+++ b/test/integration/test-external-dependency-solver-protocol
@@ -189,6 +189,7 @@ Source: stuff
Source-Version: 3
Priority: optional
Section: other
+Size: 42
APT-Release:
a=experimental,n=experimental,c=main,b=all
APT-Pin: 1
@@ -202,6 +203,7 @@ Source: stuff
Source-Version: 2
Priority: optional
Section: other
+Size: 42
APT-Release:
a=unstable,n=sid,c=main,b=all
APT-Pin: 500