All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe
@ 2020-02-27 20:08 unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 1/4] Makefile: add SED_QUIET unixmania at gmail.com
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 20:08 UTC (permalink / raw
  To: buildroot

From: Carlos Santos <unixmania@gmail.com>

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. So we need to patch the
modules scripts accordingly.

Patch 1 adds SED_QUIET, used by the KCONFIG_GET_OPT macro, in patch 2.

Patch 2 adds a KCONFIG_GET_OPT macro. Given a config name and a file, it
returns the config value, if set; otherwise returns an empty string.

Patch 3 adapts the "modules" init script to busybox "modprobe".

Patch 4 documents the use of busybox.mk variables in openrc.mk.

Carlos Santos (4):
  Makefile: add SED_QUIET
  package/pkg-utils.mk: add KCONFIG_GET_OPT macro
  package/openrc: adapt "modules" init script to busybox "modprobe"
  package/busybox.mk: document the use of variables in openrc.mk

 Makefile                   |  4 +++-
 package/busybox/busybox.mk |  4 ++++
 package/openrc/openrc.mk   | 28 +++++++++++++++++++++++++---
 package/pkg-utils.mk       |  4 ++++
 4 files changed, 36 insertions(+), 4 deletions(-)

-- 
2.18.2

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

* [Buildroot] [PATCH v2 1/4] Makefile: add SED_QUIET
  2020-02-27 20:08 [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
@ 2020-02-27 20:08 ` unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro unixmania at gmail.com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 20:08 UTC (permalink / raw
  To: buildroot

From: Carlos Santos <unixmania@gmail.com>

- Save the sed command full path in HOSTSED
- Define SED as "$(HOSTSED) -i -e"
- Define SED_QUIET as "$(HOSTSED) -n -e"

SED_QUIET will be used by the forthcoming KCONFIG_GET_OPT macro.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index eb68598059..25285eb5c2 100644
--- a/Makefile
+++ b/Makefile
@@ -307,7 +307,9 @@ HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
 HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
-SED := $(shell which sed || type -p sed) -i -e
+HOSTSED := $(shell which sed || type -p sed)
+SED := $(HOSTSED) -i -e
+SED_QUIET := $(HOSTSED) -n -e
 
 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
-- 
2.18.2

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

* [Buildroot] [PATCH v2 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro
  2020-02-27 20:08 [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 1/4] Makefile: add SED_QUIET unixmania at gmail.com
@ 2020-02-27 20:08 ` unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 4/4] package/busybox.mk: document the use of variables in openrc.mk unixmania at gmail.com
  3 siblings, 0 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 20:08 UTC (permalink / raw
  To: buildroot

From: Carlos Santos <unixmania@gmail.com>

Given a config name and a file list, returns the config value if it is
set in one of the files, otherwise returns an empty string.

Files are searched in the given order and the last value found prevails
over the other ones.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 package/pkg-utils.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index d324934dba..6f9693e81a 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -16,6 +16,10 @@ define KCONFIG_ENABLE_OPT # (option, file)
 	echo '$(1)=y' >> $(2)
 endef
 
+define KCONFIG_GET_OPT # (option, files)
+$(shell $(SED_QUIET) '/^\<$(1)\>=/h;$${x;s/$(1)=//p;}' $(2) 2> /dev/null)
+endef
+
 define KCONFIG_SET_OPT # (option, value, file)
 	$(SED) "/\\<$(1)\\>/d" $(3)
 	echo '$(1)=$(2)' >> $(3)
-- 
2.18.2

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

* [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
  2020-02-27 20:08 [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 1/4] Makefile: add SED_QUIET unixmania at gmail.com
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro unixmania at gmail.com
@ 2020-02-27 20:08 ` unixmania at gmail.com
  2020-02-28 20:26   ` Yann E. MORIN
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 4/4] package/busybox.mk: document the use of variables in openrc.mk unixmania at gmail.com
  3 siblings, 1 reply; 6+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 20:08 UTC (permalink / raw
  To: buildroot

From: Carlos Santos <unixmania@gmail.com>

If kmod tools are not selected, check the busybox configuration files
and adapt the modules script accordingly:

- Busybox modprobe does not have a "--first-time" option.
- The "--verbose" option is just "-v".
- The "--use-blacklist" option is just "-b". Also 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 | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk
index 3f6453cef5..0fc87f95b1 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,31 @@ 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.
+OPENRC_BB_FILES = $(BUSYBOX_KCONFIG_FILE) $(BUSYBOX_KCONFIG_FRAGMENT_FILES) $(BUSYBOX_BUILD_CONFIG)
+ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(OPENRC_BB_FILES)),y)
+ifeq ($(call KCONFIG_GET_OPT,CONFIG_FEATURE_MODPROBE_BLACKLIST,$(OPENRC_BB_FILES)),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
-- 
2.18.2

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

* [Buildroot] [PATCH v2 4/4] package/busybox.mk: document the use of variables in openrc.mk
  2020-02-27 20:08 [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
                   ` (2 preceding siblings ...)
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
@ 2020-02-27 20:08 ` unixmania at gmail.com
  3 siblings, 0 replies; 6+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 20:08 UTC (permalink / raw
  To: buildroot

From: Carlos Santos <unixmania@gmail.com>

Prevent filures if the variables are removed or renamed in the future.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 package/busybox/busybox.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 9eeb784d2a..241a488e45 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -80,7 +80,9 @@ BUSYBOX_CFLAGS += "`$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`"
 BUSYBOX_CFLAGS_busybox += "`$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`"
 endif
 
+# Warning: this is also used in package/openrc/openrc.mk.
 BUSYBOX_BUILD_CONFIG = $(BUSYBOX_DIR)/.config
+
 # Allows the build system to tweak CFLAGS
 BUSYBOX_MAKE_ENV = \
 	$(TARGET_MAKE_ENV) \
@@ -105,8 +107,10 @@ ifndef BUSYBOX_CONFIG_FILE
 BUSYBOX_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG))
 endif
 
+# Warning: these two are also used in package/openrc/openrc.mk.
 BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
 BUSYBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES))
