diff mbox series

[1/1] linux: allow modules install path to be overriden

Message ID 20220721183503.369200-1-paul@crapouillou.net
State Rejected
Headers show
Series [1/1] linux: allow modules install path to be overriden | expand

Commit Message

Paul Cercueil July 21, 2022, 6:35 p.m. UTC
On my system the modules are not installed in the root filesystem
directly, but in a separate squashfs image that is then shipped
alongside the kernel.

Support this setup by allowing board files to override the install path
for the kernel modules.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 linux/linux.mk | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Arnout Vandecappelle July 23, 2022, 12:01 p.m. UTC | #1
On 21/07/2022 20:35, Paul Cercueil wrote:
> On my system the modules are not installed in the root filesystem
> directly, but in a separate squashfs image that is then shipped
> alongside the kernel.

  That use case is way too specific to add support for it...

> Support this setup by allowing board files to override the install path
> for the kernel modules.

  This works for in-tree modules, but it stops working if you have any 
out-of-tree modules.

  The proper way to do this would be to add a post-build script that moves 
TARGET_DIR/lib/modules to where you want it - or probably just run mksquashfs on 
it and remove it afterwards.


  Therefore, I've marked this patch as Rejected in patchwork.

  Regards,
  Arnout

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>   linux/linux.mk | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 322ccabbd9..36896a3b4d 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -145,6 +145,8 @@ LINUX_POST_EXTRACT_HOOKS += LINUX_XTENSA_OVERLAY_EXTRACT
>   LINUX_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
>   endif
>   
> +INSTALL_MOD_PATH = $(TARGET_DIR)
> +
>   # We don't want to run depmod after installing the kernel. It's done in a
>   # target-finalize hook, to encompass modules installed by packages.
>   # Disable building host tools with -Werror: newer gcc versions can be
> @@ -152,7 +154,7 @@ endif
>   LINUX_MAKE_FLAGS = \
>   	HOSTCC="$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS)" \
>   	ARCH=$(KERNEL_ARCH) \
> -	INSTALL_MOD_PATH=$(TARGET_DIR) \
> +	INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
>   	CROSS_COMPILE="$(TARGET_CROSS)" \
>   	WERROR=0 \
>   	DEPMOD=$(HOST_DIR)/sbin/depmod
> @@ -519,8 +521,8 @@ define LINUX_INSTALL_TARGET_CMDS
>   	# directories, not relevant on the target
>   	@if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
>   		$(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \
> -		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
> -		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
> +		rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
> +		rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
>   	fi
>   	$(LINUX_INSTALL_HOST_TOOLS)
>   endef
> @@ -528,9 +530,9 @@ endef
>   # Run depmod in a target-finalize hook, to encompass modules installed by
>   # packages.
>   define LINUX_RUN_DEPMOD
> -	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
> +	if test -d $(INSTALL_MOD_PATH)/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); \
> +		$(HOST_DIR)/sbin/depmod -a -b $(INSTALL_MOD_PATH) $(LINUX_VERSION_PROBED); \
>   	fi
>   endef
>   LINUX_TARGET_FINALIZE_HOOKS += LINUX_RUN_DEPMOD
Paul Cercueil July 23, 2022, 12:06 p.m. UTC | #2
Le sam., juil. 23 2022 at 14:01:12 +0200, Arnout Vandecappelle 
<arnout@mind.be> a écrit :
> 
> 
> On 21/07/2022 20:35, Paul Cercueil wrote:
>> On my system the modules are not installed in the root filesystem
>> directly, but in a separate squashfs image that is then shipped
>> alongside the kernel.
> 
>  That use case is way too specific to add support for it...
> 
>> Support this setup by allowing board files to override the install 
>> path
>> for the kernel modules.
> 
>  This works for in-tree modules, but it stops working if you have any 
> out-of-tree modules.

Fair enough.

>  The proper way to do this would be to add a post-build script that 
> moves TARGET_DIR/lib/modules to where you want it - or probably just 
> run mksquashfs on it and remove it afterwards.

But this would only work once and then it would be impossible to 
rebuild.

-Paul

