All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kmod: Add an exclude directive to depmod
@ 2022-03-30 22:11 Saul Wold
  2022-03-30 22:11 ` [PATCH 2/2] depmodwrapper: Use native staging dir Saul Wold
  2022-03-31  8:21 ` [OE-core] [PATCH 1/2] kmod: Add an exclude directive to depmod Jose Quaresma
  0 siblings, 2 replies; 5+ messages in thread
From: Saul Wold @ 2022-03-30 22:11 UTC (permalink / raw)
  To: openembedded-core; +Cc: Saul Wold

This adds a new configuration directive to depmod that causes
depmod to exclude a give path entry like .debug.

kernel-dbg provides the modules .debug/<module>.ko files and
when installed either directly or when dbg-pkgs are selected
this can cause depmod to fail.

This patch will be submitted to upstream kmod.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
 .../kmod/depmodwrapper-cross_1.0.bb           |   3 +
 ...dd-support-for-excluding-a-directory.patch | 158 ++++++++++++++++++
 meta/recipes-kernel/kmod/kmod_29.bb           |   4 +
 3 files changed, 165 insertions(+)
 create mode 100644 meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch

diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index 04fc14a6d21..aa23ba41276 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -16,6 +16,9 @@ do_populate_sysroot[depends] = ""
 
 do_install() {
 	install -d ${D}${bindir_crossscripts}/
+	install -d ${D}${sysconfdir}/depmod.d/
+
+	echo "exclude .debug" > ${D}${sysconfdir}/depmod.d/exclude.conf
 
 	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
 #!/bin/sh
diff --git a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
new file mode 100644
index 00000000000..3f16cdf0574
--- /dev/null
+++ b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
@@ -0,0 +1,158 @@
+From 8bc07c3ba3a412bd6bb94ad8bad0d76801ec2c9f Mon Sep 17 00:00:00 2001
+From: Saul Wold <saul.wold@windriver.com>
+Date: Tue, 22 Mar 2022 12:11:45 -0700
+Subject: [PATCH] depmod: Add support for excluding a directory
+
+This adds support to depmod to enable a new exclude directive in
+the depmod.d/exclude.conf configuration file. Currently depmod
+already excludes directories named source or build. This change
+will allow additional directories like .debug to be excluded also
+via a new exclude directive.
+
+depmod.d/exclude.conf example:
+exclude	.debug
+
+Upstream-Status: Submitted
+
+Signed-off-by: Saul Wold <saul.wold@windriver.com>
+
+%% original patch: 0001-depmod-Add-support-for-excluding-a-directory.patch
+---
+ man/depmod.d.xml | 14 +++++++++++++
+ tools/depmod.c   | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 68 insertions(+)
+
+diff --git a/man/depmod.d.xml b/man/depmod.d.xml
+index b315e93..9ab790a 100644
+--- a/man/depmod.d.xml
++++ b/man/depmod.d.xml
+@@ -131,6 +131,20 @@
+           </para>
+         </listitem>
+       </varlistentry>
++      <varlistentry>
++        <term>external <replaceable>excludedir</replaceable>
++        </term>
++        <listitem>
++          <para>
++            This specifies the trailing directories that will be excluded
++            during the search for kernel modules.
++          </para>
++          <para>
++	    The <replaceable>excludedir</replaceable> the trailing directory
++	    to exclude
++          </para>
++        </listitem>
++      </varlistentry>
+     </variablelist>
+   </refsect1>
+ 
+diff --git a/tools/depmod.c b/tools/depmod.c
+index eb810b8..8b19ab6 100644
+--- a/tools/depmod.c
++++ b/tools/depmod.c
+@@ -458,6 +458,12 @@ struct cfg_external {
+ 	char path[];
+ };
+ 
++struct cfg_exclude {
++	struct cfg_exclude *next;
++	size_t len;
++	char exclude_dir[];
++};
++
+ struct cfg {
+ 	const char *kversion;
+ 	char dirname[PATH_MAX];
+@@ -469,6 +475,7 @@ struct cfg {
+ 	struct cfg_override *overrides;
+ 	struct cfg_search *searches;
+ 	struct cfg_external *externals;
++	struct cfg_exclude *excludes;
+ };
+ 
+ static enum search_type cfg_define_search_type(const char *path)
+@@ -580,6 +587,31 @@ static void cfg_external_free(struct cfg_external *ext)
+ 	free(ext);
+ }
+ 
++static int cfg_exclude_add(struct cfg *cfg, const char *path)
++{
++	struct cfg_exclude *exc;
++	size_t len = strlen(path);
++
++	exc = malloc(sizeof(struct cfg_exclude) + len);
++	if (exc == NULL) {
++		ERR("exclude add: out of memory\n");
++		return -ENOMEM;
++	}
++	exc->len = len;
++	memcpy(exc->exclude_dir, path, len);
++
++	DBG("exclude add: %s\n", path);
++
++	exc->next = cfg->excludes;
++	cfg->excludes = exc;
++	return 0;
++}
++
++static void cfg_exclude_free(struct cfg_exclude *exc)
++{
++	free(exc);
++}
++
+ static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern)
+ {
+ 	regex_t re;
+@@ -657,6 +689,11 @@ static int cfg_file_parse(struct cfg *cfg, const char *filename)
+ 			}
+ 
+ 			cfg_external_add(cfg, dir);
++		} else if (streq(cmd, "exclude")) {
++			const char *sp;
++			while ((sp = strtok_r(NULL, "\t ", &saveptr)) != NULL) {
++				cfg_exclude_add(cfg, sp);
++			}
+ 		} else if (streq(cmd, "include")
+ 				|| streq(cmd, "make_map_files")) {
+ 			INF("%s:%u: command %s not implemented yet\n",
+@@ -857,6 +894,12 @@ static void cfg_free(struct cfg *cfg)
+ 		cfg->externals = cfg->externals->next;
+ 		cfg_external_free(tmp);
+ 	}
++
++	while (cfg->excludes) {
++		struct cfg_exclude *tmp = cfg->excludes;
++		cfg->excludes = cfg->excludes->next;
++		cfg_exclude_free(tmp);
++	}
+ }
+ 
+ 
+@@ -1239,12 +1282,23 @@ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t basel
+ 		const char *name = de->d_name;
+ 		size_t namelen;
+ 		uint8_t is_dir;
++	        struct cfg_exclude *exc;
++		int exclude = 0;
+ 
+ 		if (name[0] == '.' && (name[1] == '\0' ||
+ 				       (name[1] == '.' && name[2] == '\0')))
+ 			continue;
+ 		if (streq(name, "build") || streq(name, "source"))
+ 			continue;
++
++	        for (exc = depmod->cfg->excludes; exc != NULL; exc = exc->next) {
++			if (streq(name, exc->exclude_dir)) {
++				exclude = 1;
++			}
++		}
++		if (exclude)
++			continue;
++
+ 		namelen = strlen(name);
+ 		if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) {
+ 			err = -ENOMEM;
+-- 
+2.31.1
+
diff --git a/meta/recipes-kernel/kmod/kmod_29.bb b/meta/recipes-kernel/kmod/kmod_29.bb
index 91951edde16..9b663490666 100644
--- a/meta/recipes-kernel/kmod/kmod_29.bb
+++ b/meta/recipes-kernel/kmod/kmod_29.bb
@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1"
 SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \
            file://depmod-search.conf \
            file://avoid_parallel_tests.patch \
+           file://0001-depmod-Add-support-for-excluding-a-directory.patch \
            "
 
 S = "${WORKDIR}/git"
@@ -64,6 +65,9 @@ do_install:append () {
 
         # install depmod.d file for search/ dir
         install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf"
+
+        # Add .debug to the exclude path for depmod
+        echo "exclude .debug" > ${D}${nonarch_base_libdir}/depmod.d/exclude.conf
 }
 
 ALTERNATIVE_PRIORITY = "70"
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] depmodwrapper: Use native staging dir
  2022-03-30 22:11 [PATCH 1/2] kmod: Add an exclude directive to depmod Saul Wold
