Skip to content
Snippets Groups Projects
Verified Commit 7564ccca authored by Davide Gardenal's avatar Davide Gardenal
Browse files

meta-oniro-staging: add upstream patches


These patches are needed to make cve-check work. This is a dummy commit,
the patches will be sent to oe-core

Signed-off-by: Davide Gardenal's avatarDavide Gardenal <davide.gardenal@huawei.com>
parent 04b293b6
No related branches found
No related tags found
1 merge request!4meta-oniro-staging: mirror cve-check
Pipeline #5627 canceled
From 00feddb14d45e0a738a709ecb61ae71b3f7be1d5 Mon Sep 17 00:00:00 2001
From: Davide Gardenal <davide.gardenal@huawei.com>
Date: Mon, 27 Jun 2022 15:37:43 +0200
Subject: [PATCH 1/3] lib/oe/cve_check: refactor update_symlinks with saver
version
Now update_symlinks has more checks to prevent unwanted exception.
It returns False if the link is not created/updated, True otherwise.
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
---
meta/lib/oe/cve_check.py | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
index aa06497727..688693520e 100644
--- a/meta/lib/oe/cve_check.py
+++ b/meta/lib/oe/cve_check.py
@@ -169,7 +169,17 @@ def update_symlinks(target_path, link_path):
Update a symbolic link link_path to point to target_path.
Remove the link and recreate it if exist and is different.
"""
- if link_path != target_path and os.path.exists(target_path):
- if os.path.exists(os.path.realpath(link_path)):
- os.remove(link_path)
- os.symlink(os.path.basename(target_path), link_path)
+ import os
+
+ if target_path == link_path or \
+ target_path is None or \
+ link_path is None or \
+ not os.path.exists(target_path):
+
+ return False
+
+ if os.path.lexists(link_path):
+ os.remove(link_path)
+
+ os.symlink(target_path, link_path)
+ return True
--
2.34.1
From 4b82cd9ecb14f0e5c4e17d2f719e19d419c97e70 Mon Sep 17 00:00:00 2001
From: Davide Gardenal <davide.gardenal@huawei.com>
Date: Mon, 27 Jun 2022 15:41:00 +0200
Subject: [PATCH 2/3] lib/oe/rootfs: create image_list_installed_packages_pn
function
image_list_installed_packages_pn has been taken from cve-check.bbclass
to make it available for other classes.
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
---
meta/lib/oe/rootfs.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 9e6b411fb6..54a356102f 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -393,6 +393,15 @@ def image_list_installed_packages(d, rootfs_dir=None):
cls = importlib.import_module('oe.package_manager.' + img_type)
return cls.PMPkgsList(d, rootfs_dir).list_pkgs()
+def image_list_installed_packages_pn(d):
+ recipies = set()
+ for pkg in list(image_list_installed_packages(d)):
+ pkg_info = os.path.join(d.getVar('PKGDATA_DIR'),
+ 'runtime-reverse', pkg)
+ pkg_data = oe.packagedata.read_pkgdatafile(pkg_info)
+ recipies.add(pkg_data["PN"])
+ return recipies
+
if __name__ == "__main__":
"""
We should be able to run this as a standalone script, from outside bitbake
--
2.34.1
From e89de5d10e374612187ffa4fbeddac2af3f99921 Mon Sep 17 00:00:00 2001
From: Davide Gardenal <davide.gardenal@huawei.com>
Date: Mon, 27 Jun 2022 15:43:14 +0200
Subject: [PATCH 3/3] lib/oe/utils: create get_current_recipe_layer function
get_current_recipe_layer returns the recipe layer given its
file path.
Signed-off-by: Davide Gardenal <davide.gardenal@huawei.com>
---
meta/lib/oe/utils.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 46fc76c261..4e17b1b40e 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -584,3 +584,11 @@ def directory_size(root, blocksize=4096):
total += sum(roundup(getsize(os.path.join(root, name))) for name in files)
total += roundup(getsize(root))
return total
+
+def get_current_recipe_layer(d):
+ """
+ Extract the recipe layer from it's path.
+ Returns the layer name.
+ """
+ fdir_name = d.getVar("FILE_DIRNAME")
+ return fdir_name.split("/")[-3]
--
2.34.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment