aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-04-04 16:03:04 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-04-19 19:39:55 +0300
commite958b63712f9a0ff4b523765d2fe12b58aa97fe0 (patch)
tree97ab99f430c0a6b40997aae56ced865e103cb9be /bpkg/package.cxx
parent00f75769842b303fd08d8465cd3dc682b6161664 (diff)
Implement dependency up/down-grade/unhold
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r--bpkg/package.cxx46
1 files changed, 42 insertions, 4 deletions
diff --git a/bpkg/package.cxx b/bpkg/package.cxx
index 21c2109..08e71f9 100644
--- a/bpkg/package.cxx
+++ b/bpkg/package.cxx
@@ -9,6 +9,7 @@
#include <bpkg/database.hxx>
#include <bpkg/checksum.hxx>
+#include <bpkg/diagnostics.hxx>
#include <bpkg/manifest-utility.hxx>
using namespace std;
@@ -145,20 +146,22 @@ namespace bpkg
return result ();
}
- vector<shared_ptr<available_package>>
+ vector<pair<shared_ptr<available_package>, shared_ptr<repository>>>
filter (const vector<shared_ptr<repository>>& rps,
odb::result<available_package>&& apr,
bool prereq)
{
- vector<shared_ptr<available_package>> aps;
+ vector<pair<shared_ptr<available_package>, shared_ptr<repository>>> aps;
for (shared_ptr<available_package> ap: pointer_result (apr))
{
for (const shared_ptr<repository> r: rps)
{
- if (filter (r, ap, prereq) != nullptr)
+ shared_ptr<repository> ar (filter (r, ap, prereq));
+
+ if (ar != nullptr)
{
- aps.push_back (move (ap));
+ aps.emplace_back (move (ap), move (ar));
break;
}
}
@@ -167,6 +170,41 @@ namespace bpkg
return aps;
}
+ void
+ check_any_available (const dir_path& c,
+ transaction& t,
+ const diag_record* dr)
+ {
+ database& db (t.database ());
+
+ if (db.query_value<repository_count> () == 0)
+ {
+ diag_record d;
+ (dr != nullptr ? *dr << info : d << fail)
+ << "configuration " << c << " has no repositories" <<
+ info << "use 'bpkg rep-add' to add a repository";
+ }
+ else if (db.query_value<available_package_count> () == 0)
+ {
+ diag_record d;
+ (dr != nullptr ? *dr << info : d << fail)
+ << "configuration " << c << " has no available packages" <<
+ info << "use 'bpkg rep-fetch' to fetch available packages list";
+ }
+ }
+
+ string
+ package_string (const string& n, const version& v, bool system)
+ {
+ string vs (v.empty ()
+ ? string ()
+ : v == wildcard_version
+ ? "/*"
+ : '/' + v.string ());
+
+ return system ? "sys:" + n + vs : n + vs;
+ }
+
// selected_package
//
string selected_package::