summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0006-Modify-the-ID-of-software-image-updater-object-on-DB.patch
blob: 1f2a86fb9983f64384132538c0b8fcfdd7980206 (plain)
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
From 9b3c44e9fb3d907c0152f14b967e23ab964c0e0b Mon Sep 17 00:00:00 2001
From: Jennifer Lee <jennifer1.lee@intel.com>
Date: Thu, 14 Feb 2019 14:54:45 -0800
Subject: [PATCH 6/6] Modify the ID of software image updater object on DBus to
 allow force update onto same version image

In the original design of image update, it does not allow the same version of image to be flashed onto itself.
But this blocks validation tests and in most of the cases we don't prevent user from doing such update.

This patch appends a random number after the version ID hash string to unblock such limitation.

Signed-off-by: Jennifer Lee <jennifer1.lee@intel.com>
Change-Id: I16aba4804ae1bc2e8784320f91c0419fb8b23c35
---
 image_manager.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/image_manager.cpp b/image_manager.cpp
index 5b2ff49..e3d26e3 100644
--- a/image_manager.cpp
+++ b/image_manager.cpp
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+#include <time.h>
 #include <unistd.h>
 
 #include <elog-errors.hpp>
@@ -174,6 +175,11 @@ int Manager::processImage(const std::string& tarFilePath)
     // Compute id
     auto id = Version::getId(version);
 
+    // Append a random number after the original version hash
+    // This will allow forcing image update onto the same version
+    srand(time(NULL));
+    id = id + "_" + std::to_string(rand());
+
     fs::path imageDirPath = std::string{IMG_UPLOAD_DIR};
     imageDirPath /= id;
 
-- 
2.17.1