diff options
-rwxr-xr-x | configure.ac | 8 | ||||
-rwxr-xr-x | item_updater.cpp | 31 | ||||
-rwxr-xr-x | item_updater.hpp | 4 |
3 files changed, 31 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index 7c9278c12..eeabcfa4e 100755 --- a/configure.ac +++ b/configure.ac @@ -54,18 +54,16 @@ AC_DEFINE_UNQUOTED([SOFTWARE_OBJPATH], ["$SOFTWARE_OBJPATH"], [The software mana AC_DEFINE(VERSION_IFACE, "xyz.openbmc_project.Software.Version", [The software version manager interface]) +AC_DEFINE(FILEPATH_IFACE, "xyz.openbmc_project.Common.FilePath", + [The common file path interface]) AC_DEFINE(BUSNAME_UPDATER, "org.open_power.Software.Host.Updater", [The item updater DBus busname to own.]) AC_ARG_VAR(MANIFEST_FILE, [The path to the MANIFEST file]) -AS_IF([test "x$MANIFEST_FILE" == "x"], [MANIFEST_FILE="/tmp/images/MANIFEST"]) +AS_IF([test "x$MANIFEST_FILE" == "x"], [MANIFEST_FILE="MANIFEST"]) AC_DEFINE_UNQUOTED([MANIFEST_FILE], ["$MANIFEST_FILE"], [The path to the MANIFEST file]) -AC_ARG_VAR(IMAGE_DIR, [The path to all the IMAGE files]) -AS_IF([test "x$IMAGE_DIR" == "x"], [IMAGE_DIR="/tmp/images/"]) -AC_DEFINE_UNQUOTED([IMAGE_DIR], ["$IMAGE_DIR"], [The path to all the IMAGE files]) - AC_DEFINE(MAPPER_BUSNAME, "xyz.openbmc_project.ObjectMapper", [The object mapper busname.]) AC_DEFINE(MAPPER_PATH, "/xyz/openbmc_project/object_mapper", diff --git a/item_updater.cpp b/item_updater.cpp index a8809e610..fa1c38dcc 100755 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -1,4 +1,5 @@ #include <string> +#include <experimental/filesystem> #include <fstream> #include <phosphor-logging/log.hpp> #include <xyz/openbmc_project/Software/Version/server.hpp> @@ -15,6 +16,7 @@ namespace updater // When you see server:: you know we're referencing our base class namespace server = sdbusplus::xyz::openbmc_project::Software::server; +namespace fs = std::experimental::filesystem; using namespace phosphor::logging; @@ -29,6 +31,8 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m) m.read(objPath, interfaces); std::string path(std::move(objPath)); + std::string filePath; + for (const auto& intf : interfaces) { if (intf.first == VERSION_IFACE) @@ -50,9 +54,23 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m) } } } + else if (intf.first == FILEPATH_IFACE) + { + for (const auto& property : intf.second) + { + if (property.first == "Path") + { + filePath = sdbusplus::message::variant_ns::get< + std::string>(property.second); + } + } + } + } + if (filePath.empty()) + { + return; } - auto extendedVersion = ItemUpdater::getExtendedVersion(MANIFEST_FILE); // Version id is the last item in the path auto pos = path.rfind("/"); if (pos == std::string::npos) @@ -68,7 +86,7 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m) { // Determine the Activation state by processing the given image dir. auto activationState = server::Activation::Activations::Invalid; - if (ItemUpdater::validateSquashFSImage(versionId) == 0) + if (ItemUpdater::validateSquashFSImage(filePath) == 0) { activationState = server::Activation::Activations::Ready; @@ -90,6 +108,9 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m) bus.call_noreply(method); } + fs::path manifestPath(filePath); + manifestPath /= MANIFEST_FILE; + auto extendedVersion = ItemUpdater::getExtendedVersion(manifestPath); activations.insert(std::make_pair( versionId, std::make_unique<Activation>( @@ -141,10 +162,10 @@ std::string ItemUpdater::getExtendedVersion(const std::string& manifestFilePath) return extendedVersion; } -int ItemUpdater::validateSquashFSImage(const std::string& versionId) +int ItemUpdater::validateSquashFSImage(const std::string& filePath) { - auto file = IMAGE_DIR + versionId + "/" + - std::string(squashFSImage); + fs::path file(filePath); + file /= squashFSImage; std::ifstream efile(file.c_str()); if (efile.good() == 1) diff --git a/item_updater.hpp b/item_updater.hpp index 97f500575..82df3e7d8 100755 --- a/item_updater.hpp +++ b/item_updater.hpp @@ -60,11 +60,11 @@ class ItemUpdater : public ItemUpdaterInherit /** * @brief Validates the presence of SquashFS iamge in the image dir. * - * @param[in] versionId - The software version ID. + * @param[in] filePath - The path to the SquashfFS image. * @param[out] result - 0 --> if validation was successful * - -1--> Otherwise */ - static int validateSquashFSImage(const std::string& versionId); + static int validateSquashFSImage(const std::string& filePath); /** @brief Persistent sdbusplus DBus bus connection. */ sdbusplus::bus::bus& bus; |