@ 2022-03-30 22:11 ` Saul Wold
  2022-03-30 22:17   ` [OE-core] " Richard Purdie
  2022-03-31  8:21 ` [OE-core] [PATCH 1/2] kmod: Add an exclude directive to depmod Jose Quaresma
  1 sibling, 1 reply; 5+ messages in thread
From: Saul Wold @ 2022-03-30 22:11 UTC (permalink / raw)
  To: openembedded-core; +Cc: Saul Wold

Use the native staging dir so that we can get the correct depmod.d configuration
files. When depmod runs we want to ensure that the newly supported exclude.conf
is read so that .debug/<module>.ko files are excluded.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index aa23ba41276..9921b7e8ad7 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -35,9 +35,9 @@ fi
 
 if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
     echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
-    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
+    exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" "\$4"
 else
-    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
+    exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
 fi
 EOF
 	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH 2/2] depmodwrapper: Use native staging dir
  2022-03-30 22:11 ` [PATCH 2/2] depmodwrapper: Use native staging dir Saul Wold
@ 2022-03-30 22:17   ` Richard Purdie
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2022-03-30 22:17 UTC (permalink / raw)
  To: Saul Wold, openembedded-core

On Wed, 2022-03-30 at 15:11 -0700, Saul Wold wrote:
> Use the native staging dir so that we can get the correct depmod.d configuration
> files. When depmod runs we want to ensure that the newly supported exclude.conf
> is read so that .debug/<module>.ko files are excluded.
> 
> Signed-off-by: Saul Wold <saul.wold@windriver.com>
> ---
>  meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index aa23ba41276..9921b7e8ad7 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -35,9 +35,9 @@ fi
>  
>  if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" "\$4"
> +    exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" "\$4"
>  else
> -    exec env depmod -C "\$3${sysconfdir}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
> +    exec env depmod -C "\${STAGING_BASE_LIBDIR_NATIVE}/depmod.d" "\$1" "\$2" "\$3" -F "${PKGDATA_DIR}/kernel-depmod/System.map-\$4" "\$4"
>  fi
>  EOF
>  	chmod +x ${D}${bindir_crossscripts}/depmodwrapper

This doesn't look/feel right to me. Shouldn't we be putting this configuration
into the target depmod.d directories and using it from there? What happens if
the depmod configuration is machine/target specific?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH 1/2] kmod: Add an exclude directive to depmod
  2022-03-30 22:11 [PATCH 1/2] kmod: Add an exclude directive to depmod Saul Wold
  2022-03-30 22:11 ` [PATCH 2/2] depmodwrapper: Use native staging dir Saul Wold
