-
Notifications
You must be signed in to change notification settings - Fork 10
/
msl_verify.hpp
78 lines (67 loc) · 2.34 KB
/
msl_verify.hpp
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
#pragma once
#include <cstdint>
#include <string>
namespace openpower
{
namespace software
{
namespace image
{
/** @class MinimumShipLevel
* @brief Contains minimum ship level verification functions.
*/
class MinimumShipLevel
{
public:
MinimumShipLevel() = delete;
MinimumShipLevel(const MinimumShipLevel&) = delete;
MinimumShipLevel& operator=(const MinimumShipLevel&) = delete;
MinimumShipLevel(MinimumShipLevel&&) = default;
MinimumShipLevel& operator=(MinimumShipLevel&&) = default;
~MinimumShipLevel() = default;
/** @brief Constructs MinimumShipLevel.
* @param[in] minShipLevel - Minimum Ship Level string
*/
explicit MinimumShipLevel(const std::string& minShipLevel) :
minShipLevel(minShipLevel) {};
/** @brief Verify if the current PNOR version meets the min ship level
* @return true if the verification succeeded, false otherwise
*/
bool verify();
/** @brief Version components */
struct Version
{
uint8_t major;
uint8_t minor;
uint8_t rev;
};
/** @brief Get the functional PNOR version on the system
* @details If the PNOR version file is not found, don't log an error since
* all PNOR images may had been deleted. If there is an issue with
* the VERSION partition, it should be caught by the host fw code.
* @return The populated or empty version string
*/
std::string getFunctionalVersion();
/** @brief Parse the version components into a struct
* @details Version format follows a git tag convention: vX.Y[.Z]
* Reference:
* https://github.com/open-power/op-build/blob/master/openpower/package/VERSION.readme
* @param[in] versionStr - The version string to be parsed
* @param[out] version - The version struct to be populated
*/
void parse(const std::string& versionStr, Version& version);
/** @brief Compare the versions provided
* @param[in] a - The first version to compare
* @param[in] b - The second version to compare
* @return 1 if a > b
* 0 if a = b
* -1 if a < b
*/
int compare(const Version& a, const Version& b);
private:
/** Minimum Ship Level to compare against */
std::string minShipLevel;
};
} // namespace image
} // namespace software
} // namespace openpower