diff options
| author | Marta Rybczynska <rybczynska@gmail.com> | 2022-06-03 10:58:27 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-11 10:06:13 +0100 |
| commit | 7f22fb48eb910e5325d659e2513003c812289194 (patch) | |
| tree | 7e6116b22bdf50961b515353ea4705a30dee3fe7 | |
| parent | 2d031b7e2ab983fe3738f1f585df7058150cca99 (diff) | |
| download | poky-7f22fb48eb910e5325d659e2513003c812289194.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: 66bf08f2df478a909a12756c650dcc2ae09a0a47)
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>
| -rw-r--r-- | meta/classes/cve-check.bbclass | 11 | ||||
| -rw-r--r-- | meta/lib/oe/cve_check.py | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass index c80a365819..3844efcddb 100644 --- a/meta/classes/cve-check.bbclass +++ b/meta/classes/cve-check.bbclass | |||
| @@ -80,16 +80,10 @@ CVE_CHECK_LAYER_INCLUDELIST ??= "" | |||
| 80 | # set to "alphabetical" for version using single alphabetical character as increment release | 80 | # set to "alphabetical" for version using single alphabetical character as increment release |
| 81 | CVE_VERSION_SUFFIX ??= "" | 81 | CVE_VERSION_SUFFIX ??= "" |
| 82 | 82 | ||
| 83 | def update_symlinks(target_path, link_path): | ||
| 84 | if link_path != target_path and os.path.exists(target_path): | ||
| 85 | if os.path.exists(os.path.realpath(link_path)): | ||
| 86 | os.remove(link_path) | ||
| 87 | os.symlink(os.path.basename(target_path), link_path) | ||
| 88 | |||
| 89 | def generate_json_report(d, out_path, link_path): | 83 | def generate_json_report(d, out_path, link_path): |
| 90 | if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): | 84 | if os.path.exists(d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH")): |
| 91 | import json | 85 | import json |
| 92 | from oe.cve_check import cve_check_merge_jsons | 86 | from oe.cve_check import cve_check_merge_jsons, update_symlinks |
| 93 | 87 | ||
| 94 | bb.note("Generating JSON CVE summary") | 88 | bb.note("Generating JSON CVE summary") |
| 95 | index_file = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH") | 89 | index_file = d.getVar("CVE_CHECK_SUMMARY_INDEX_PATH") |
| @@ -110,6 +104,7 @@ def generate_json_report(d, out_path, link_path): | |||
| 110 | python cve_save_summary_handler () { | 104 | python cve_save_summary_handler () { |
| 111 | import shutil | 105 | import shutil |
| 112 | import datetime | 106 | import datetime |
| 107 | from oe.cve_check import update_symlinks | ||
| 113 | 108 | ||
| 114 | cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE") | 109 | cve_tmp_file = d.getVar("CVE_CHECK_TMP_FILE") |
| 115 | 110 | ||
| @@ -179,7 +174,7 @@ python cve_check_write_rootfs_manifest () { | |||
| 179 | import shutil | 174 | import shutil |
| 180 | import json | 175 | import json |
| 181 | from oe.rootfs import image_list_installed_packages | 176 | from oe.rootfs import image_list_installed_packages |
| 182 | from oe.cve_check import cve_check_merge_jsons | 177 | from oe.cve_check import cve_check_merge_jsons, update_symlinks |
| 183 | 178 | ||
| 184 | if d.getVar("CVE_CHECK_COPY_FILES") == "1": | 179 | if d.getVar("CVE_CHECK_COPY_FILES") == "1": |
| 185 | deploy_file = d.getVar("CVE_CHECK_RECIPE_FILE") | 180 | 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 dc7d2e2826..aa06497727 100644 --- a/meta/lib/oe/cve_check.py +++ b/meta/lib/oe/cve_check.py | |||
| @@ -163,3 +163,13 @@ def cve_check_merge_jsons(output, data): | |||
| 163 | return | 163 | return |
| 164 | 164 | ||
| 165 | output["package"].append(data["package"][0]) | 165 | output["package"].append(data["package"][0]) |
| 166 | |||
| 167 | def update_symlinks(target_path, link_path): | ||
| 168 | """ | ||
| 169 | Update a symbolic link link_path to point to target_path. | ||
| 170 | Remove the link and recreate it if exist and is different. | ||
| 171 | """ | ||
| 172 | if link_path != target_path and os.path.exists(target_path): | ||
| 173 | if os.path.exists(os.path.realpath(link_path)): | ||
| 174 | os.remove(link_path) | ||
| 175 | os.symlink(os.path.basename(target_path), link_path) | ||
