[PATCH setup 3/3] Keep track of all known sites for a given version of a package

Ken Brown kbrown@cornell.edu
Sat Mar 17 15:00:00 GMT 2018


When adding a packageversion for an entry in setup.ini, make its
packagesource::sites vector include the sites from previously
processed ini files.

Also remove from the libsolv pool the previous packageversions, so
that libsolv will always find the one that lists all the sites.
---
 IniDBBuilderPackage.cc | 11 ++++++++++-
 package_meta.cc        |  8 ++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 324f1bf..0b84def 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -148,6 +148,11 @@ IniDBBuilderPackage::buildPackageInstall (const std::string& path,
   // set archive path, size, mirror, hash
   cbpv.archive.set_canonical(path.c_str());
   cbpv.archive.size = atoi(size.c_str());
+  // do we already have some sites from previously read ini files?
+  packagedb db;
+  packageversion pv = db.findBinaryVersion(PackageSpecification(name, cbpv.version));
+  if (pv)
+    cbpv.archive.sites = pv.source()->sites;
   cbpv.archive.sites.push_back(site(parse_mirror));
 
   switch (type) {
@@ -190,6 +195,11 @@ IniDBBuilderPackage::buildPackageSource (const std::string& path,
   cspv.archive = packagesource();
   cspv.archive.set_canonical(path.c_str());
   cspv.archive.size = atoi(size.c_str());
+  // do we already have some sites from previously read ini files?
+  packagedb db;
+  packageversion pv = db.findBinaryVersion(PackageSpecification(name, cbpv.version));
+  if (pv)
+    cspv.archive.sites = pv.sourcePackage().source()->sites;
   cspv.archive.sites.push_back(site(parse_mirror));
 
   switch (type) {
@@ -210,7 +220,6 @@ IniDBBuilderPackage::buildPackageSource (const std::string& path,
     break;
   }
 
-  packagedb db;
   packageversion spkg_id = db.addSource (name + "-src", cspv);
 
   /* create relationship between binary and source packageversions */
diff --git a/package_meta.cc b/package_meta.cc
index 7f8110d..89b67bc 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -140,6 +140,14 @@ packagemeta::add_version (packageversion & thepkg, const SolverPool::addPackageD
   set <packageversion>::iterator i = versions.find(thepkg);
   if (i != versions.end())
     {
+      if (pkgdata.reponame != "_installed")
+	{
+	  if (curr == *i)
+	    curr = thepkg;
+	  if (exp == *i)
+	    exp = thepkg;
+	  i->remove();
+	}
       versions.erase(i);
     }
 
-- 
2.16.2



More information about the Cygwin-apps mailing list