Add support for Inventory.Decorator.Compatible
This adds support for the compatibility strings interface described in
https://github.com/openbmc/phosphor-dbus-interfaces/tree/master/yaml/xyz/openbmc_project/Software#compatibility.
The Version objects will now be created with the Inventory.Decorator.Compatible
interface with the compatibility names coming from the MANIFEST file.
e.g.
version=1.2.3
MachineName=foo
purpose=Other
ExtendedVersion=a.b.c
CompatibleName=foo.bar
CompatibleName=baz.bim
Tested:
$ busctl get-property xyz.openbmc_project.Software.Version \
/xyz/openbmc_project/software/517751da \
xyz.openbmc_project.Inventory.Decorator.Compatible Names
as 2 "foo.bar" "baz.bim"
Signed-off-by: Justin Ledford <justinledford@google.com>
Change-Id: I9ee36af2d3d1494d533a3b09c466a250c4fe786b
diff --git a/item_updater.cpp b/item_updater.cpp
index cfe0ae5..c8fda76 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -49,11 +49,14 @@
auto purpose = VersionPurpose::Unknown;
std::string extendedVersion;
std::string version;
- std::map<std::string, std::map<std::string, std::variant<std::string>>>
+ std::map<std::string,
+ std::map<std::string,
+ std::variant<std::string, std::vector<std::string>>>>
interfaces;
msg.read(objPath, interfaces);
std::string path(std::move(objPath));
std::string filePath;
+ std::vector<std::string> compatibleNames;
for (const auto& intf : interfaces)
{
@@ -100,6 +103,17 @@
}
}
}
+ else if (intf.first == COMPATIBLE_IFACE)
+ {
+ for (const auto& property : intf.second)
+ {
+ if (property.first == "Names")
+ {
+ compatibleNames =
+ std::get<std::vector<std::string>>(property.second);
+ }
+ }
+ }
}
if (version.empty() || filePath.empty() ||
purpose == VersionPurpose::Unknown)
@@ -140,6 +154,7 @@
auto versionPtr = std::make_unique<VersionClass>(
bus, path, version, purpose, extendedVersion, filePath,
+ compatibleNames,
std::bind(&ItemUpdater::erase, this, std::placeholders::_1),
versionId);
versionPtr->deleteObject =
@@ -284,6 +299,7 @@
// Create Version instance for this version.
auto versionPtr = std::make_unique<VersionClass>(
bus, path, version, purpose, extendedVersion, flashId,
+ std::vector<std::string>(),
std::bind(&ItemUpdater::erase, this, std::placeholders::_1),
id);
if (functional)
@@ -843,6 +859,7 @@
};
biosVersion = std::make_unique<VersionClass>(
bus, path, version, VersionPurpose::Host, "", "",
+ std::vector<std::string>(),
std::bind(dummyErase, std::placeholders::_1), "");
biosVersion->deleteObject =
std::make_unique<phosphor::software::manager::Delete>(bus, path,