>  Therefore, I've marked this patch as Rejected in patchwork.
> 
>  Regards,
>  Arnout
> 
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>>   linux/linux.mk | 12 +++++++-----
>>   1 file changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/linux/linux.mk b/linux/linux.mk
>> index 322ccabbd9..36896a3b4d 100644
>> --- a/linux/linux.mk
>> +++ b/linux/linux.mk
>> @@ -145,6 +145,8 @@ LINUX_POST_EXTRACT_HOOKS += 
>> LINUX_XTENSA_OVERLAY_EXTRACT
>>   LINUX_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
>>   endif
>>   +INSTALL_MOD_PATH = $(TARGET_DIR)
>> +
>>   # We don't want to run depmod after installing the kernel. It's 
>> done in a
>>   # target-finalize hook, to encompass modules installed by packages.
>>   # Disable building host tools with -Werror: newer gcc versions can 
>> be
>> @@ -152,7 +154,7 @@ endif
>>   LINUX_MAKE_FLAGS = \
>>   	HOSTCC="$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS)" \
>>   	ARCH=$(KERNEL_ARCH) \
>> -	INSTALL_MOD_PATH=$(TARGET_DIR) \
>> +	INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
>>   	CROSS_COMPILE="$(TARGET_CROSS)" \
>>   	WERROR=0 \
>>   	DEPMOD=$(HOST_DIR)/sbin/depmod
>> @@ -519,8 +521,8 @@ define LINUX_INSTALL_TARGET_CMDS
>>   	# directories, not relevant on the target
>>   	@if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
>>   		$(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) 
>> modules_install; \
>> -		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
>> -		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
>> +		rm -f 
>> $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
>> +		rm -f 
>> $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
>>   	fi
>>   	$(LINUX_INSTALL_HOST_TOOLS)
>>   endef
>> @@ -528,9 +530,9 @@ endef
>>   # Run depmod in a target-finalize hook, to encompass modules 
>> installed by
>>   # packages.
>>   define LINUX_RUN_DEPMOD
>> -	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
>> +	if test -d $(INSTALL_MOD_PATH)/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); \
>> +		$(HOST_DIR)/sbin/depmod -a -b $(INSTALL_MOD_PATH) 
>> $(LINUX_VERSION_PROBED); \
>>   	fi
>>   endef
>>   LINUX_TARGET_FINALIZE_HOOKS += LINUX_RUN_DEPMOD
Arnout Vandecappelle July 23, 2022, 12:35 p.m. UTC | #3
On 23/07/2022 14:06, Paul Cercueil wrote:
> 
> 
> Le sam., juil. 23 2022 at 14:01:12 +0200, Arnout Vandecappelle <arnout@mind.be> 
> a écrit :
>>
>>
>> On 21/07/2022 20:35, Paul Cercueil wrote:
>>> On my system the modules are not installed in the root filesystem
>>> directly, but in a separate squashfs image that is then shipped
>>> alongside the kernel.
>>
>>  That use case is way too specific to add support for it...
>>
>>> Support this setup by allowing board files to override the install path
>>> for the kernel modules.
>>
>>  This works for in-tree modules, but it stops working if you have any 
>> out-of-tree modules.
> 
> Fair enough.
> 
>>  The proper way to do this would be to add a post-build script that moves 
>> TARGET_DIR/lib/modules to where you want it - or probably just run mksquashfs 
>> on it and remove it afterwards.
> 
> But this would only work once and then it would be impossible to rebuild.

  If you want to support rebuild, you have to rsync to some other dir and keep 
that dir.

  Regards,
  Arnout

