diff options
| -rw-r--r-- | meta/classes/cve-check.bbclass | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass index 3729d9cba8..0ab7ec7ae6 100644 --- a/meta/classes/cve-check.bbclass +++ b/meta/classes/cve-check.bbclass | |||
| @@ -79,6 +79,12 @@ CVE_CHECK_LAYER_INCLUDELIST ??= "" | |||
| 79 | # set to "alphabetical" for version using single alphabetical character as increment release | 79 | # set to "alphabetical" for version using single alphabetical character as increment release |
| 80 | CVE_VERSION_SUFFIX ??= "" | 80 | CVE_VERSION_SUFFIX ??= "" |
| 81 | 81 | ||
| 82 | def update_symlinks(target_path, link_path): | ||
| 83 | if link_path != target_path and os.path.exists(target_path): | ||
| 84 | if os.path.exists(os.path.realpath(link_path)): | ||
| 85 | os.remove(link_path) | ||
| 86 | os.symlink(os.path.basename(target_path), link_path) | ||
| 87 | |||
| 82 | def generate_json_report(d, out_path, link_path): | 88 | def generate_json_report(d, out_path, link_path): |
| 83 | if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): | 89 | if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): |
| 84 | import json | 90 | import json |
| @@ -98,10 +104,7 @@ def generate_json_report(d, out_path, link_path): | |||
| 98 | with open(out_path, "w") as f: | 104 | with open(out_path, "w") as f: |
| 99 | json.dump(summary, f, indent=2) | 105 | json.dump(summary, f, indent=2) |
| 100 | 106 | ||
| 101 | if link_path != out_path: | 107 | update_symlinks(out_path, link_path) |
| 102 | if os.path.exists(os.path.realpath(link_path)): | ||
| 103 | os.remove(link_path) | ||
| 104 | os.symlink(os.path.basename(out_path), link_path) | ||
| 105 | 108 | ||
| 106 | python cve_save_summary_handler () { | 109 | python cve_save_summary_handler () { |
| 107 | import shutil | 110 | import shutil |
| @@ -118,14 +121,9 @@ python cve_save_summary_handler () { | |||
| 118 | 121 | ||
| 119 | if os.path.exists(cve_tmp_file): | 122 | if os.path.exists(cve_tmp_file): |
| 120 | shutil.copyfile(cve_tmp_file, cve_summary_file) | 123 | shutil.copyfile(cve_tmp_file, cve_summary_file) |
| 121 | 124 | cvefile_link = os.path.join(cvelogpath, cve_summary_name) | |
| 122 | if cve_summary_file and os.path.exists(cve_summary_file): | 125 | update_symlinks(cve_summary_file, cvefile_link) |
| 123 | cvefile_link = os.path.join(cvelogpath, cve_summary_name) | 126 | bb.plain("Complete CVE report summary created at: %s" % cvefile_link) |
| 124 | # if the paths are the same don't create the link | ||
| 125 | if cvefile_link != cve_summary_file: | ||
| 126 | if os.path.exists(os.path.realpath(cvefile_link)): | ||
| 127 | os.remove(cvefile_link) | ||
| 128 | os.symlink(os.path.basename(cve_summary_file), cvefile_link) | ||
| 129 | 127 | ||
| 130 | if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": | 128 | if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": |
| 131 | json_summary_link_name = os.path.join(cvelogpath, d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON")) | 129 | json_summary_link_name = os.path.join(cvelogpath, d.getVar("CVE_CHECK_SUMMARY_FILE_NAME_JSON")) |
| @@ -198,15 +196,9 @@ python cve_check_write_rootfs_manifest () { | |||
| 198 | bb.utils.mkdirhier(os.path.dirname(manifest_name)) | 196 | bb.utils.mkdirhier(os.path.dirname(manifest_name)) |
| 199 | shutil.copyfile(cve_tmp_file, manifest_name) | 197 | shutil.copyfile(cve_tmp_file, manifest_name) |
| 200 | 198 | ||
| 201 | if manifest_name and os.path.exists(manifest_name): | 199 | manifest_link = os.path.join(deploy_dir, "%s.cve" % link_name) |
| 202 | manifest_link = os.path.join(deploy_dir, "%s.cve" % link_name) | 200 | update_symlinks(manifest_name, manifest_link) |
| 203 | # if they are the same don't create the link | 201 | bb.plain("Image CVE report stored in: %s" % manifest_name) |
| 204 | if manifest_link != manifest_name: | ||
| 205 | # If we already have another manifest, update symlinks | ||
| 206 | if os.path.exists(os.path.realpath(manifest_link)): | ||
| 207 | os.remove(manifest_link) | ||
| 208 | os.symlink(os.path.basename(manifest_name), manifest_link) | ||
| 209 | bb.plain("Image CVE report stored in: %s" % manifest_name) | ||
| 210 | 202 | ||
| 211 | if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": | 203 | if d.getVar("CVE_CHECK_FORMAT_JSON") == "1": |
| 212 | link_path = os.path.join(deploy_dir, "%s.json" % link_name) | 204 | link_path = os.path.join(deploy_dir, "%s.json" % link_name) |
