Implement Software.Extended Version

- Populate the ExtendedVersion object from MANIFEST
- Create an ExtendedVersion object

Change-Id: I13e352d4cb8f4a73259a940f341a736fe7e9305f
Signed-off-by: Chanh Nguyen <chanh@amperemail.onmicrosoft.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index d831217..e8196af 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -5,6 +5,7 @@
 #include "images.hpp"
 #include "serialize.hpp"
 #include "version.hpp"
+#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
 #include "xyz/openbmc_project/Software/Version/server.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
@@ -45,6 +46,7 @@
 
     sdbusplus::message::object_path objPath;
     auto purpose = VersionPurpose::Unknown;
+    std::string extendedVersion;
     std::string version;
     std::map<std::string, std::map<std::string, std::variant<std::string>>>
         interfaces;
@@ -87,6 +89,16 @@
                 }
             }
         }
+        else if (intf.first == EXTENDED_VERSION_IFACE)
+        {
+            for (const auto& property : intf.second)
+            {
+                if (property.first == "ExtendedVersion")
+                {
+                    extendedVersion = std::get<std::string>(property.second);
+                }
+            }
+        }
     }
     if (version.empty() || filePath.empty() ||
         purpose == VersionPurpose::Unknown)
@@ -132,7 +144,7 @@
                                          activationState, associations)));
 
         auto versionPtr = std::make_unique<VersionClass>(
-            bus, path, version, purpose, filePath,
+            bus, path, version, purpose, extendedVersion, filePath,
             std::bind(&ItemUpdater::erase, this, std::placeholders::_1));
         versionPtr->deleteObject =
             std::make_unique<phosphor::software::manager::Delete>(bus, path,
@@ -221,6 +233,10 @@
             auto purpose = server::Version::VersionPurpose::BMC;
             restorePurpose(id, purpose);
 
+            // Read os-release from /etc/ to get the BMC extended version
+            std::string extendedVersion =
+                VersionClass::getBMCExtendedVersion(osRelease);
+
             auto path = fs::path(SOFTWARE_OBJPATH) / id;
 
             // Create functional association if this is the functional
@@ -249,7 +265,7 @@
 
             // Create Version instance for this version.
             auto versionPtr = std::make_unique<VersionClass>(
-                bus, path, version, purpose, "",
+                bus, path, version, purpose, extendedVersion, "",
                 std::bind(&ItemUpdater::erase, this, std::placeholders::_1));
             auto isVersionFunctional = versionPtr->isFunctional();
             if (!isVersionFunctional)