summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMarta Rybczynska <rybczynska@gmail.com>2022-06-03 10:58:27 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-06-11 10:06:09 +0100
commit6cf824520a23f7d0f78b37a6cffb033f31c87a36 (patch)
tree3f61e21666ed76a258bf82c12450d596d414cb6a /meta
parent42bb9689a0a173fd0c526330b297957961cd1d5d (diff)
downloadpoky-6cf824520a23f7d0f78b37a6cffb033f31c87a36.tar.gz
cve-check: move update_symlinks to a library
Move the function to a library, it could be useful in other places. (From OE-Core rev: c8a0e7ecee15985f7eed10ce9c86c48a77c5b7c5) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit debd37abcdde8788761ebdb4a05bc61f7394cbb8) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/cve-check.bbclass11
-rw-r--r--meta/lib/oe/cve_check.py10
2 files changed, 13 insertions, 8 deletions
diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass
index 0111ec6ba8..2ab1720dc3 100644
--- a/meta/classes/cve-check.bbclass
+++ b/meta/classes/cve-check.bbclass
@@ -76,16 +76,10 @@ CVE_CHECK_LAYER_INCLUDELIST ??= ""
76# set to "alphabetical" for version using single alphabetical character as increment release 76# set to "alphabetical" for version using single alphabetical character as increment release
77CVE_VERSION_SUFFIX ??= "" 77CVE_VERSION_SUFFIX ??= ""
78 78
79def update_symlinks(target_path, link_path):
80 if link_path != target_path and os.path.exists(target_path):
81 if os.path.exists(os.path.realpath(link_path)):
82 os.remove(link_path)
83 os.symlink(os.path.basename(target_path), link_path)
84
85def generate_json_report(d, out_path, link_path): 79def generate_json_report(d, out_path, link_path):
86 if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): 80 if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")):
87 import json 81 import json
88 from oe.cve_check import cve_check_merge_jsons 82 from oe.cve_check import cve_check_merge_jsons, update_symlinks
89 83
90 bb.note("Generating JSON CVE summary") 84 bb.note("Generating JSON CVE summary")
91 index_file = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH") 85 index_file = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")
@@ -106,6 +100,7 @@ def generate_json_report(d, out_path, link_path):
106python cve_save_summary_handler () { 100python cve_save_summary_handler () {
107 import shutil 101 import shutil
108 import datetime 102 import datetime
103 from oe.cve_check import update_symlinks
109 104
110 cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE") 105 cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE")
111 106
@@ -174,7 +169,7 @@ python cve_check_write_rootfs_manifest () {
174 import shutil 169 import shutil
175 import json 170 import json
176 from oe.rootfs import image_list_installed_packages 171 from oe.rootfs import image_list_installed_packages
177 from oe.cve_check import cve_check_merge_jsons 172 from oe.cve_check import cve_check_merge_jsons, update_symlinks
178 173
179 if d.getVar("CVE_CHECK_COPY_FILES") == "1": 174 if d.getVar("CVE_CHECK_COPY_FILES") == "1":
180 deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE") 175 deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE")
diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
index 1d3c775bbe..b17390de90 100644
--- a/meta/lib/oe/cve_check.py
+++ b/meta/lib/oe/cve_check.py
@@ -79,3 +79,13 @@ def cve_check_merge_jsons(output, data):
79 return 79 return
80 80
81 output["package"].append(data["package"][0]) 81 output["package"].append(data["package"][0])
82
83def update_symlinks(target_path, link_path):
84 """
85 Update a symbolic link link_path to point to target_path.
86 Remove the link and recreate it if exist and is different.
87 """
88 if link_path != target_path and os.path.exists(target_path):
89 if os.path.exists(os.path.realpath(link_path)):
90 os.remove(link_path)
91 os.symlink(os.path.basename(target_path), link_path)