diff options
Diffstat (limited to 'bpkg/package-query.cxx')
-rw-r--r-- | bpkg/package-query.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bpkg/package-query.cxx b/bpkg/package-query.cxx index 9705579..0c6d459 100644 --- a/bpkg/package-query.cxx +++ b/bpkg/package-query.cxx @@ -7,6 +7,7 @@ #include <bpkg/package-odb.hxx> #include <bpkg/database.hxx> #include <bpkg/rep-mask.hxx> +#include <bpkg/satisfaction.hxx> using namespace std; @@ -26,6 +27,34 @@ namespace bpkg return i != imaginary_stubs.end () ? *i : nullptr; } + vector<pair<reference_wrapper<database>, + shared_ptr<available_package>>> existing_packages; + + pair<shared_ptr<available_package>, lazy_shared_ptr<repository_fragment>> + find_existing (const package_name& name, + const optional<version_constraint>& c, + const lazy_shared_ptr<repository_fragment>& rf) + { + database& db (rf.database ()); + + pair<shared_ptr<available_package>, + lazy_shared_ptr<repository_fragment>> r; + + for (const auto& p: existing_packages) + { + if (p.first == db && + p.second->id.name == name && + (!c || satisfies (p.second->version, *c))) + { + r.first = p.second; + r.second = lazy_shared_ptr<repository_fragment> (db, empty_string); + break; + } + } + + return r; + } + linked_databases repo_configs; linked_databases |