aboutsummaryrefslogtreecommitdiff
path: root/bpkg/system-repository.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/system-repository.cxx
parenta4b29effed15b0a3e9309a4633a3ada37f3081e6 (diff)
Support system packages
Diffstat (limited to 'bpkg/system-repository.cxx')
-rw-r--r--bpkg/system-repository.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/bpkg/system-repository.cxx b/bpkg/system-repository.cxx
new file mode 100644
index 0000000..b2a892d
--- /dev/null
+++ b/bpkg/system-repository.cxx
@@ -0,0 +1,33 @@
+// file : bpkg/system-repository.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <bpkg/system-repository>
+
+namespace bpkg
+{
+ system_repository_type system_repository;
+
+ const version& system_repository_type::
+ insert (const string& name, const version& v, bool authoritative)
+ {
+ auto p (map_.emplace (name, system_package {v, authoritative}));
+
+ if (!p.second)
+ {
+ system_package& sp (p.first->second);
+
+ // We should not override authoritative information.
+ //
+ assert (!(authoritative && sp.authoritative));
+
+ if (authoritative >= sp.authoritative)
+ {
+ sp.authoritative = authoritative;
+ sp.version = v;
+ }
+ }
+
+ return p.first->second.version;
+ }
+}