summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorErnst Sjöstrand <ernstp@gmail.com>2022-05-24 13:50:20 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-06-04 12:16:59 +0100
commitb0cff6d434a2f590aa916704560a71fa3ea0dee0 (patch)
tree94fbe7d9ce9e17a08fe9da3d6d50b89f43f4420d /meta
parent08fb6eb2e09b76d7b3b3063148d9a0fed2fec28b (diff)
downloadpoky-b0cff6d434a2f590aa916704560a71fa3ea0dee0.tar.gz
cve-check: Add helper for symlink handling
(From OE-Core rev: 8a178a728f2318c55d5ecaef0ef9e0fd8ebc333b) Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 5046d54df2c3057be2afa4143a2833183fca0d67) 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.bbclass34
1 files changed, 13 insertions, 21 deletions
diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass
index f7ed2a6ae9..3cae0e8eb2 100644
--- a/meta/classes/cve-check.bbclass
+++ b/meta/classes/cve-check.bbclass
@@ -75,6 +75,12 @@ CVE_CHECK_LAYER_INCLUDELIST ??= ""
75# set to "alphabetical" for version using single alphabetical character as increment release 75# set to "alphabetical" for version using single alphabetical character as increment release
76CVE_VERSION_SUFFIX ??= "" 76CVE_VERSION_SUFFIX ??= ""
77 77
78def update_symlinks(target_path, link_path):
79 if link_path != target_path and os.path.exists(target_path):
80 if os.path.exists(os.path.realpath(link_path)):
81 os.remove(link_path)
82 os.symlink(os.path.basename(target_path), link_path)
83
78def generate_json_report(d, out_path, link_path): 84def generate_json_report(d, out_path, link_path):
79 if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): 85 if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")):
80 import json 86 import json
@@ -94,10 +100,7 @@ def generate_json_report(d, out_path, link_path):
94 with open(out_path, "w") as f: 100 with open(out_path, "w") as f:
95 json.dump(summary, f, indent=2) 101 json.dump(summary, f, indent=2)
96 102
97 if link_path != out_path: 103 update_symlinks(out_path, link_path)
98 if os.path.exists(os.path.realpath(link_path)):
99 os.remove(link_path)
100 os.symlink(os.path.basename(out_path), link_path)
101 104
102python cve_save_summary_handler () { 105python cve_save_summary_handler () {
103 import shutil 106 import shutil
@@ -114,14 +117,9 @@ python cve_save_summary_handler () {
114 117
115 if os.path.exists(cve_tmp_file): 118 if os.path.exists(cve_tmp_file):
116 shutil.copyfile(cve_tmp_file, cve_summary_file) 119 shutil.copyfile(cve_tmp_file, cve_summary_file)
117 120 cvefile_link = os.path.join(cvelogpath, cve_summary_name)
118 if cve_summary_file and os.path.exists(cve_summary_file): 121 update_symlinks(cve_summary_file, cvefile_link)
119 cvefile_link = os.path.join(cvelogpath, cve_summary_name) 122 bb.plain("Complete CVE report summary created at: %s" % cvefile_link)
120 # if the paths are the same don't create the link
121 if cvefile_link != cve_summary_file:
122 if os.path.exists(os.path.realpath(cvefile_link)):
123 os.remove(cvefile_link)
124 os.symlink(os.path.basename(cve_summary_file), cvefile_link)
125 123
126 if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": 124 if d.getVar("CVE_CHECK_FORMAT_JSON") == "1":
127 json_summary_link_name = os.path.join(cvelogpath, d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON")) 125 json_summary_link_name = os.path.join(cvelogpath, d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON"))
@@ -193,15 +191,9 @@ python cve_check_write_rootfs_manifest () {
193 bb.utils.mkdirhier(os.path.dirname(manifest_name)) 191 bb.utils.mkdirhier(os.path.dirname(manifest_name))
194 shutil.copyfile(cve_tmp_file, manifest_name) 192 shutil.copyfile(cve_tmp_file, manifest_name)
195 193
196 if manifest_name and os.path.exists(manifest_name): 194 manifest_link = os.path.join(deploy_dir, "%s.cve" % link_name)
197 manifest_link = os.path.join(deploy_dir, "%s.cve" % link_name) 195 update_symlinks(manifest_name, manifest_link)
198 # if they are the same don't create the link 196 bb.plain("Image CVE report stored in: %s" % manifest_name)
199 if manifest_link != manifest_name:
200 # If we already have another manifest, update symlinks
201 if os.path.exists(os.path.realpath(manifest_link)):
202 os.remove(manifest_link)
203 os.symlink(os.path.basename(manifest_name), manifest_link)
204 bb.plain("Image CVE report stored in: %s" % manifest_name)
205 197
206 if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": 198 if d.getVar("CVE_CHECK_FORMAT_JSON") == "1":
207 link_path = os.path.join(deploy_dir, "%s.json" % link_name) 199 link_path = os.path.join(deploy_dir, "%s.json" % link_name)