depot_query/deploy: allow pkg <rom> relabeling

This patch adds the ability to specify an optional 'as' attribute in a
<rom> module declarion of a runtime file.

  <runtime ...>
    ...
    <content>
      <rom label="camera-pinephone.dtb" as="dtb"/>
      ...
    </content>
  </runtime>

If specified, The depot-deploy tool uses the provided attribute value to
hand out the ROM 'camera-pinephone.dtb' under the label 'dtb' to the
subsystem.
This commit is contained in:
Norman Feske 2023-03-16 14:51:32 +01:00 committed by Christian Helmuth
parent 7927c0b540
commit 123df93741
2 changed files with 12 additions and 3 deletions

View File

@ -627,6 +627,7 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
typedef Name Label;
Path const path = rom.attribute_value("path", Path());
Label const label = rom.attribute_value("label", Label());
Label const as = rom.attribute_value("as", label);
xml.node("service", [&] () {
xml.attribute("name", "ROM");
@ -634,7 +635,7 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
if (route_binary_to_shim && label == _binary_name)
xml.attribute("label", "binary");
else
xml.attribute("label_last", label);
xml.attribute("label_last", as);
if (cached_depot_rom.valid()) {
xml.node("child", [&] () {

View File

@ -87,6 +87,7 @@ void Depot_query::Main::_gen_rom_path_nodes(Xml_generator &xml,
return;
Rom_label const label = node.attribute_value("label", Rom_label());
Rom_label const as = node.attribute_value("as", label);
/* skip ROM that is provided by the environment */
bool provided_by_env = false;
@ -94,9 +95,16 @@ void Depot_query::Main::_gen_rom_path_nodes(Xml_generator &xml,
if (node.attribute_value("label", Rom_label()) == label)
provided_by_env = true; });
auto gen_label_attr = [&]
{
xml.attribute("label", label);
if (as != label)
xml.attribute("as", as);
};
if (provided_by_env) {
xml.node("rom", [&] () {
xml.attribute("label", label);
gen_label_attr();
xml.attribute("env", "yes");
});
return;
@ -107,7 +115,7 @@ void Depot_query::Main::_gen_rom_path_nodes(Xml_generator &xml,
if (rom_path.valid()) {
xml.node("rom", [&] () {
xml.attribute("label", label);
gen_label_attr();
xml.attribute("path", rom_path);
});