Read image version from the MANIFEST.
According to Patrick, all information regarding the
image must be read from the MANIFEST, such as version.
Also we must never open/read pnor.toc.
Change-Id: Icf9f83f9ec055de21e2cf13e4ab4ab4afafc2af7
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/configure.ac b/configure.ac
index de7c5b7..9c0b406 100755
--- a/configure.ac
+++ b/configure.ac
@@ -61,9 +61,9 @@
AC_DEFINE(BUSNAME_UPDATER, "org.open_power.Software.Host.Updater",
[The item updater DBus busname to own.])
-AC_ARG_VAR(TOC_FILE, [The path to the pnor toc file])
-AS_IF([test "x$TOC_FILE" == "x"], [TOC_FILE="/tmp/pnor/pnor.toc"])
-AC_DEFINE_UNQUOTED([TOC_FILE], ["$TOC_FILE"], [The path to the pnor toc file])
+AC_ARG_VAR(MANIFEST_FILE, [The path to the MANIFEST file])
+AS_IF([test "x$MANIFEST_FILE" == "x"], [MANIFEST_FILE="/tmp/pnor/MANIFEST"])
+AC_DEFINE_UNQUOTED([MANIFEST_FILE], ["$MANIFEST_FILE"], [The path to the MANIFEST file])
AC_DEFINE(MAPPER_BUSNAME, "xyz.openbmc_project.ObjectMapper",
[The object mapper busname.])
diff --git a/generate-squashfs b/generate-squashfs
index e85cc87..11f0abc 100755
--- a/generate-squashfs
+++ b/generate-squashfs
@@ -104,7 +104,7 @@
echo "Creating MANIFEST for the image"
manifest_location="${scratch_dir}/MANIFEST"
-echo -e "purpose: host\nversion: $version" >> $manifest_location
+echo -e "purpose=host\nversion=$version" >> $manifest_location
echo "Generating tarball to contain the SquashFS image and its MANIFEST"
tar -cvf $outfile $manifest_location ${scratch_dir}/pnor.xz.squashfs
diff --git a/test/utest.cpp b/test/utest.cpp
index 4da45a5..4fd1e78 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -37,17 +37,17 @@
/** @brief Make sure we correctly get the version from getVersion()*/
TEST_F(VersionTest, TestGetVersion)
{
- auto tocFilePath = _directory + "/" + "pnor.toc";
+ auto manifestFilePath = _directory + "/" + "MANIFEST";
auto version = "test-version";
std::ofstream file;
- file.open(tocFilePath, std::ofstream::out);
+ file.open(manifestFilePath, std::ofstream::out);
ASSERT_TRUE(file.is_open());
file << "version=" << version << std::endl;
file.close();
- EXPECT_EQ(Version::getVersion(tocFilePath), version);
+ EXPECT_EQ(Version::getVersion(manifestFilePath), version);
}
/** @brief Make sure we correctly get the Id from getId()*/
diff --git a/version_host_software_manager.cpp b/version_host_software_manager.cpp
index 7719270..6b392d4 100644
--- a/version_host_software_manager.cpp
+++ b/version_host_software_manager.cpp
@@ -15,15 +15,15 @@
using namespace phosphor::logging;
-std::string Version::getVersion(const std::string& tocFilePath)
+std::string Version::getVersion(const std::string& manifestFilePath)
{
constexpr auto versionKey = "version=";
constexpr auto versionKeySize = strlen(versionKey);
- if (tocFilePath.empty())
+ if (manifestFilePath.empty())
{
- log<level::ERR>("Error TocFilePath is empty");
- throw std::runtime_error("TocFilePath is empty");
+ log<level::ERR>("Error MANIFESTFilePath is empty");
+ throw std::runtime_error("MANIFESTFilePath is empty");
}
std::string version{};
@@ -36,7 +36,7 @@
// Too many GCC bugs (53984, 66145) to do this the right way...
try
{
- efile.open(tocFilePath);
+ efile.open(manifestFilePath);
while (getline(efile, line))
{
if (line.compare(0, versionKeySize, versionKey) == 0)
@@ -49,7 +49,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Error in reading Host pnor.toc file");
+ log<level::ERR>("Error in reading Host MANIFEST file");
}
return version;
diff --git a/version_host_software_manager.hpp b/version_host_software_manager.hpp
index e9b62d8..74db7be 100755
--- a/version_host_software_manager.hpp
+++ b/version_host_software_manager.hpp
@@ -45,7 +45,7 @@
*
* @return The version identifier.
**/
- static std::string getVersion(const std::string& tocFilePath);
+ static std::string getVersion(const std::string& manifestFilePath);
/**
* @brief Get the Host Version id.
diff --git a/version_host_software_manager_main.cpp b/version_host_software_manager_main.cpp
index 0b5d973..9db6b02 100644
--- a/version_host_software_manager_main.cpp
+++ b/version_host_software_manager_main.cpp
@@ -11,7 +11,7 @@
sdbusplus::server::manager::manager objManager(bus,
SOFTWARE_OBJPATH);
- auto version = openpower::software::manager::Version::getVersion(TOC_FILE);
+ auto version = openpower::software::manager::Version::getVersion(MANIFEST_FILE);
auto id = openpower::software::manager::Version::getId(version);
openpower::software::manager::Version manager(bus,