diff mbox series

[3/4] package/openrc: adapt "modules" init script to busybox "modprobe"

Message ID 20200227123938.13412-4-unixmania@gmail.com
State Superseded, archived
Headers show
Series adapt openrc "modules" script to busybox modprobe | expand

Commit Message

Carlos Santos Feb. 27, 2020, 12:39 p.m. UTC
From: Carlos Santos <unixmania@gmail.com>

If kmod tools are not selected, check for the busybox features and adapt
the modules script accordingly, since the busybox modprobe does not have
a "--first-time" option, "--verbose" is just "-v" and "--use-blacklist"
is just "-b". Also the blacklist support is not selected in the default
busybox configuration.

If modprobe is not available, do not install the modules script and
configuration file.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 package/openrc/openrc.mk | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

Comments

Thomas Petazzoni Feb. 27, 2020, 5:27 p.m. UTC | #1
On Thu, 27 Feb 2020 09:39:37 -0300
unixmania@gmail.com wrote:

> +# modprobe can be provided by either kmod or busybox
> +ifeq ($(BR2_PACKAGE_KMOD_TOOLS),)
> +ifeq ($(BR2_PACKAGE_BUSYBOX),y)
> +# Busybox modprobe does not have a --first-time option; --verbose is just -v
> +# and --use-blacklist is just -b.
> +ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(BUSYBOX_BUILD_CONFIG)),y)

Is this working? Isn't that evaluated when Makefiles are parsed, i.e
before the build has extracted Busybox and created its .config file ?

Best regards,

Thomas
Carlos Santos Feb. 27, 2020, 6:57 p.m. UTC | #2
On Thu, Feb 27, 2020 at 2:27 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> On Thu, 27 Feb 2020 09:39:37 -0300
> unixmania@gmail.com wrote:
>
> > +# modprobe can be provided by either kmod or busybox
> > +ifeq ($(BR2_PACKAGE_KMOD_TOOLS),)
> > +ifeq ($(BR2_PACKAGE_BUSYBOX),y)
> > +# Busybox modprobe does not have a --first-time option; --verbose is just -v
> > +# and --use-blacklist is just -b.
> > +ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(BUSYBOX_BUILD_CONFIG)),y)
>
> Is this working? Isn't that evaluated when Makefiles are parsed, i.e
> before the build has extracted Busybox and created its .config file ?
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

Hum, not in a clean build. Good catch. :-(

But it works if I use

    $(BR2_PACKAGE_BUSYBOX_CONFIG) $(BUSYBOX_BUILD_CONFIG)

So in a clean/first build it will take the value from the first file
and in a dirty build it will take the value from the second file.

--
Carlos Santos <unixmania@gmail.com>
Carlos Santos Feb. 27, 2020, 8:16 p.m. UTC | #3
On Thu, Feb 27, 2020 at 3:57 PM Carlos Santos <unixmania@gmail.com> wrote:
>
> On Thu, Feb 27, 2020 at 2:27 PM Thomas Petazzoni
> <thomas.petazzoni@bootlin.com> wrote:
> >
> > On Thu, 27 Feb 2020 09:39:37 -0300
> > unixmania@gmail.com wrote:
> >
> > > +# modprobe can be provided by either kmod or busybox
> > > +ifeq ($(BR2_PACKAGE_KMOD_TOOLS),)
> > > +ifeq ($(BR2_PACKAGE_BUSYBOX),y)
> > > +# Busybox modprobe does not have a --first-time option; --verbose is just -v
> > > +# and --use-blacklist is just -b.
> > > +ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(BUSYBOX_BUILD_CONFIG)),y)
> >
> > Is this working? Isn't that evaluated when Makefiles are parsed, i.e
> > before the build has extracted Busybox and created its .config file ?
> >
> > Best regards,
> >
> > Thomas
> > --
> > Thomas Petazzoni, CTO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
>
> Hum, not in a clean build. Good catch. :-(
>
> But it works if I use
>
>     $(BR2_PACKAGE_BUSYBOX_CONFIG) $(BUSYBOX_BUILD_CONFIG)
>
> So in a clean/first build it will take the value from the first file
> and in a dirty build it will take the value from the second file.

I just sent a v2 which hopefully cover all the cases. It even deals
with kconfig fragment files.
diff mbox series

Patch

diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk
index 3f6453cef5..999e34e094 100644
--- a/package/openrc/openrc.mk
+++ b/package/openrc/openrc.mk
@@ -9,7 +9,7 @@  OPENRC_SITE = $(call github,OpenRC,openrc,$(OPENRC_VERSION))
 OPENRC_LICENSE = BSD-2-Clause
 OPENRC_LICENSE_FILES = LICENSE
 
-OPENRC_DEPENDENCIES = ncurses
+OPENRC_DEPENDENCIES = ncurses $(if $(BR2_PACKAGE_BUSYBOX),busybox)
 
 # set LIBNAME so openrc puts files in proper directories and sets proper
 # paths in installed files. Since in buildroot /lib64 and /lib32 always
@@ -29,9 +29,30 @@  else
 OPENRC_MAKE_OPTS += MKSTATICLIBS=yes
 endif
 
-define OPENRC_BUILD_CMDS
-	$(MAKE) $(OPENRC_MAKE_OPTS) -C $(@D)
+# modprobe can be provided by either kmod or busybox
+ifeq ($(BR2_PACKAGE_KMOD_TOOLS),)
+ifeq ($(BR2_PACKAGE_BUSYBOX),y)
+# Busybox modprobe does not have a --first-time option; --verbose is just -v
+# and --use-blacklist is just -b.
+ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(BUSYBOX_BUILD_CONFIG)),y)
+ifeq ($(call KCONFIG_GET_OPT,CONFIG_FEATURE_MODPROBE_BLACKLIST,$(BUSYBOX_BUILD_CONFIG)),y)
+OPENRC_MODULES_BLACKLIST = s/ --use-blacklist/ -b/
+else
+OPENRC_MODULES_BLACKLIST = s/ --use-blacklist//
+endif
+define OPENRC_MODULES_CLEAN
+	$(SED) 's/ --first-time//;$(OPENRC_MODULES_BLACKLIST);s/--verbose/-v/' \
+		$(@D)/init.d/modules.in
+endef
+else # BR2_PACKAGE_BUSYBOX
+# No modprobe command available. Do not build/install the modules script.
+define OPENRC_MODULES_CLEAN
+	$(SED) 's/ modules//' $(@D)/{conf.d,init.d,runlevels}/Makefile
 endef
+endif # CONFIG_MODPROBE
+OPENRC_POST_PATCH_HOOKS += OPENRC_MODULES_CLEAN
+endif # BR2_PACKAGE_BUSYBOX
+endif # BR2_PACKAGE_KMOD_TOOLS
 
 define OPENRC_INSTALL_TARGET_CMDS
 	$(MAKE) $(OPENRC_MAKE_OPTS) DESTDIR=$(TARGET_DIR) -C $(@D) install