]> code.ossystems Code Review - openembedded-core.git/commitdiff
cve-check: avoid FileNotFoundError if no do_cve_check task has run
authorChris Laplante <chris.laplante@agilent.com>
Wed, 9 Sep 2020 20:51:09 +0000 (16:51 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 9 Sep 2020 22:41:01 +0000 (23:41 +0100)
For example, if you just run 'bitbake cve-update-db-native' in a clean
build system, |cve_tmp_file| won't exist yet.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/cve-check.bbclass

index 35b7d0f29861b0bac8b4eeaae3db57d776d680b1..17f64a8a9c77dec82ee8b9637304520490a05829 100644 (file)
@@ -63,14 +63,15 @@ python cve_save_summary_handler () {
     timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
     cve_summary_file = os.path.join(cvelogpath, "%s-%s.txt" % (cve_summary_name, timestamp))
 
-    shutil.copyfile(cve_tmp_file, cve_summary_file)
+    if os.path.exists(cve_tmp_file):
+        shutil.copyfile(cve_tmp_file, cve_summary_file)
 
-    if cve_summary_file and os.path.exists(cve_summary_file):
-        cvefile_link = os.path.join(cvelogpath, cve_summary_name)
+        if cve_summary_file and os.path.exists(cve_summary_file):
+            cvefile_link = os.path.join(cvelogpath, cve_summary_name)
 
-        if os.path.exists(os.path.realpath(cvefile_link)):
-            os.remove(cvefile_link)
-        os.symlink(os.path.basename(cve_summary_file), cvefile_link)
+            if os.path.exists(os.path.realpath(cvefile_link)):
+                os.remove(cvefile_link)
+            os.symlink(os.path.basename(cve_summary_file), cvefile_link)
 }
 
 addhandler cve_save_summary_handler