Skip to contentSkip to conversation

linux: run depmod only if modules directory exists

PATCH New Paul Cercueil 3 participants 5 messages Jun 23, 2020 – Aug 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux: run depmod only if modules directory exists

If the modules directory that corresponds to the version of the kernel being built has been deleted, don't try to run depmod, which will obviously fail.

This can happen for instance when the modules are stripped from the main root filesystem, and placed into a separate filesystem image, so that the root filesystem and the kernel can be updated separately.

---
 linux/linux.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux/linux.mk +2 -1
index b90b032bb9..d31933fea1 100644
@@ -490,7 +490,8 @@ endef
 # Run depmod in a target-finalize hook, to encompass modules installed by
 # packages.
 define LINUX_RUN_DEPMOD
-	if grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
+	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
+		&& grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
 		$(HOST_DIR)/sbin/depmod -a -b $(TARGET_DIR) $(LINUX_VERSION_PROBED); \
 	fi
 endef
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 linux: run depmod only if modules directory exists

Paul, All,

On 2020-06-23 13:38 +0200, Paul Cercueil spake thusly:

Quoted 7 lines

If the modules directory that corresponds to the version of the kernel being built has been deleted, don't try to run depmod, which will obviously fail.

This can happen for instance when the modules are stripped from the main root filesystem, and placed into a separate filesystem image, so that the root filesystem and the kernel can be updated separately.

I fail to see how this can happen, sine:

- LINUX_RUN_DEPMOD is run as a TARGET_FINALIZE_HOOKS

- TARGET_FINALIZE_HOOKS are run ultra-early in the target-finalize step, way before we run post-build scripts.

So, how can you end up with a /lib/modules/VERSIO/ directory missing?

(Note that I find your reason valid, I'm just curious to understand how this can happen before I apply the patch.)

Regards,
Yann E. MORIN.

Quoted 26 lines
---
 linux/linux.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux/linux.mk +2 -1
index b90b032bb9..d31933fea1 100644
@@ -490,7 +490,8 @@ endef
 # Run depmod in a target-finalize hook, to encompass modules installed by
 # packages.
 define LINUX_RUN_DEPMOD
-	if grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
+	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
+		&& grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
 		$(HOST_DIR)/sbin/depmod -a -b $(TARGET_DIR) $(LINUX_VERSION_PROBED); \
 	fi
 endef
Signature · 6 lines
2.27.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 linux: run depmod only if modules directory exists

Hi Yann,

Le mer. 24 juin 2020 ? 22:17, Yann E. MORIN <[email protected]> a ?crit :

Quoted 18 lines

Paul, All,

On 2020-06-23 13:38 +0200, Paul Cercueil spake thusly:

Quoted 10 lines

If the modules directory that corresponds to the version of the
kernel
being built has been deleted, don't try to run depmod, which will obviously fail.

This can happen for instance when the modules are stripped from the
main
root filesystem, and placed into a separate filesystem image, so
that
the root filesystem and the kernel can be updated separately.

I fail to see how this can happen, sine:

- LINUX_RUN_DEPMOD is run as a TARGET_FINALIZE_HOOKS

Quoted 8 lines

- TARGET_FINALIZE_HOOKS are run ultra-early in the target-finalize step, way before we run post-build scripts.

So, how can you end up with a /lib/modules/VERSIO/ directory missing?

(Note that I find your reason valid, I'm just curious to understand how
this can happen before I apply the patch.)

In the first run, the modules folder is erased after LINUX_RUN_DEPMOD is executed, yes. The problem is in successive runs, because then LINUX_RUN_DEPMOD is still executed but the modules folder is gone and is not re-installed unless the kernel package is rebuilt.

Cheers,
-Paul

Quoted 43 lines

Regards,
Yann E. MORIN.

Quoted 24 lines

---

  linux/linux.mk | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index b90b032bb9..d31933fea1 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -490,7 +490,8 @@ endef
# Run depmod in a target-finalize hook, to encompass modules
installed by

  # packages.
  define LINUX_RUN_DEPMOD
 -	if grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
 +	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
 +		&& grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
  		$(HOST_DIR)/sbin/depmod -a -b $(TARGET_DIR) 
$(LINUX_VERSION_PROBED); \
  	fi
  endef
 --
 2.27.0
Quoted 4 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' 
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___      
         |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  
There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   
conspiracy.  |

'------------------------------^-------^------------------^--------------------'

#3 lore raw

PATCH 1/1 linux: run depmod only if modules directory exists

In reply to Paul Cercueil

Paul, All,

On 2020-06-23 13:38 +0200, Paul Cercueil spake thusly:

Quoted 18 lines

If the modules directory that corresponds to the version of the kernel being built has been deleted, don't try to run depmod, which will obviously fail.

This can happen for instance when the modules are stripped from the main root filesystem, and placed into a separate filesystem image, so that the root filesystem and the kernel can be updated separately.

---
 linux/linux.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux/linux.mk +0 -0
index b90b032bb9..d31933fea1 100644

linux/linux.mk endef · line 493

Quoted 5 lines
linux/linux.mk +1 -1
@@ -490,7 +490,8 @@ endef
 # Run depmod in a target-finalize hook, to encompass modules installed by
 # packages.
 define LINUX_RUN_DEPMOD
-	if grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
+	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \

Removing stuff from target and then expecting everything continues to work as expected is a bit hackish, I believe. But another maintainer was OK with that patch, so applied to master now, thanks.

Regards,
Yann E. MORIN.

Quoted 11 lines
linux/linux.mk +1 -0
+		&& grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
 		$(HOST_DIR)/sbin/depmod -a -b $(TARGET_DIR) $(LINUX_VERSION_PROBED); \
 	fi
 endef
Signature · 6 lines
2.27.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 1/1 linux: run depmod only if modules directory exists

Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Paul, All,
On 2020-06-23 13:38 +0200, Paul Cercueil spake thusly:

Quoted 13 lines

If the modules directory that corresponds to the version of the kernel being built has been deleted, don't try to run depmod, which will obviously fail.

This can happen for instance when the modules are stripped from the main root filesystem, and placed into a separate filesystem image, so that the root filesystem and the kernel can be updated separately.

---
linux/linux.mk | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines

linux/linux.mk endef · line 493

Quoted 10 lines
linux/linux.mk +0 -0
index b90b032bb9..d31933fea1 100644
@@ -490,7 +490,8 @@ endef
 # Run depmod in a target-finalize hook, to encompass modules installed by
 # packages.

define LINUX_RUN_DEPMOD

linux/linux.mk +1 -1
-	if grep -q "CONFIG_MODULES=y" $(LINUX_DIR)/.config; then \
+	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \

Removing stuff from target and then expecting everything continues to work as expected is a bit hackish, I believe. But another maintainer was OK with that patch, so applied to master now, thanks.

Committed to 2020.02.x and 2020.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard