aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-05-01 16:24:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-05-01 16:24:12 +0200
commit1b9d5cd435b800adad6432bca91cac189ad58823 (patch)
treec43a2b4c2c45b6ed5c2ef4e17cd573f2d10d992f
parent6cabe4d21b49ea149e6694c7290ff3e1fa9e08d2 (diff)
Use standard version in bootstrap manifest
-rw-r--r--bbot/agent.cxx34
-rw-r--r--bbot/bootstrap-manifest.cxx22
-rw-r--r--bbot/bootstrap-manifest.hxx13
-rw-r--r--bbot/worker.cxx15
-rw-r--r--tests/agent/testscript4
-rw-r--r--tests/worker/bootstrap.test8
6 files changed, 51 insertions, 45 deletions
diff --git a/bbot/agent.cxx b/bbot/agent.cxx
index d30799f..bb0ccb7 100644
--- a/bbot/agent.cxx
+++ b/bbot/agent.cxx
@@ -91,10 +91,10 @@ bootstrap_machine (const dir_path& md,
toolchain_manifest {tc_id.empty () ? "bogus" : tc_id},
bootstrap_manifest {
bootstrap_manifest::versions_type {
- {"bbot", BBOT_VERSION},
- {"libbbot", LIBBBOT_VERSION},
- {"libbpkg", LIBBPKG_VERSION},
- {"libbutl", LIBBUTL_VERSION}
+ {"bbot", standard_version (BBOT_VERSION_STR)},
+ {"libbbot", standard_version (LIBBBOT_VERSION_STR)},
+ {"libbpkg", standard_version (LIBBPKG_VERSION_STR)},
+ {"libbutl", standard_version (LIBBUTL_VERSION_STR)}
}
}
};
@@ -415,13 +415,14 @@ try
//
auto compare_bbot = [] (const bootstrap_manifest& m) -> int
{
- auto cmp = [&m] (const string& n, uint64_t v) -> int
+ auto cmp = [&m] (const string& n, const char* v) -> int
{
+ standard_version sv (v);
auto i = m.versions.find (n);
- return
- i == m.versions.end () || i->second < v
- ? -1
- : i->second > v ? 1 : 0;
+
+ return (i == m.versions.end () || i->second < sv
+ ? -1
+ : i->second > sv ? 1 : 0);
};
// Start from the top assuming a new dependency cannot be added
@@ -429,10 +430,10 @@ try
//
int r;
return
- (r = cmp ("bbot", BBOT_VERSION)) != 0 ? r :
- (r = cmp ("libbbot", LIBBBOT_VERSION)) != 0 ? r :
- (r = cmp ("libbpkg", LIBBPKG_VERSION)) != 0 ? r :
- (r = cmp ("libbutl", LIBBUTL_VERSION)) != 0 ? r : 0;
+ (r = cmp ("bbot", BBOT_VERSION_STR)) != 0 ? r :
+ (r = cmp ("libbbot", LIBBBOT_VERSION_STR)) != 0 ? r :
+ (r = cmp ("libbpkg", LIBBPKG_VERSION_STR)) != 0 ? r :
+ (r = cmp ("libbutl", LIBBUTL_VERSION_STR)) != 0 ? r : 0;
};
optional<bootstrapped_machine_manifest> bmm;
@@ -777,9 +778,10 @@ try
//
if (ops.version ())
{
- cout << "bbot-agent " << BBOT_VERSION_STR << endl
- << "libbbot " << LIBBBOT_VERSION_STR << endl
- << "libbutl " << LIBBUTL_VERSION_STR << endl
+ cout << "bbot-agent " << BBOT_VERSION_ID << endl
+ << "libbbot " << LIBBBOT_VERSION_ID << endl
+ << "libbpkg " << LIBBBOT_VERSION_ID << endl
+ << "libbutl " << LIBBUTL_VERSION_ID << endl
<< "Copyright (c) 2014-2017 Code Synthesis Ltd" << endl
<< "TBC; All rights reserved" << endl;
diff --git a/bbot/bootstrap-manifest.cxx b/bbot/bootstrap-manifest.cxx
index 0d6e6b5..ebbc7ce 100644
--- a/bbot/bootstrap-manifest.cxx
+++ b/bbot/bootstrap-manifest.cxx
@@ -75,15 +75,17 @@ namespace bbot
// Package version.
//
- size_t vn;
- uint64_t pv (stoull (v, &vn));
- if (vn != v.size ())
- bad_value ("invalid package version");
-
- // Make sure the package version is not redefined.
- //
- if (!versions.emplace (move (pn), pv).second)
- bad_name (n + " redefinition");
+ try
+ {
+ // Make sure the package version is not redefined.
+ //
+ if (!versions.emplace (move (pn), standard_version (v)).second)
+ bad_name (n + " redefinition");
+ }
+ catch (const invalid_argument& e)
+ {
+ bad_value (string ("invalid package version: ") + e.what ());
+ }
}
else if (!iu)
bad_name ("unknown name '" + n + "' in bootstrap manifest");
@@ -105,7 +107,7 @@ namespace bbot
// Serialize *-version values.
//
for (const auto& v: versions)
- s.next (v.first + "-version", to_string (v.second));
+ s.next (v.first + "-version", v.second.string_project ());
s.next ("", ""); // End of manifest.
}
diff --git a/bbot/bootstrap-manifest.hxx b/bbot/bootstrap-manifest.hxx
index 9d583ad..69fb358 100644
--- a/bbot/bootstrap-manifest.hxx
+++ b/bbot/bootstrap-manifest.hxx
@@ -8,6 +8,7 @@
#include <map>
#include <butl/manifest-forward>
+#include <butl/standard-version>
#include <bbot/types.hxx>
#include <bbot/utility.hxx>
@@ -21,14 +22,14 @@ namespace bbot
{
public:
- // Map of packages to their (numeric) versions that were used inside the
- // bootstrapped machine. Used to make sure bbot agent/worker use the same
- // versions. For example:
+ // Map of packages to their (standard project) versions that were used
+ // inside the bootstrapped machine. Used to make sure bbot agent/worker
+ // use the same versions. For example:
//
- // libbbot-version: 1010100 # 1.1.1
- // bbot-version: 1010200 # 1.1.2
+ // libbbot-version: 1.2.3
+ // bbot-version: 1.2.4-a.0.1234.de2f
//
- using versions_type = std::map<string, uint64_t>;
+ using versions_type = std::map<string, butl::standard_version>;
versions_type versions;
explicit
diff --git a/bbot/worker.cxx b/bbot/worker.cxx
index f777e30..70440b0 100644
--- a/bbot/worker.cxx
+++ b/bbot/worker.cxx
@@ -465,10 +465,10 @@ bootstrap ()
{
bootstrap_manifest bm {
bootstrap_manifest::versions_type {
- {"bbot", BBOT_VERSION},
- {"libbbot", LIBBBOT_VERSION},
- {"libbpkg", LIBBPKG_VERSION},
- {"libbutl", LIBBUTL_VERSION}
+ {"bbot", standard_version (BBOT_VERSION_STR)},
+ {"libbbot", standard_version (LIBBBOT_VERSION_STR)},
+ {"libbpkg", standard_version (LIBBPKG_VERSION_STR)},
+ {"libbutl", standard_version (LIBBUTL_VERSION_STR)}
}
};
@@ -526,9 +526,10 @@ try
//
if (ops.version ())
{
- cout << "bbot-worker " << BBOT_VERSION_STR << endl
- << "libbbot " << LIBBBOT_VERSION_STR << endl
- << "libbutl " << LIBBUTL_VERSION_STR << endl
+ cout << "bbot-worker " << BBOT_VERSION_ID << endl
+ << "libbbot " << LIBBBOT_VERSION_ID << endl
+ << "libbpkg " << LIBBBOT_VERSION_ID << endl
+ << "libbutl " << LIBBUTL_VERSION_ID << endl
<< "Copyright (c) 2014-2017 Code Synthesis Ltd" << endl
<< "TBC; All rights reserved" << endl;
diff --git a/tests/agent/testscript b/tests/agent/testscript
index 529e0db..95ca388 100644
--- a/tests/agent/testscript
+++ b/tests/agent/testscript
@@ -84,7 +84,7 @@ rm = $src_base/btrfs-rmdir /build/machines
trace: enumerate_machines: bootstrapped linux-gcc
EOE
- sed -i -e 's/^(bbot-version):.*/\1: 0/' $m/linux-gcc-default/manifest
+ sed -i -e 's/^(bbot-version):.*/\1: 0.0.1/' $m/linux-gcc-default/manifest
: re-bootstrap-bbot
:
@@ -101,7 +101,7 @@ rm = $src_base/btrfs-rmdir /build/machines
trace: enumerate_machines: bootstrapped linux-gcc
EOE
- sed -i -e 's/^(bbot-version):.*/\1: 9999999990000/' $m/linux-gcc-default/manifest
+ sed -i -e 's/^(bbot-version):.*/\1: 999.999.999/' $m/linux-gcc-default/manifest
: re-bootstrap-bbot-newer
:
diff --git a/tests/worker/bootstrap.test b/tests/worker/bootstrap.test
index 91e4417..51129fa 100644
--- a/tests/worker/bootstrap.test
+++ b/tests/worker/bootstrap.test
@@ -6,8 +6,8 @@ test.options = --bootstrap
$* >>~%EOO%
: 1
-%bbot-version: \d+%
-%libbbot-version: \d+%
-%libbpkg-version: \d+%
-%libbutl-version: \d+%
+%bbot-version: .+%
+%libbbot-version: .+%
+%libbpkg-version: .+%
+%libbutl-version: .+%
EOO