@ 2022-03-31  8:21 ` Jose Quaresma
  1 sibling, 0 replies; 5+ messages in thread
From: Jose Quaresma @ 2022-03-31  8:21 UTC (permalink / raw)
  To: Saul Wold; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 9033 bytes --]

Hi Saul,

Saul Wold <Saul.Wold@windriver.com> escreveu no dia quarta, 30/03/2022 à(s)
23:12:

> This adds a new configuration directive to depmod that causes
> depmod to exclude a give path entry like .debug.
>
> kernel-dbg provides the modules .debug/<module>.ko files and
> when installed either directly or when dbg-pkgs are selected
> this can cause depmod to fail.
>
> This patch will be submitted to upstream kmod.
>
> Signed-off-by: Saul Wold <saul.wold@windriver.com>
> ---
>  .../kmod/depmodwrapper-cross_1.0.bb           |   3 +
>  ...dd-support-for-excluding-a-directory.patch | 158 ++++++++++++++++++
>  meta/recipes-kernel/kmod/kmod_29.bb           |   4 +
>  3 files changed, 165 insertions(+)
>  create mode 100644
> meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
>
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index 04fc14a6d21..aa23ba41276 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -16,6 +16,9 @@ do_populate_sysroot[depends] = ""
>
>  do_install() {
>         install -d ${D}${bindir_crossscripts}/
> +       install -d ${D}${sysconfdir}/depmod.d/
> +
> +       echo "exclude .debug" > ${D}${sysconfdir}/depmod.d/exclude.conf
>
>         cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
>  #!/bin/sh
> diff --git
> a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
> b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
> new file mode 100644
> index 00000000000..3f16cdf0574
> --- /dev/null
> +++
> b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
> @@ -0,0 +1,158 @@
> +From 8bc07c3ba3a412bd6bb94ad8bad0d76801ec2c9f Mon Sep 17 00:00:00 2001
> +From: Saul Wold <saul.wold@windriver.com>
> +Date: Tue, 22 Mar 2022 12:11:45 -0700
> +Subject: [PATCH] depmod: Add support for excluding a directory
> +
> +This adds support to depmod to enable a new exclude directive in
> +the depmod.d/exclude.conf configuration file. Currently depmod
> +already excludes directories named source or build. This change
> +will allow additional directories like .debug to be excluded also
> +via a new exclude directive.
> +
> +depmod.d/exclude.conf example:
> +exclude        .debug
> +
> +Upstream-Status: Submitted
> +
> +Signed-off-by: Saul Wold <saul.wold@windriver.com>
> +
> +%% original patch: 0001-depmod-Add-support-for-excluding-a-directory.patch
>

This line comes from devtool but is not needed.

Jose


> +---
> + man/depmod.d.xml | 14 +++++++++++++
> + tools/depmod.c   | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
> + 2 files changed, 68 insertions(+)
> +
> +diff --git a/man/depmod.d.xml b/man/depmod.d.xml
> +index b315e93..9ab790a 100644
> +--- a/man/depmod.d.xml
> ++++ b/man/depmod.d.xml
> +@@ -131,6 +131,20 @@
> +           </para>
> +         </listitem>
> +       </varlistentry>
> ++      <varlistentry>
> ++        <term>external <replaceable>excludedir</replaceable>
> ++        </term>
> ++        <listitem>
> ++          <para>
> ++            This specifies the trailing directories that will be excluded
> ++            during the search for kernel modules.
> ++          </para>
> ++          <para>
> ++          The <replaceable>excludedir</replaceable> the trailing
> directory
> ++          to exclude
> ++          </para>
> ++        </listitem>
> ++      </varlistentry>
> +     </variablelist>
> +   </refsect1>
> +
> +diff --git a/tools/depmod.c b/tools/depmod.c
> +index eb810b8..8b19ab6 100644
> +--- a/tools/depmod.c
> ++++ b/tools/depmod.c
> +@@ -458,6 +458,12 @@ struct cfg_external {
> +       char path[];
> + };
> +
> ++struct cfg_exclude {
> ++      struct cfg_exclude *next;
> ++      size_t len;
> ++      char exclude_dir[];
> ++};
> ++
> + struct cfg {
> +       const char *kversion;
> +       char dirname[PATH_MAX];
> +@@ -469,6 +475,7 @@ struct cfg {
> +       struct cfg_override *overrides;
> +       struct cfg_search *searches;
> +       struct cfg_external *externals;
> ++      struct cfg_exclude *excludes;
> + };
> +
> + static enum search_type cfg_define_search_type(const char *path)
> +@@ -580,6 +587,31 @@ static void cfg_external_free(struct cfg_external
> *ext)
> +       free(ext);
> + }
> +
> ++static int cfg_exclude_add(struct cfg *cfg, const char *path)
> ++{
> ++      struct cfg_exclude *exc;
> ++      size_t len = strlen(path);
> ++
> ++      exc = malloc(sizeof(struct cfg_exclude) + len);
> ++      if (exc == NULL) {
> ++              ERR("exclude add: out of memory\n");
> ++              return -ENOMEM;
> ++      }
> ++      exc->len = len;
> ++      memcpy(exc->exclude_dir, path, len);
> ++
> ++      DBG("exclude add: %s\n", path);
> ++
> ++      exc->next = cfg->excludes;
> ++      cfg->excludes = exc;
> ++      return 0;
> ++}
> ++
> ++static void cfg_exclude_free(struct cfg_exclude *exc)
> ++{
> ++      free(exc);
> ++}
> ++
> + static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern)
> + {
> +       regex_t re;
> +@@ -657,6 +689,11 @@ static int cfg_file_parse(struct cfg *cfg, const
> char *filename)
> +                       }
> +
> +                       cfg_external_add(cfg, dir);
> ++              } else if (streq(cmd, "exclude")) {
> ++                      const char *sp;
> ++                      while ((sp = strtok_r(NULL, "\t ", &saveptr)) !=
> NULL) {
> ++                              cfg_exclude_add(cfg, sp);
> ++                      }
> +               } else if (streq(cmd, "include")
> +                               || streq(cmd, "make_map_files")) {
> +                       INF("%s:%u: command %s not implemented yet\n",
> +@@ -857,6 +894,12 @@ static void cfg_free(struct cfg *cfg)
> +               cfg->externals = cfg->externals->next;
> +               cfg_external_free(tmp);
> +       }
> ++
> ++      while (cfg->excludes) {
> ++              struct cfg_exclude *tmp = cfg->excludes;
> ++              cfg->excludes = cfg->excludes->next;
> ++              cfg_exclude_free(tmp);
> ++      }
> + }
> +
> +
> +@@ -1239,12 +1282,23 @@ static int depmod_modules_search_dir(struct
> depmod *depmod, DIR *d, size_t basel
> +               const char *name = de->d_name;
> +               size_t namelen;
> +               uint8_t is_dir;
> ++              struct cfg_exclude *exc;
> ++              int exclude = 0;
> +
> +               if (name[0] == '.' && (name[1] == '\0' ||
> +                                      (name[1] == '.' && name[2] ==
> '\0')))
> +                       continue;
> +               if (streq(name, "build") || streq(name, "source"))
> +                       continue;
> ++
> ++              for (exc = depmod->cfg->excludes; exc != NULL; exc =
> exc->next) {
> ++                      if (streq(name, exc->exclude_dir)) {
> ++                              exclude = 1;
> ++                      }
> ++              }
> ++              if (exclude)
> ++                      continue;
> ++
> +               namelen = strlen(name);
> +               if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) {
> +                       err = -ENOMEM;
> +--
> +2.31.1
> +
> diff --git a/meta/recipes-kernel/kmod/kmod_29.bb
> b/meta/recipes-kernel/kmod/kmod_29.bb
> index 91951edde16..9b663490666 100644
> --- a/meta/recipes-kernel/kmod/kmod_29.bb
> +++ b/meta/recipes-kernel/kmod/kmod_29.bb
> @@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1"
>  SRC_URI = "git://
> git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \
>             file://depmod-search.conf \
>             file://avoid_parallel_tests.patch \
> +           file://0001-depmod-Add-support-for-excluding-a-directory.patch
> \
>             "
>
>  S = "${WORKDIR}/git"
> @@ -64,6 +65,9 @@ do_install:append () {
>
>          # install depmod.d file for search/ dir
>          install -Dm644 "${WORKDIR}/depmod-search.conf"
> "${D}${nonarch_base_libdir}/depmod.d/search.conf"
> +
> +        # Add .debug to the exclude path for depmod
> +        echo "exclude .debug" >
> ${D}${nonarch_base_libdir}/depmod.d/exclude.conf
>  }
>
>  ALTERNATIVE_PRIORITY = "70"
> --
> 2.31.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#163795):
> https://lists.openembedded.org/g/openembedded-core/message/163795
> Mute This Topic: https://lists.openembedded.org/mt/90143170/5052612
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> quaresma.jose@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

-- 
Best regards,

José Quaresma

[-- Attachment #2: Type: text/html, Size: 12590 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] kmod: Add an exclude directive to depmod
@ 2022-03-25 19:00 Saul Wold
  0 siblings, 0 replies; 5+ messages in thread
From: Saul Wold @ 2022-03-25 19:00 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Saul Wold

This adds a new configuration directive to depmod that causes
depmod to exclude a give path entry like .debug.

kernel-dbg provides the modules .debug/<module>.ko files and
when installed either directly or when dbg-pkgs are selected
this can cause depmod to fail.

This patch will be submitted to upstream kmod.

Signed-off-by: Saul Wold <saul.wold@windriver.com>
---
 .../kmod/depmodwrapper-cross_1.0.bb           |   3 +
 ...dd-support-for-excluding-a-directory.patch | 158 ++++++++++++++++++
 meta/recipes-kernel/kmod/kmod_29.bb           |   4 +
 3 files changed, 165 insertions(+)
 create mode 100644 meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch

diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index 04fc14a6d21..aa23ba41276 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -16,6 +16,9 @@ do_populate_sysroot[depends] = ""
 
 do_install() {
 	install -d ${D}${bindir_crossscripts}/
+	install -d ${D}${sysconfdir}/depmod.d/
+
+	echo "exclude .debug" > ${D}${sysconfdir}/depmod.d/exclude.conf
 
 	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
 #!/bin/sh
diff --git a/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
new file mode 100644
index 00000000000..3f16cdf0574
--- /dev/null
+++ b/meta/recipes-kernel/kmod/kmod/0001-depmod-Add-support-for-excluding-a-directory.patch
@@ -0,0 +1,158 @@
+From 8bc07c3ba3a412bd6bb94ad8bad0d76801ec2c9f Mon Sep 17 00:00:00 2001
+From: Saul Wold <saul.wold@windriver.com>
+Date: Tue, 22 Mar 2022 12:11:45 -0700
+Subject: [PATCH] depmod: Add support for excluding a directory
+
+This adds support to depmod to enable a new exclude directive in
+the depmod.d/exclude.conf configuration file. Currently depmod
+already excludes directories named source or build. This change
+will allow additional directories like .debug to be excluded also
+via a new exclude directive.
+
+depmod.d/exclude.conf example:
+exclude	.debug
+
+Upstream-Status: Submitted
+
+Signed-off-by: Saul Wold <saul.wold@windriver.com>
+
+%% original patch: 0001-depmod-Add-support-for-excluding-a-directory.patch
+---
+ man/depmod.d.xml | 14 +++++++++++++
+ tools/depmod.c   | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 68 insertions(+)
+
+diff --git a/man/depmod.d.xml b/man/depmod.d.xml
+index b315e93..9ab790a 100644
+--- a/man/depmod.d.xml
++++ b/man/depmod.d.xml
+@@ -131,6 +131,20 @@
+           </para>
+         </listitem>
+       </varlistentry>
++      <varlistentry>
++        <term>external <replaceable>excludedir</replaceable>
++        </term>
++        <listitem>
++          <para>
++            This specifies the trailing directories that will be excluded
++            during the search for kernel modules.
++          </para>
++          <para>
++	    The <replaceable>excludedir</replaceable> the trailing directory
++	    to exclude
++          </para>
++        </listitem>
++      </varlistentry>
+     </variablelist>
+   </refsect1>
+ 
+diff --git a/tools/depmod.c b/tools/depmod.c
+index eb810b8..8b19ab6 100644
+--- a/tools/depmod.c
++++ b/tools/depmod.c
+@@ -458,6 +458,12 @@ struct cfg_external {
+ 	char path[];
+ };
+ 
++struct cfg_exclude {
++	struct cfg_exclude *next;
++	size_t len;
++	char exclude_dir[];
++};
++
+ struct cfg {
+ 	const char *kversion;
+ 	char dirname[PATH_MAX];
+@@ -469,6 +475,7 @@ struct cfg {
+ 	struct cfg_override *overrides;
+ 	struct cfg_search *searches;
+ 	struct cfg_external *externals;
++	struct cfg_exclude *excludes;
+ };
+ 
+ static enum search_type cfg_define_search_type(const char *path)
+@@ -580,6 +587,31 @@ static void cfg_external_free(struct cfg_external *ext)
+ 	free(ext);
+ }
+ 
++static int cfg_exclude_add(struct cfg *cfg, const char *path)
++{
++	struct cfg_exclude *exc;
++	size_t len = strlen(path);
++
++	exc = malloc(sizeof(struct cfg_exclude) + len);
++	if (exc == NULL) {
++		ERR("exclude add: out of memory\n");
++		return -ENOMEM;
++	}
++	exc->len = len;
++	memcpy(exc->exclude_dir, path, len);
++
++	DBG("exclude add: %s\n", path);
++
++	exc->next = cfg->excludes;
++	cfg->excludes = exc;
++	return 0;
++}
++
++static void cfg_exclude_free(struct cfg_exclude *exc)
++{
++	free(exc);
++}
++
+ static int cfg_kernel_matches(const struct cfg *cfg, const char *pattern)
+ {
+ 	regex_t re;
+@@ -657,6 +689,11 @@ static int cfg_file_parse(struct cfg *cfg, const char *filename)
+ 			}
+ 
+ 			cfg_external_add(cfg, dir);
++		} else if (streq(cmd, "exclude")) {
++			const char *sp;
++			while ((sp = strtok_r(NULL, "\t ", &saveptr)) != NULL) {
++				cfg_exclude_add(cfg, sp);
++			}
+ 		} else if (streq(cmd, "include")
+ 				|| streq(cmd, "make_map_files")) {
+ 			INF("%s:%u: command %s not implemented yet\n",
+@@ -857,6 +894,12 @@ static void cfg_free(struct cfg *cfg)
+ 		cfg->externals = cfg->externals->next;
+ 		cfg_external_free(tmp);
+ 	}
++
++	while (cfg->excludes) {
++		struct cfg_exclude *tmp = cfg->excludes;
++		cfg->excludes = cfg->excludes->next;
++		cfg_exclude_free(tmp);
++	}
+ }
+ 
+ 
+@@ -1239,12 +1282,23 @@ static int depmod_modules_search_dir(struct depmod *depmod, DIR *d, size_t basel
+ 		const char *name = de->d_name;
+ 		size_t namelen;
+ 		uint8_t is_dir;
++	        struct cfg_exclude *exc;
++		int exclude = 0;
+ 
+ 		if (name[0] == '.' && (name[1] == '\0' ||
+ 				       (name[1] == '.' && name[2] == '\0')))
+ 			continue;
+ 		if (streq(name, "build") || streq(name, "source"))
+ 			continue;
++
++	        for (exc = depmod->cfg->excludes; exc != NULL; exc = exc->next) {
++			if (streq(name, exc->exclude_dir)) {
++				exclude = 1;
++			}
++		}
++		if (exclude)
++			continue;
++
+ 		namelen = strlen(name);
+ 		if (scratchbuf_alloc(s_path, baselen + namelen + 2) < 0) {
+ 			err = -ENOMEM;
+-- 
+2.31.1
+
diff --git a/meta/recipes-kernel/kmod/kmod_29.bb b/meta/recipes-kernel/kmod/kmod_29.bb
index 91951edde16..9b663490666 100644
--- a/meta/recipes-kernel/kmod/kmod_29.bb
+++ b/meta/recipes-kernel/kmod/kmod_29.bb
@@ -20,6 +20,7 @@ SRCREV = "b6ecfc916a17eab8f93be5b09f4e4f845aabd3d1"
 SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git;branch=master \
            file://depmod-search.conf \
            file://avoid_parallel_tests.patch \
+           file://0001-depmod-Add-support-for-excluding-a-directory.patch \
            "
 
 S = "${WORKDIR}/git"
@@ -64,6 +65,9 @@ do_install:append () {
 
         # install depmod.d file for search/ dir
         install -Dm644 "${WORKDIR}/depmod-search.conf" "${D}${nonarch_base_libdir}/depmod.d/search.conf"
+
+        # Add .debug to the exclude path for depmod
+        echo "exclude .debug" > ${D}${nonarch_base_libdir}/depmod.d/exclude.conf
 }
 
 ALTERNATIVE_PRIORITY = "70"
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-31  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30 22:11 [PATCH 1/2] kmod: Add an exclude directive to depmod Saul Wold
2022-03-30 22:11 ` [PATCH 2/2] depmodwrapper: Use native staging dir Saul Wold
2022-03-30 22:17   ` [OE-core] " Richard Purdie
2022-03-31  8:21 ` [OE-core] [PATCH 1/2] kmod: Add an exclude directive to depmod Jose Quaresma
  -- strict thread matches above, loose matches on Subject: below --
2022-03-25 19:00 Saul Wold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.