Support ALWAYS_USE_BUILTIN_IMG_DIR in IA handler
Support the new ALWAYS_USE_BUILTIN_IMG_DIR meson option in the
InterfacesAdded handler for software versions.
This handler notifies the application when a new software version is
created on D-Bus. When a new PSU image is uploaded to the IMG_DIR
(/tmp/images) directory, the xyz.openbmc_project.Software.Version
service creates a new D-Bus object with the Version interface.
If the ALWAYS_USE_BUILTIN_IMG_DIR option is specified, the new PSU image
in IMG_DIR should be ignored. Only PSU images stored in IMG_DIR_BUILTIN
(/usr/share/obmc/psu) are used to update PSUs.
Tested:
* Built with ALWAYS_USE_BUILTIN_IMG_DIR set to false (the default)
* Verified that a new PSU image uploaded to /tmp/images is installed
on all PSUs.
* Verified new PSU image is copied to /var/lib/obmc/psu
* Verified new PSU image is removed from /tmp/images
* Verified that after BMC is rebooted new PSU image still exists in
/var/lib/obmc/psu
* Built with ALWAYS_USE_BUILTIN_IMG_DIR set to true
* Verified that a new PSU image uploaded to /tmp/images is ignored and
no PSUs are updated.
* Verified new PSU image is not copied to /var/lib/obmc/psu
* Verified new PSU image is not removed from /tmp/images
* Verified that after BMC is rebooted new PSU image no longer exists
in /tmp/images
Change-Id: I2f71593f786eac86bdf6f484cc0220e0e6b0f4b7
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index 8e664b8..8c92917 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -80,6 +80,13 @@
return;
}
+ // If we are only installing PSU images from the built-in directory, ignore
+ // PSU images from other directories
+ if (ALWAYS_USE_BUILTIN_IMG_DIR && !filePath.starts_with(IMG_DIR_BUILTIN))
+ {
+ return;
+ }
+
// Version id is the last item in the path
auto pos = path.rfind('/');
if (pos == std::string::npos)