From 6f0a727aeeed2fbe6cf3902371254a633478056d Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sun, 20 May 2018 00:45:03 +0200 Subject: [PATCH] depot_deploy: support lazy pkg installation This patch enhances the 'Child' interface with the ability to retry the deployment after an initial attempt failed. This way, packages can be installed on demand based on the error feedback of deployment attempts. --- repos/gems/src/app/depot_deploy/child.h | 29 +++++++++++++++++++++- repos/gems/src/app/depot_deploy/children.h | 12 +++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index 87d2a7bb45..6888386d48 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -140,6 +140,9 @@ class Depot_deploy::Child : public List_model::Element if (pkg.attribute_value("path", Archive::Path()) != _blueprint_pkg_path) return; + /* package was missing but is installed now */ + _pkg_incomplete = false; + Xml_node const runtime = pkg.sub_node("runtime"); Number_of_bytes const ram { runtime.attribute_value("ram", Number_of_bytes()) }; @@ -165,11 +168,22 @@ class Depot_deploy::Child : public List_model::Element if (path != _blueprint_pkg_path) return; - error(path, " incomplete or missing"); + log(path, " incomplete or missing"); _pkg_incomplete = true; } + /** + * Reconsider deployment of child after installing missing archives + */ + void reset_incomplete() + { + if (_pkg_incomplete) { + _pkg_incomplete = false; + _pkg_xml.destruct(); + } + } + void gen_query(Xml_generator &xml) const { if (_configured() || _pkg_incomplete) @@ -190,6 +204,19 @@ class Depot_deploy::Child : public List_model::Element */ inline void gen_start_node(Xml_generator &, Xml_node common, Depot_rom_server const &depot_rom) const; + + /** + * Generate installation entry needed for the completion of the child + */ + void gen_installation_entry(Xml_generator &xml) const + { + if (!_pkg_incomplete) return; + + xml.node("archive", [&] () { + xml.attribute("path", _config_pkg_path()); + xml.attribute("source", "no"); + }); + } }; diff --git a/repos/gems/src/app/depot_deploy/children.h b/repos/gems/src/app/depot_deploy/children.h index 4696d8c2ce..315d87c3af 100644 --- a/repos/gems/src/app/depot_deploy/children.h +++ b/repos/gems/src/app/depot_deploy/children.h @@ -78,6 +78,12 @@ class Depot_deploy::Children child.mark_as_incomplete(missing); }); }); } + void reset_incomplete() + { + _children.for_each([&] (Child &child) { + child.reset_incomplete(); }); + } + void gen_start_nodes(Xml_generator &xml, Xml_node common, Child::Depot_rom_server const &depot_rom) const { @@ -90,6 +96,12 @@ class Depot_deploy::Children _children.for_each([&] (Child const &child) { child.gen_query(xml); }); } + + void gen_installation_entries(Xml_generator &xml) const + { + _children.for_each([&] (Child const &child) { + child.gen_installation_entry(xml); }); + } }; #endif /* _CHILDREN_H_ */