1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
From ef7f6eb7107c2c7116ddc20de8d251d6a55db75f Mon Sep 17 00:00:00 2001
From: Nikita Kosenkov <NKosenkov@IBS.RU>
Date: Thu, 22 Sep 2022 11:46:44 +0300
Subject: [PATCH] Added reading BIOS version from file
---
item_updater.cpp | 9 ++++++++-
version.cpp | 11 +++++++++--
version.hpp | 10 ++++++++++
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/item_updater.cpp b/item_updater.cpp
index 96782f2..48fb698 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -849,7 +849,6 @@ void ItemUpdater::createBIOSObject()
createFunctionalAssociation(path);
auto versionId = path.substr(pos + 1);
- auto version = "null";
AssociationList assocs = {};
biosActivation = std::make_unique<Activation>(
bus, path, *this, versionId, server::Activation::Activations::Active,
@@ -857,6 +856,14 @@ void ItemUpdater::createBIOSObject()
auto dummyErase = [](std::string /*entryId*/) {
// Do nothing;
};
+
+ auto version = VersionClass::getVersion(
+ "/var/lib/phosphor-bmc-code-mgmt/bios-release");
+ if(version.empty())
+ {
+ version = "null";
+ }
+
biosVersion = std::make_unique<VersionClass>(
bus, path, version, VersionPurpose::Host, "", "",
std::vector<std::string>(),
diff --git a/version.cpp b/version.cpp
index 847148e..523a855 100644
--- a/version.cpp
+++ b/version.cpp
@@ -179,14 +179,14 @@ std::string Version::getBMCExtendedVersion(const std::string& releaseFilePath)
return extendedVersion;
}
-std::string Version::getBMCVersion(const std::string& releaseFilePath)
+std::string Version::getVersion(const std::string& versionFilePath)
{
std::string versionKey = "VERSION_ID=";
std::string versionValue{};
std::string version{};
std::ifstream efile;
std::string line;
- efile.open(releaseFilePath);
+ efile.open(versionFilePath);
while (getline(efile, line))
{
@@ -216,6 +216,13 @@ std::string Version::getBMCVersion(const std::string& releaseFilePath)
}
efile.close();
+ return version;
+}
+
+std::string Version::getBMCVersion(const std::string& releaseFilePath)
+{
+ auto version = getVersion(releaseFilePath);
+
if (version.empty())
{
error("BMC current version is empty");
diff --git a/version.hpp b/version.hpp
index 5c74f99..e8956fa 100644
--- a/version.hpp
+++ b/version.hpp
@@ -150,6 +150,16 @@ class Version : public VersionInherit
static std::string
getBMCExtendedVersion(const std::string& releaseFilePath);
+ /**
+ * @brief Get the active VERSION_ID string.
+ *
+ * @param[in] releaseFilePath - The path to the file which contains
+ * the release version string.
+ *
+ * @return The version string (e.g. v1.99.10-19).
+ */
+ static std::string getVersion(const std::string& versionFilePath);
+
/**
* @brief Get the active BMC version string.
*
--
2.35.1
|