From c0789a6c0e9c21418fd2d567ec8b4cda84f7b061 Mon Sep 17 00:00:00 2001 From: Pirmin Duss Date: Mon, 19 Aug 2019 12:14:29 +0200 Subject: [PATCH] depot_deploy: status report The idea is, that other components may know, when a valid init.config is available. Issue #3482 --- repos/gems/src/app/depot_deploy/children.h | 8 +++++++ repos/gems/src/app/depot_deploy/main.cc | 25 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/repos/gems/src/app/depot_deploy/children.h b/repos/gems/src/app/depot_deploy/children.h index 558e6795a..04fcbc24d 100644 --- a/repos/gems/src/app/depot_deploy/children.h +++ b/repos/gems/src/app/depot_deploy/children.h @@ -133,6 +133,14 @@ class Depot_deploy::Children child.gen_installation_entry(xml); }); } + size_t count() const + { + size_t count = 0; + _children.for_each([&] (Child const &) { + ++count; }); + return count; + } + bool any_incomplete() const { bool result = false; diff --git a/repos/gems/src/app/depot_deploy/main.cc b/repos/gems/src/app/depot_deploy/main.cc index 683f385cb..eac86d841 100644 --- a/repos/gems/src/app/depot_deploy/main.cc +++ b/repos/gems/src/app/depot_deploy/main.cc @@ -13,6 +13,7 @@ /* Genode includes */ #include +#include #include #include #include @@ -34,6 +35,8 @@ struct Depot_deploy::Main Expanding_reporter _query_reporter { _env, "query" , "query"}; Expanding_reporter _init_config_reporter { _env, "config", "init.config"}; + Constructible _state_reporter { }; + Heap _heap { _env.ram(), _env.rm() }; Children _children { _heap }; @@ -48,6 +51,16 @@ struct Depot_deploy::Main _config.update(); _blueprint.update(); + bool const report_state = + _config.xml().has_sub_node("report") && + _config.xml().sub_node("report").attribute_value("state", false); + + _state_reporter.conditional(report_state, _env, "state", "state"); + + if (_state_reporter.constructed()) + _state_reporter->generate([&] (Xml_generator xml) { + xml.attribute("running", true); }); + Xml_node const config = _config.xml(); _children.apply_config(config); @@ -76,6 +89,17 @@ struct Depot_deploy::Main _children.gen_queries(xml); }); } + + if ((_children.count() > 0UL) + && !_children.any_incomplete() + && !_children.any_blueprint_needed() + && _state_reporter.constructed()) { + + _state_reporter->generate([&] (Xml_generator xml) { + xml.attribute("running", false); + xml.attribute("count", _children.count()); + }); + } } Main(Env &env) : _env(env) @@ -83,6 +107,7 @@ struct Depot_deploy::Main _config .sigh(_config_handler); _blueprint.sigh(_config_handler); + _handle_config(); } };