diff mbox series

[pseudo] pseudo_client: Add support for PSEUDO_INCLUDE_PATHS

Message ID 20250510155038.871646-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [pseudo] pseudo_client: Add support for PSEUDO_INCLUDE_PATHS | expand

Commit Message

Richard Purdie May 10, 2025, 3:50 p.m. UTC
We've often wondered if things would be better with a path include
list instead of an exclusion list. Add support for this so we can
test that theory

If set the include path takes precedence over the ignore path list.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 pseudo_client.c | 22 ++++++++++++++++++++++
 pseudo_util.c   |  1 +
 2 files changed, 23 insertions(+)

Comments

Peter Kjellerstedt May 13, 2025, 2:09 p.m. UTC | #1
> -----Original Message-----
> From: yocto-patches@lists.yoctoproject.org <yocto-patches@lists.yoctoproject.org> On Behalf Of Richard Purdie via lists.yoctoproject.org
> Sent: den 10 maj 2025 17:51
> To: yocto-patches@lists.yoctoproject.org
> Cc: seebs@seebs.net; mark.hatle@kernel.crashing.org
> Subject: [yocto-patches] [pseudo] [PATCH] pseudo_client: Add support for PSEUDO_INCLUDE_PATHS
> 
> We've often wondered if things would be better with a path include
> list instead of an exclusion list. Add support for this so we can
> test that theory
> 
> If set the include path takes precedence over the ignore path list.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  pseudo_client.c | 22 ++++++++++++++++++++++
>  pseudo_util.c   |  1 +
>  2 files changed, 23 insertions(+)
> 
> diff --git a/pseudo_client.c b/pseudo_client.c
> index 9fd68b5..8a07341 100644
> --- a/pseudo_client.c
> +++ b/pseudo_client.c
> @@ -1566,6 +1566,28 @@ 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_INCLUDE_PATHS");
> +	if (env) {
> +		char *p = env;
> +		if (*path == '\0') {
> +			free(env);
> +			return 0;
> +		}
> +		while (p) {
> +			char *next = strchr(p, ',');
> +			if (next)
> +				*next++ = '\0';
> +			if (*p && !strncmp(path, p, strlen(p))) {
> +				free(env);
> +				return 0;
> +			}
> +			p = next;
> +		}
> +		pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
> +		free(env);
> +		return 1;
> +        }

Wrong indentation (spaces instead of a tab) on the line above.

> +
>  	env = pseudo_get_value("PSEUDO_IGNORE_PATHS");
>  	if (!env)
>  		return 0;
> diff --git a/pseudo_util.c b/pseudo_util.c
> index aa989cb..a94a4da 100644
> --- a/pseudo_util.c
> +++ b/pseudo_util.c
> @@ -43,6 +43,7 @@ static struct pseudo_variables pseudo_env[] = {
>  	{ "PSEUDO_BINDIR", 13, NULL },
>  	{ "PSEUDO_LIBDIR", 13, NULL },
>  	{ "PSEUDO_LOCALSTATEDIR", 20, NULL },
> +	{ "PSEUDO_INCLUDE_PATHS", 20, NULL },
>  	{ "PSEUDO_IGNORE_PATHS", 19, NULL },
>  	{ "PSEUDO_PASSWD", 13, NULL },
>  	{ "PSEUDO_CHROOT", 13, NULL },

//Peter
diff mbox series

Patch

diff --git a/pseudo_client.c b/pseudo_client.c
index 9fd68b5..8a07341 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -1566,6 +1566,28 @@  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_INCLUDE_PATHS");
+	if (env) {
+		char *p = env;
+		if (*path == '\0') {
+			free(env);
+			return 0;
+		}
+		while (p) {
+			char *next = strchr(p, ',');
+			if (next)
+				*next++ = '\0';
+			if (*p && !strncmp(path, p, strlen(p))) {
+				free(env);
+				return 0;
+			}
+			p = next;
+		}
+		pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "ignoring path: '%s'\n", path);
+		free(env);
+		return 1;
+        }
+
 	env = pseudo_get_value("PSEUDO_IGNORE_PATHS");
 	if (!env)
 		return 0;
diff --git a/pseudo_util.c b/pseudo_util.c
index aa989cb..a94a4da 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -43,6 +43,7 @@  static struct pseudo_variables pseudo_env[] = {
 	{ "PSEUDO_BINDIR", 13, NULL },
 	{ "PSEUDO_LIBDIR", 13, NULL },
 	{ "PSEUDO_LOCALSTATEDIR", 20, NULL },
+	{ "PSEUDO_INCLUDE_PATHS", 20, NULL },
 	{ "PSEUDO_IGNORE_PATHS", 19, NULL },
 	{ "PSEUDO_PASSWD", 13, NULL },
 	{ "PSEUDO_CHROOT", 13, NULL },