diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-03 12:07:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-03 12:07:02 +0200 |
commit | f5ab412da304e3970a6b5b3290758ed791c31881 (patch) | |
tree | 28ddc870029302d6a26209dba0f73b3ce692744d | |
parent | fa5ebd101b792fdf038394f0aaa4a4ab8e28dab6 (diff) |
Pass toolchain name/version to controller
-rw-r--r-- | bbot/agent.cli | 7 | ||||
-rw-r--r-- | bbot/agent.cxx | 19 | ||||
-rw-r--r-- | bbot/agent.hxx | 7 | ||||
-rw-r--r-- | bbot/bbot-agent@.service | 2 | ||||
-rw-r--r-- | bbot/bootstrap-manifest.hxx | 3 | ||||
-rw-r--r-- | bbot/types-parsers.cxx | 21 | ||||
-rw-r--r-- | bbot/types-parsers.hxx | 7 | ||||
-rw-r--r-- | bbot/types.hxx | 5 |
8 files changed, 62 insertions, 9 deletions
diff --git a/bbot/agent.cli b/bbot/agent.cli index 49563f8..b55379c 100644 --- a/bbot/agent.cli +++ b/bbot/agent.cli @@ -54,6 +54,13 @@ namespace bbot "Toolchain number, 1 by default." } + standard_version --toolchain-ver + { + "<stdver>", + "Toolchain version. If unspecified, then the agent's version will be + used (which will be imprecise for snapshot versions)." + } + string --toolchain-id { "<str>", diff --git a/bbot/agent.cxx b/bbot/agent.cxx index 731a172..671f1c0 100644 --- a/bbot/agent.cxx +++ b/bbot/agent.cxx @@ -43,9 +43,10 @@ namespace bbot const string bs_prot ("1"); - string tc_name; - uint16_t tc_num; - string tc_id; + string tc_name; + uint16_t tc_num; + standard_version tc_ver; + string tc_id; string hname; uid_t uid; @@ -802,6 +803,9 @@ try tc_name = ops.toolchain_name (); tc_num = ops.toolchain_num (); + tc_ver = (ops.toolchain_ver_specified () + ? ops.toolchain_ver () + : standard_version (BBOT_VERSION_STR)); tc_id = ops.toolchain_id (); @@ -834,6 +838,7 @@ try dr << info << "bbot agent " << BBOT_VERSION_ID << info << "toolchain name " << tc_name << info << "toolchain num " << tc_num << + info << "toolchain ver " << tc_ver.string () << info << "toolchain id " << tc_id << info << "CPU(s) " << ops.cpu () << info << "RAM(kB) " << ops.ram (); @@ -865,7 +870,13 @@ try // // @@ TODO: key fingerprint. // - task_request_manifest tq {hname, nullopt, machine_header_manifests {}}; + task_request_manifest tq { + hname, + tc_name, + tc_ver, + nullopt, + machine_header_manifests {} + }; for (const bootstrapped_machine_manifest& m: ms) tq.machines.emplace_back (m.machine.id, diff --git a/bbot/agent.hxx b/bbot/agent.hxx index e5115ae..f009a64 100644 --- a/bbot/agent.hxx +++ b/bbot/agent.hxx @@ -18,9 +18,10 @@ namespace bbot extern const string bs_prot; // Bootstrap protocol version. - extern string tc_name; // Toolchain name. - extern uint16_t tc_num; // Toolchain number. - extern string tc_id; // Toolchain id. + extern string tc_name; // Toolchain name. + extern uint16_t tc_num; // Toolchain number. + extern standard_version tc_ver; // Toolchain version. + extern string tc_id; // Toolchain id. extern string hname; // Our host name. extern uid_t uid; // Our effective user id. diff --git a/bbot/bbot-agent@.service b/bbot/bbot-agent@.service index dd7ca21..66d46f4 100644 --- a/bbot/bbot-agent@.service +++ b/bbot/bbot-agent@.service @@ -18,6 +18,7 @@ Environment=REQUEST_TIMEOUT=300 Environment=TOOLCHAIN_NAME=%i Environment=TOOLCHAIN_NUM=1 +Environment=TOOLCHAIN_VER= Environment=TOOLCHAIN_ID= Environment="CONTROLLER_URL=" @@ -34,6 +35,7 @@ ExecStart=/build/bots/%i/bin/bbot-agent --systemd-daemon \ --request-timeout ${REQUEST_TIMEOUT} \ --toolchain-name ${TOOLCHAIN_NAME} \ --toolchain-num ${TOOLCHAIN_NUM} \ + --toolchain-ver ${TOOLCHAIN_VER} \ --toolchain-id ${TOOLCHAIN_ID} \ $CONTROLLER_TRUST \ $CONTROLLER_URL diff --git a/bbot/bootstrap-manifest.hxx b/bbot/bootstrap-manifest.hxx index 6b56785..5a32b72 100644 --- a/bbot/bootstrap-manifest.hxx +++ b/bbot/bootstrap-manifest.hxx @@ -8,7 +8,6 @@ #include <map> #include <libbutl/manifest-forward.hxx> -#include <libbutl/standard-version.hxx> #include <bbot/types.hxx> #include <bbot/utility.hxx> @@ -29,7 +28,7 @@ namespace bbot // libbbot-version: 1.2.3 // bbot-version: 1.2.4-a.0.1234.de2f // - using versions_type = std::map<string, butl::standard_version>; + using versions_type = std::map<string, standard_version>; versions_type versions; explicit diff --git a/bbot/types-parsers.cxx b/bbot/types-parsers.cxx index 1d0a250..af48ff7 100644 --- a/bbot/types-parsers.cxx +++ b/bbot/types-parsers.cxx @@ -47,5 +47,26 @@ namespace bbot xs = true; parse_path (x, s); } + + void parser<standard_version>:: + parse (standard_version& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const char* v (s.next ()); + + try + { + x = standard_version (v); + } + catch (const invalid_argument&) + { + throw invalid_value (o, v); //@@ Would be nice to include description. + } + } } } diff --git a/bbot/types-parsers.hxx b/bbot/types-parsers.hxx index eef3418..033789b 100644 --- a/bbot/types-parsers.hxx +++ b/bbot/types-parsers.hxx @@ -32,6 +32,13 @@ namespace bbot static void parse (dir_path&, bool&, scanner&); }; + + template <> + struct parser<standard_version> + { + static void + parse (standard_version&, bool&, scanner&); + }; } } diff --git a/bbot/types.hxx b/bbot/types.hxx index 0ab6377..e1c1cca 100644 --- a/bbot/types.hxx +++ b/bbot/types.hxx @@ -24,6 +24,7 @@ #include <libbutl/optional.hxx> #include <libbutl/vector-view.hxx> #include <libbutl/small-vector.hxx> +#include <libbutl/standard-version.hxx> namespace bbot { @@ -85,6 +86,10 @@ namespace bbot using paths = std::vector<path>; using dir_paths = std::vector<dir_path>; + + // <libbutl/standard-version.hxx> + // + using butl::standard_version; } // In order to be found (via ADL) these have to be either in std:: or in |