phosphor-settings-manager: Avoid build fail at non-clean build
To perform removing interfaces feature from:
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/51394
phosphor-settings-manager build fail while rebuild without clean.
For example, add xxx.remove.yml contains a key:
/xyz/openbmc_project/control/host0/auto_reboot
Build will success at first build ,but rebuild will fail.
Error Message:
Traceback (most recent call last):
......
File "....../merge_settings.py", line 39, in dict_merge
target.pop(k)
KeyError: '/xyz/openbmc_project/control/host0/auto_reboot'
the key seems already be removed at first build so keyError occurs,
add key existence check before calling pop() to avoid this problem.
Signed-off-by: Allen.Wang <Allen_Wang@quantatw.com>
Change-Id: Id98c8b9d755ba6083b1df88159ad47a41286c4a1
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py
index 68c2437..62a8f4a 100755
--- a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py
@@ -35,7 +35,7 @@
if k in target and isinstance(target[k], dict):
dict_merge(target[k], v, remove)
else:
- if remove is True:
+ if remove is True and k in target:
target.pop(k)
else:
target[k] = copy.deepcopy(v)