aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-08-19 17:37:29 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-08-29 18:20:03 +0300
commit53c2aa8e382dd50d09b385285bc3fa0b645ace0a (patch)
tree6d23d091bc57c0aa8d8a529e63ec2f2f22322a3a /bpkg/package.cxx
parenta4b29effed15b0a3e9309a4633a3ada37f3081e6 (diff)
Support system packages
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r--bpkg/package.cxx44
1 files changed, 42 insertions, 2 deletions
diff --git a/bpkg/package.cxx b/bpkg/package.cxx
index 2cf96ff..6089c23 100644
--- a/bpkg/package.cxx
+++ b/bpkg/package.cxx
@@ -11,6 +11,8 @@ using namespace std;
namespace bpkg
{
+ const version wildcard_version (0, "0", nullopt, 0);
+
// available_package_id
//
bool
@@ -22,7 +24,6 @@ namespace bpkg
// available_package
//
-
// Check if the package is available from the specified repository,
// its prerequisite repositories, or one of their complements,
// recursively. Return the first repository that contains the
@@ -104,6 +105,21 @@ namespace bpkg
return result ();
}
+ // selected_package
+ //
+ string selected_package::
+ version_string () const
+ {
+ return version != wildcard_version ? version.string () : "*";
+ }
+
+ ostream&
+ operator<< (ostream& os, const selected_package& p)
+ {
+ os << (p.system () ? "sys:" : "") << p.name << "/" << p.version_string ();
+ return os;
+ }
+
// state
//
string
@@ -111,6 +127,7 @@ namespace bpkg
{
switch (s)
{
+ case package_state::transient: return "transient";
case package_state::broken: return "broken";
case package_state::fetched: return "fetched";
case package_state::unpacked: return "unpacked";
@@ -123,13 +140,36 @@ namespace bpkg
package_state
to_package_state (const string& s)
{
- if (s == "broken") return package_state::broken;
+ if (s == "transient") return package_state::transient;
+ else if (s == "broken") return package_state::broken;
else if (s == "fetched") return package_state::fetched;
else if (s == "unpacked") return package_state::unpacked;
else if (s == "configured") return package_state::configured;
else throw invalid_argument ("invalid package state '" + s + "'");
}
+ // substate
+ //
+ string
+ to_string (package_substate s)
+ {
+ switch (s)
+ {
+ case package_substate::none: return "none";
+ case package_substate::system: return "system";
+ }
+
+ return string (); // Should never reach.
+ }
+
+ package_substate
+ to_package_substate (const string& s)
+ {
+ if (s == "none") return package_substate::none;
+ else if (s == "system") return package_substate::system;
+ else throw invalid_argument ("invalid package substate '" + s + "'");
+ }
+
// certificate
//
ostream&