> 
> -Paul
> 
>>  Therefore, I've marked this patch as Rejected in patchwork.
>>
>>  Regards,
>>  Arnout
>>
>>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>> ---
>>>   linux/linux.mk | 12 +++++++-----
>>>   1 file changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/linux/linux.mk b/linux/linux.mk
>>> index 322ccabbd9..36896a3b4d 100644
>>> --- a/linux/linux.mk
>>> +++ b/linux/linux.mk
>>> @@ -145,6 +145,8 @@ LINUX_POST_EXTRACT_HOOKS += LINUX_XTENSA_OVERLAY_EXTRACT
>>>   LINUX_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
>>>   endif
>>>   +INSTALL_MOD_PATH = $(TARGET_DIR)
>>> +
>>>   # We don't want to run depmod after installing the kernel. It's done in a
>>>   # target-finalize hook, to encompass modules installed by packages.
>>>   # Disable building host tools with -Werror: newer gcc versions can be
>>> @@ -152,7 +154,7 @@ endif
>>>   LINUX_MAKE_FLAGS = \
>>>       HOSTCC="$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS)" \
>>>       ARCH=$(KERNEL_ARCH) \
>>> -    INSTALL_MOD_PATH=$(TARGET_DIR) \
>>> +    INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
>>>       CROSS_COMPILE="$(TARGET_CROSS)" \
>>>       WERROR=0 \
>>>       DEPMOD=$(HOST_DIR)/sbin/depmod
>>> @@ -519,8 +521,8 @@ define LINUX_INSTALL_TARGET_CMDS
>>>       # directories, not relevant on the target
>>>       @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
>>>           $(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) 
>>> modules_install; \
>>> -        rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
>>> -        rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
>>> +        rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
>>> +        rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/source 
>>> ; \
>>>       fi
>>>       $(LINUX_INSTALL_HOST_TOOLS)
>>>   endef
>>> @@ -528,9 +530,9 @@ endef
>>>   # Run depmod in a target-finalize hook, to encompass modules installed by
>>>   # packages.
>>>   define LINUX_RUN_DEPMOD
>>> -    if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
>>> +    if test -d $(INSTALL_MOD_PATH)/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); \
>>> +        $(HOST_DIR)/sbin/depmod -a -b $(INSTALL_MOD_PATH) 
>>> $(LINUX_VERSION_PROBED); \
>>>       fi
>>>   endef
>>>   LINUX_TARGET_FINALIZE_HOOKS += LINUX_RUN_DEPMOD
> 
>
Paul Cercueil July 23, 2022, 12:40 p.m. UTC | #4
Le sam., juil. 23 2022 at 14:35:22 +0200, Arnout Vandecappelle 
<arnout@mind.be> a écrit :
> 
> 
> On 23/07/2022 14:06, Paul Cercueil wrote:
>> 
>> 
>> Le sam., juil. 23 2022 at 14:01:12 +0200, Arnout Vandecappelle 
>> <arnout@mind.be> a écrit :
>>> 
>>> 
>>> On 21/07/2022 20:35, Paul Cercueil wrote:
>>>> On my system the modules are not installed in the root filesystem
>>>> directly, but in a separate squashfs image that is then shipped
>>>> alongside the kernel.
>>> 
>>>  That use case is way too specific to add support for it...
>>> 
>>>> Support this setup by allowing board files to override the install 
>>>> path
>>>> for the kernel modules.
>>> 
>>>  This works for in-tree modules, but it stops working if you have 
>>> any out-of-tree modules.
>> 
>> Fair enough.
>> 
>>>  The proper way to do this would be to add a post-build script that 
>>> moves TARGET_DIR/lib/modules to where you want it - or probably 
>>> just run mksquashfs on it and remove it afterwards.
>> 
>> But this would only work once and then it would be impossible to 
>> rebuild.
> 
>  If you want to support rebuild, you have to rsync to some other dir 
> and keep that dir.

If I keep that directory then it will end up in the rootfs as well...

-Paul
diff mbox series

Patch

diff --git a/linux/linux.mk b/linux/linux.mk
index 322ccabbd9..36896a3b4d 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -145,6 +145,8 @@  LINUX_POST_EXTRACT_HOOKS += LINUX_XTENSA_OVERLAY_EXTRACT
 LINUX_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 endif
 
+INSTALL_MOD_PATH = $(TARGET_DIR)
+
 # We don't want to run depmod after installing the kernel. It's done in a
 # target-finalize hook, to encompass modules installed by packages.
 # Disable building host tools with -Werror: newer gcc versions can be
@@ -152,7 +154,7 @@  endif
 LINUX_MAKE_FLAGS = \
 	HOSTCC="$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS)" \
 	ARCH=$(KERNEL_ARCH) \
-	INSTALL_MOD_PATH=$(TARGET_DIR) \
+	INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
 	WERROR=0 \
 	DEPMOD=$(HOST_DIR)/sbin/depmod
@@ -519,8 +521,8 @@  define LINUX_INSTALL_TARGET_CMDS
 	# directories, not relevant on the target
 	@if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
 		$(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \
-		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
-		rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
+		rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
+		rm -f $(INSTALL_MOD_PATH)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
 	fi
 	$(LINUX_INSTALL_HOST_TOOLS)
 endef
@@ -528,9 +530,9 @@  endef
 # Run depmod in a target-finalize hook, to encompass modules installed by
 # packages.
 define LINUX_RUN_DEPMOD
-	if test -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
+	if test -d $(INSTALL_MOD_PATH)/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); \
+		$(HOST_DIR)/sbin/depmod -a -b $(INSTALL_MOD_PATH) $(LINUX_VERSION_PROBED); \
 	fi
 endef
 LINUX_TARGET_FINALIZE_HOOKS += LINUX_RUN_DEPMOD