Skip to contentSkip to conversation

cve-update-db-native: clean DB if temporary file exist

PATCH New Lee Chee Yang 1 participant 1 message Mar 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cve-update-db-native: clean DB if temporary file exist

From: Lee Chee Yang <[email protected]>

when do_populate_cve_db forced stop at certain point, the DB execution are stoped however the temporary database file (DB-JOURNAL) are not removed. This db-journal file indicates that DB is incomplete and set DB in readonly mode. So when db-journal exist, remove both DB and the db-journal and build the DB again from scratch.

[YOCTO #13682]

---
 meta/recipes-core/meta/cve-update-db-native.bb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/recipes-core/meta/cve-update-db-native.bb +8 -1
index 575254a..a24ddc0 100644
@@ -13,8 +13,15 @@ deltask do_install
 deltask do_populate_sysroot
 
 python () {
-    if not d.getVar("CVE_CHECK_DB_FILE"):
+    cve_check_db_file = d.getVar("CVE_CHECK_DB_FILE")
+    if not cve_check_db_file:
         raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.")
+
+    if os.path.exists("%s-journal" % cve_check_db_file ):
+        os.remove("%s-journal" % cve_check_db_file)
+
+        if os.path.exists(cve_check_db_file):
+            os.remove(cve_check_db_file)
 }
 
 python do_populate_cve_db() {
Signature · 1 line
2.7.4