packages.insert (packagedb::packagecollection::value_type(pkgname, pkg));
}
- /* Create the SolvableVersion */
- SolvableVersion sv = solver.addPackage(pkgname, pkgdata);
-
- /* Register it in packagemeta */
- pkg->add_version (sv, pkgdata);
+ /* Create the SolvableVersion and register it in packagemeta */
+ pkg->add_version (pkgdata);
return pkg;
}
sourcePackages.insert (packagedb::packagecollection::value_type(pkgname, pkg));
}
- /* Create the SolvableVersion */
- SolvableVersion sv = solver.addPackage(pkgname, pkgdata);
-
- /* Register it in packagemeta */
- pkg->add_version (sv, pkgdata);
+ /* Create the SolvableVersion and register it in packagemeta */
+ SolvableVersion sv = pkg->add_version (pkgdata);
return sv;
}
versions.clear ();
}
-void
-packagemeta::add_version (packageversion & thepkg, const SolverPool::addPackageData &pkgdata)
+SolvableVersion
+packagemeta::add_version (const SolverPool::addPackageData &inpkgdata)
{
+ SolverPool::addPackageData pkgdata = inpkgdata;
+
+ packageversion *v = NULL;
+ switch (pkgdata.stability)
+ {
+ case TRUST_CURR:
+ v = &(this->curr);
+ break;
+ case TRUST_TEST:
+ v = &(this->exp);
+ break;
+ default:
+ break;
+ }
+
/*
- If a packageversion for the same version number is already present,allow
+ If a packageversion for the same version number is already present, allow
this version to replace it.
There is a problem where multiple repos provide a package. It's never been
We rely on this by adding packages from installed.db last.
*/
- set <packageversion>::iterator i = versions.find(thepkg);
- if (i != versions.end())
+ for (set <packageversion>::iterator i = versions.begin();
+ i != versions.end();
+ i++)
{
+ if (i->Canonical_version() != pkgdata.version)
+ continue;
+
+ if (pkgdata.vendor == i->Vendor())
+ {
+ /* Merge the site-list from any existing packageversion with the same
+ repository 'release:' label */
+ pkgdata.archive.sites.insert(pkgdata.archive.sites.end(),
+ i->source()->sites.begin(),
+ i->source()->sites.end());
+
+ /* Installed packages do not supersede repo packages */
+ if (pkgdata.reponame != "_installed")
+ {
+ /* Ensure a stability level doesn't point to a version we're about
+ to remove */
+ if (v && (*v == *i))
+ *v = packageversion();
+
+ i->remove();
+ }
+ }
+ else
+ {
+ /* Otherwise... if we had a way to set repo priorities, that could be
+ used to control which packageversion the solver picks. For the
+ moment, just warn that you might not be getting what you think you
+ should... */
+ Log (LOG_PLAIN) << "Version " << pkgdata.version << " of package " <<
+ name << " is present in releases labelled " << pkgdata.vendor <<
+ " and " << i->Vendor() << endLog;
+ }
+
versions.erase(i);
+
+ break;
}
+ /* Create the SolvableVersion */
+ packagedb db;
+ SolvableVersion thepkg = db.solver.addPackage(name, pkgdata);
+
/* Add the version */
std::pair<std::set <packageversion>::iterator, bool> result = versions.insert (thepkg);
#endif
/* Record the highest version at a given stability level */
- packageversion *v = NULL;
- switch (pkgdata.stability)
- {
- case TRUST_CURR:
- v = &(this->curr);
- break;
- case TRUST_TEST:
- v = &(this->exp);
- break;
- default:
- break;
- }
-
if (v)
{
/* Any version is always greater than no version */
*v = thepkg;
}
}
+
+ return thepkg;
}
bool