Skip to contentSkip to conversation

pseudo: use PSEUDO_CONSIDER_PATHS for path filetering

PATCH In review Chen Qi 2 participants 4 messages Jan 29, 2021 – Jan 30, 2021

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH 1/3 pseudo: use PSEUDO_CONSIDER_PATHS for path filetering

Patch pseudo to only take into consideration paths we care about. Use PSEUDO_CONSIDER_PATHS to hold the paths. The behavior of this var is the opposite of PSEUDO_IGNORE_PATHS.

---
 ...DO_CONSIDER_PATHS-for-path-filtering.patch | 55 +++++++++++++++++++
 meta/recipes-devtools/pseudo/pseudo_git.bb    |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 meta/recipes-devtools/pseudo/files/0001-pseudo-use-PSEUDO_CONSIDER_PATHS-for-path-filtering.patch
meta/recipes-devtools/pseudo/files/0001-pseudo-use-PSEUDO_CONSIDER_PATHS-for-path-filtering.patch new file +55 -0
new file mode 100644
index 0000000000..e17a2f1459
@@ -0,0 +1,55 @@
+From 683c6e39e214b34b6ecc77684ebfdfef38a2b1e1 Mon Sep 17 00:00:00 2001
+From: Chen Qi <[email protected]>
+Date: Wed, 27 Jan 2021 18:31:26 -0800
+Subject: [PATCH] pseudo: use PSEUDO_CONSIDER_PATHS for path filtering
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ pseudo_client.c | 8 ++++----
+ pseudo_util.c   | 2 +-
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/pseudo_client.c b/pseudo_client.c
+index 6310b99..5ac0702 100644
+--- a/pseudo_client.c
++++ b/pseudo_client.c
+@@ -1543,19 +1543,19 @@ int pseudo_client_ignore_path_chroot(const char *path, int ignore_chroot) {
+ 	if (ignore_chroot && pseudo_chroot && strncmp(path, pseudo_chroot, pseudo_chroot_len) == 0)
+ 		return 0;
+ 
+-	env = pseudo_get_value("PSEUDO_IGNORE_PATHS");
++	env = pseudo_get_value("PSEUDO_CONSIDER_PATHS");
+ 	if (!env)
+ 		return 0;
+ 
+-	int ret = 0;
++	int ret = 1;
+ 	char *p = env;
+ 	while (p) {
+ 		char *next = strchr(p, ',');
+ 		if (next)
+ 			*next++ = '\0';
+ 		if (*p && !strncmp(path, p, strlen(p))) {
+-			pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
+-			ret = 1;
++			pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "considering path: '%s'\n", path);
++			ret = 0;
+ 			break;
+ 		}
+ 		p = next;
+diff --git a/pseudo_util.c b/pseudo_util.c
+index b6980c2..065d975 100644
+--- a/pseudo_util.c
++++ b/pseudo_util.c
+@@ -43,7 +43,7 @@ static struct pseudo_variables pseudo_env[] = {
+ 	{ "PSEUDO_BINDIR", 13, NULL },
+ 	{ "PSEUDO_LIBDIR", 13, NULL },
+ 	{ "PSEUDO_LOCALSTATEDIR", 20, NULL },
+-	{ "PSEUDO_IGNORE_PATHS", 19, NULL },
++	{ "PSEUDO_CONSIDER_PATHS", 21, NULL },
+ 	{ "PSEUDO_PASSWD", 13, NULL },
+ 	{ "PSEUDO_CHROOT", 13, NULL },
+ 	{ "PSEUDO_UIDS", 11, NULL },
+-- 
+2.29.2
+
meta/recipes-devtools/pseudo/pseudo_git.bb +1 -0
index 29fa9152e2..ca9dc96c99 100644
@@ -2,6 +2,7 @@ require pseudo.inc
 
 SRC_URI = "git://git.yoctoproject.org/pseudo;branch=oe-core \
            file://0001-configure-Prune-PIE-flags.patch \
+           file://0001-pseudo-use-PSEUDO_CONSIDER_PATHS-for-path-filtering.patch \
            file://fallback-passwd \
            file://fallback-group \
            "
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 bitbake.conf: use PSEUDO_CONSIDER_PATHS

Instead of ignoring paths for pseudo path filtering, we use the opposite logic to only take into consideration a few paths we care about.

---
 meta/conf/bitbake.conf | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/conf/bitbake.conf +4 -4
index fd31c3f18d..cae319287c 100644
@@ -687,15 +687,15 @@ SRC_URI = ""
 PSEUDO_LOCALSTATEDIR ?= "${WORKDIR}/pseudo/"
 PSEUDO_PASSWD ?= "${STAGING_DIR_TARGET}:${PSEUDO_SYSROOT}"
 PSEUDO_SYSROOT = "${COMPONENTS_DIR}/${BUILD_ARCH}/pseudo-native"
-PSEUDO_IGNORE_PATHS = "/usr/,/etc/,/lib,/dev/,/run/,${T},${RECIPE_SYSROOT},${SSTATE_DIR},${STAMPS_DIR},${WORKDIR}/pkgdata-sysroot,${TMPDIR}/sstate-control,${DEPLOY_DIR},${WORKDIR}/deploy-,${TMPDIR}/buildstats,${WORKDIR}/sstate-build-package_,${WORKDIR}/sstate-install-package_,${WORKDIR}/sstate-build-image_complete,${TMPDIR}/sysroots-components,${BUILDHISTORY_DIR},${TMPDIR}/pkgdata,${TOPDIR}/cache,${COREBASE}/scripts,${CCACHE_DIR}"
+PSEUDO_CONSIDER_PATHS = "${D},${PKGD},${PKGDEST},${IMAGE_ROOTFS},${SDK_OUTPUT}"
 
 export PSEUDO_DISABLED = "1"
 #export PSEUDO_PREFIX = "${STAGING_DIR_NATIVE}${prefix_native}"
 #export PSEUDO_BINDIR = "${STAGING_DIR_NATIVE}${bindir_native}"
 #export PSEUDO_LIBDIR = "${STAGING_DIR_NATIVE}$PSEUDOBINDIR/../lib/pseudo/lib
-FAKEROOTBASEENV = "PSEUDO_BINDIR=${PSEUDO_SYSROOT}${bindir_native} PSEUDO_LIBDIR=${PSEUDO_SYSROOT}${prefix_native}/lib/pseudo/lib PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_IGNORE_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_IGNORE_PATHS'))} PSEUDO_DISABLED=1 PYTHONDONTWRITEBYTECODE=1"
+FAKEROOTBASEENV = "PSEUDO_BINDIR=${PSEUDO_SYSROOT}${bindir_native} PSEUDO_LIBDIR=${PSEUDO_SYSROOT}${prefix_native}/lib/pseudo/lib PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_CONSIDER_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_CONSIDER_PATHS'))} PSEUDO_DISABLED=1 PYTHONDONTWRITEBYTECODE=1"
 FAKEROOTCMD = "${PSEUDO_SYSROOT}${bindir_native}/pseudo"
-FAKEROOTENV = "PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_LOCALSTATEDIR=${PSEUDO_LOCALSTATEDIR} PSEUDO_PASSWD=${PSEUDO_PASSWD} PSEUDO_NOSYMLINKEXP=1 PSEUDO_IGNORE_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_IGNORE_PATHS'))} PSEUDO_DISABLED=0"
+FAKEROOTENV = "PSEUDO_PREFIX=${PSEUDO_SYSROOT}${prefix_native} PSEUDO_LOCALSTATEDIR=${PSEUDO_LOCALSTATEDIR} PSEUDO_PASSWD=${PSEUDO_PASSWD} PSEUDO_NOSYMLINKEXP=1 PSEUDO_CONSIDER_PATHS=${@oe.path.canonicalize(d.getVar('PSEUDO_CONSIDER_PATHS'))} PSEUDO_DISABLED=0"
 FAKEROOTNOENV = "PSEUDO_UNLOAD=1"
 FAKEROOTDIRS = "${PSEUDO_LOCALSTATEDIR}"
 PREFERRED_PROVIDER_virtual/fakeroot-native ?= "pseudo-native"
@@ -886,7 +886,7 @@ BB_HASHEXCLUDE_COMMON ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DI
     BB_WORKERCONTEXT BB_LIMITEDDEPS BB_UNIHASH extend_recipe_sysroot DEPLOY_DIR \
     SSTATE_HASHEQUIV_METHOD SSTATE_HASHEQUIV_REPORT_TASKDATA \
     SSTATE_HASHEQUIV_OWNER CCACHE_TOP_DIR BB_HASHSERVE GIT_CEILING_DIRECTORIES"
-BB_HASHBASE_WHITELIST ?= "${BB_HASHEXCLUDE_COMMON} PSEUDO_IGNORE_PATHS BUILDHISTORY_DIR SSTATE_DIR "
+BB_HASHBASE_WHITELIST ?= "${BB_HASHEXCLUDE_COMMON} PSEUDO_CONSIDER_PATHS BUILDHISTORY_DIR SSTATE_DIR "
 BB_HASHCONFIG_WHITELIST ?= "${BB_HASHEXCLUDE_COMMON} DATE TIME SSH_AGENT_PID \
     SSH_AUTH_SOCK PSEUDO_BUILD BB_ENV_EXTRAWHITE DISABLE_SANITY_CHECKS \
     PARALLEL_MAKE BB_NUMBER_THREADS BB_ORIGENV BB_INVALIDCONF BBINCLUDED \
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 3/3 libc-package: add locale stash related dirs to PSEUDO_CONSIDER_PATHS

In reply to Chen Qi

The locale stash related directories need to be considered, otherwise, there will be QA warning for glibc-locale about host contamination.

---
 meta/classes/libc-package.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes/libc-package.bbclass +1 -0
index de3b4250c7..d947cb6a7c 100644
@@ -54,6 +54,7 @@ localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s %
 }
 
 LOCALETREESRC ?= "${PKGD}"
+PSEUDO_CONSIDER_PATHS .= ",${WORKDIR}/locale-tree,${WORKDIR}/stashed-locale,${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
 
 do_prep_locale_tree() {
 	treedir=${WORKDIR}/locale-tree
Signature · 1 line
2.17.1
#3 lore raw
In reply to Chen Qi
Quoted 10 lines · Chen Qi

Patch pseudo to only take into consideration paths we care about. Use PSEUDO_CONSIDER_PATHS to hold the paths. The behavior of this var is the opposite of PSEUDO_IGNORE_PATHS.

---
 ...DO_CONSIDER_PATHS-for-path-filtering.patch | 55 +++++++++++++++++++
 meta/recipes-devtools/pseudo/pseudo_git.bb | 1 +

 2 files changed, 56 insertions(+)

 create mode 100644 meta/recipes-devtools/pseudo/files/0001-pseudo-use-PSEUDO_CONSIDER_PATHS-for-path-filtering.patch

This is interesting but these patches would need more work before we could consider this.

a) It no longer supports PSEUDO_IGNORE_PATHS and we have code widely using that. We'd probably need to support both options.

b) There are a load of references to PSEUDO_IGNORE_PATHS in OE-Core which this series doesn't touch in the following files:

meta/lib/oeqa/selftest/cases/runtime_test.py
meta/classes/sanity.bbclass
meta/classes/sanity.bbclass
meta/classes/sanity.bbclass
meta/classes/base.bbclass
meta/classes/image_types_wic.bbclass
meta/classes/populate_sdk_base.bbclass
meta/classes/license.bbclass
scripts/lib/wic/partition.py

We'd need to do something with those. Was wic tested? Were oe-selftests run?

c) Has the output been compared before and after this change to ensure permissions/ownership is correctly being handled in all cases?

d) The pseudo authors explicitly asked we implement exclusions, not an inclusion list like this. I'd want to understand more about why they made such a strong recommendation. FWIW I'd originally hoped to do something like this patch but they dissuaded me.

e) The name PSEUDO_CONSIDER_PATHS doesn't sound right to me, if we did this I'd like to find a better one.

Cheers,

Richard