From 53c2aa8e382dd50d09b385285bc3fa0b645ace0a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 19 Aug 2016 17:37:29 +0300 Subject: Support system packages --- bpkg/pkg-status.cxx | 86 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 25 deletions(-) (limited to 'bpkg/pkg-status.cxx') diff --git a/bpkg/pkg-status.cxx b/bpkg/pkg-status.cxx index 1396b1a..0cb4168 100644 --- a/bpkg/pkg-status.cxx +++ b/bpkg/pkg-status.cxx @@ -58,31 +58,44 @@ namespace bpkg // Now look for available packages. // + bool available; // At least one vailable package (stub or not). vector> aps; { + shared_ptr rep (db.load ("")); // Root. + using query = query; query q (query::id.name == n); - // If the user specified the version, then only look for that specific - // version (we still do it since there might be other revisions). - // - if (!v.empty ()) - q = q && compare_version_eq (query::id.version, v, v.revision != 0); - - // And if we found an existing package, then only look for versions - // greater than what already exists. - // - if (p != nullptr) - q = q && query::id.version > p->version; - - q += order_by_version_desc (query::id.version); + available = + filter_one (rep, db.query (q)).first != nullptr; - // Only consider packages that are in repositories that were explicitly - // added to the configuration and their complements, recursively. - // - aps = filter (db.load (""), - db.query (q)); + if (available) + { + // If the user specified the version, then only look for that + // specific version (we still do it since there might be other + // revisions). + // + if (!v.empty ()) + q = q && + compare_version_eq (query::id.version, v, v.revision != 0); + + // And if we found an existing package, then only look for versions + // greater than what already exists. Note that for a system wildcard + // version we will always show all available versions (since it's + // 0). + // + if (p != nullptr) + q = q && query::id.version > p->version; + + q += order_by_version_desc (query::id.version); + + // Only consider packages that are in repositories that were + // explicitly added to the configuration and their complements, + // recursively. + // + aps = filter (rep, db.query (q)); + } } if (multi) @@ -101,10 +114,13 @@ namespace bpkg { cout << p->state; + if (p->substate != package_substate::none) + cout << ',' << p->substate; + // Also print the version of the package unless the user specified it. // if (v != p->version) - cout << " " << p->version; + cout << ' ' << p->version_string (); if (p->hold_package) cout << " hold_package"; @@ -115,19 +131,39 @@ namespace bpkg found = true; } - if (!aps.empty ()) + if (available) { cout << (found ? "; " : "") << "available"; - // If the user specified the version, then there might only be one - // entry in which case it is useless to repeat it. + // The idea is that in the future we will try to auto-discover a + // system version and then print that. For now we just say "maybe + // available from the system" but only if no version was specified by + // the user. We will later compare it if the user did specify the + // version. // - if (v.empty () || aps.size () > 1 || aps[0]->version != v) + bool sys (v.empty ()); + + if (!aps.empty ()) { - for (shared_ptr ap: aps) - cout << ' ' << ap->version; + // If the user specified the version, then there might only be one + // entry in which case it is useless to repeat it. But we do want + // to print it if there is also a system one. + // + if (sys || v.empty () || aps.size () > 1 || aps[0]->version != v) + { + for (shared_ptr ap: aps) + { + if (ap->stub ()) + break; // All the rest are stubs so bail out. + + cout << ' ' << ap->version; + } + } } + if (sys) + cout << " sys:?"; + found = true; } -- cgit v1.1