+
 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
 BUSYBOX_KCONFIG_OPTS = $(BUSYBOX_MAKE_OPTS)
 
-- 
2.18.2

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

* [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
  2020-02-27 20:08 ` [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
@ 2020-02-28 20:26   ` Yann E. MORIN
  0 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2020-02-28 20:26 UTC (permalink / raw
  To: buildroot

Carlos, All,

On 2020-02-27 17:08 -0300, unixmania at gmail.com spake thusly:
> From: Carlos Santos <unixmania@gmail.com>
> 
> If kmod tools are not selected, check the busybox configuration files
> and adapt the modules script accordingly:
> 
> - Busybox modprobe does not have a "--first-time" option.
> - The "--verbose" option is just "-v".
> - The "--use-blacklist" option is just "-b". Also 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 | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk
> index 3f6453cef5..0fc87f95b1 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)

This not nice, because currently we have no package dpending on busybox.
Instead, busybox depends on all packages (for which it may provide
applets).

Adding this first dependency onto busybox risks introducing a new
circular dependency (if not now, in the future).

>  # 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,31 @@ 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.
> +OPENRC_BB_FILES = $(BUSYBOX_KCONFIG_FILE) $(BUSYBOX_KCONFIG_FRAGMENT_FILES) $(BUSYBOX_BUILD_CONFIG)
> +ifeq ($(call KCONFIG_GET_OPT,CONFIG_MODPROBE,$(OPENRC_BB_FILES)),y)
> +ifeq ($(call KCONFIG_GET_OPT,CONFIG_FEATURE_MODPROBE_BLACKLIST,$(OPENRC_BB_FILES)),y)

This is not guaranteed to work, if the value of either or both of CONFIG_MODPROBE
or CONFIG_FEATURE_MODPROBE_BLACKLIST is not present in any of the config
fragments, and they get their default values (acted upon by running
oldconfig in busybox' package). Indeed, that happens way after we parse
our Makefiles.

Having Makefile constructs in Buildroot that test the presence and/or
content of Kconfig files is flawed by design.

> +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

This is conditional patching, and we like to avoid it as much as
possible.

We've discussed this series with the other maintainers, and we believe
that a simpler solution is to just add a dependency to kmod for openrc.

So I've posted that instead:
    https://patchwork.ozlabs.org/patch/1246825/

Regards,
Yann E. MORIN.

> +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
> -- 
> 2.18.2
> 
> _______________________________________________
> 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.  |
'------------------------------^-------^------------------^--------------------'

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

end of thread, other threads:[~2020-02-28 20:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-27 20:08 [Buildroot] [PATCH v2 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
2020-02-27 20:08 ` [Buildroot] [PATCH v2 1/4] Makefile: add SED_QUIET unixmania at gmail.com
2020-02-27 20:08 ` [Buildroot] [PATCH v2 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro unixmania at gmail.com
2020-02-27 20:08 ` [Buildroot] [PATCH v2 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
2020-02-28 20:26   ` Yann E. MORIN
2020-02-27 20:08 ` [Buildroot] [PATCH v2 4/4] package/busybox.mk: document the use of variables in openrc.mk unixmania at gmail.com

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.