bios: Delete uploaded DBus object after update

When the BIOS code update is completed, delete the uploaded DBus object
so that only the "bios_active" object remains.
Otherwise it leaves the uploaded DBus object that does not reflect a
real thing.

Tested: Verify only bios_active remains and the uploaded BIOS object is
        deleted from DBus, and it is possible to upload and update the
        same BIOS tarball for multieple times.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I18e76238821f48a3b322594bb359fcb37f28f397
diff --git a/activation.cpp b/activation.cpp
index 5490cd9..75d99ff 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -5,6 +5,7 @@
 #include "msl_verify.hpp"
 #include "serialize.hpp"
 
+#include <boost/asio/io_context.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
@@ -16,6 +17,8 @@
 #include "image_verify.hpp"
 #endif
 
+extern boost::asio::io_context& getIOContext();
+
 namespace phosphor
 {
 namespace software
@@ -431,6 +434,11 @@
             log<level::INFO>("Bios upgrade completed successfully.");
             parent.biosVersion->version(
                 parent.versions.find(versionId)->second->version());
+
+            // Delete the uploaded activation
+            getIOService().post([&parent = parent, versionId = versionId]() {
+                parent.erase(versionId);
+            });
         }
         else if (newStateResult == "failed")
         {
diff --git a/item_updater_main.cpp b/item_updater_main.cpp
index 79c4fd8..7e41ad7 100644
--- a/item_updater_main.cpp
+++ b/item_updater_main.cpp
@@ -2,12 +2,20 @@
 
 #include "item_updater.hpp"
 
+#include <boost/asio/io_context.hpp>
+#include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/manager.hpp>
 
+boost::asio::io_context& getIOContext()
+{
+    static boost::asio::io_context io;
+    return io;
+}
+
 int main()
 {
-    auto bus = sdbusplus::bus::new_default();
+    sdbusplus::asio::connection bus(getIOContext());
 
     // Add sdbusplus ObjectManager.
     sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
@@ -16,10 +24,7 @@
 
     bus.request_name(BUSNAME_UPDATER);
 
-    while (true)
-    {
-        bus.process_discard();
-        bus.wait();
-    }
+    getIOContext().run();
+
     return 0;
 }
diff --git a/meson.build b/meson.build
index a6ebcc4..29939ed 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,17 @@
     license: 'Apache-2.0',
     version: '1.0')
 
+add_project_arguments(
+    '-DBOOST_SYSTEM_NO_DEPRECATED',
+    '-DBOOST_ERROR_CODE_HEADER_ONLY',
+    '-DBOOST_NO_RTTI',
+    '-DBOOST_NO_TYPEID',
+    '-DBOOST_ALL_NO_LIB',
+    '-DBOOST_ASIO_DISABLE_THREADS',
+    '-DBOOST_ASIO_NO_DEPRECATED',
+    language: 'cpp',
+)
+
 conf = configuration_data()
 
 # DBus information