* [Buildroot] [PATCH 1/4] Makefile: add SED_QUIET
2020-02-27 12:39 [Buildroot] [PATCH 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
@ 2020-02-27 12:39 ` unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro unixmania at gmail.com
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 12:39 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 6311ae643e..c7159059a6 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] 8+ messages in thread
* [Buildroot] [PATCH 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro
2020-02-27 12:39 [Buildroot] [PATCH 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 1/4] Makefile: add SED_QUIET unixmania at gmail.com
@ 2020-02-27 12:39 ` unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 4/4] package/busybox: document the use of BUSYBOX_BUILD_CONFIG in openrc.mk unixmania at gmail.com
3 siblings, 0 replies; 8+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 12:39 UTC (permalink / raw)
To: buildroot
From: Carlos Santos <unixmania@gmail.com>
Given a config name and a file, returns the config value if it is set;
otherwise returns an empty string.
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..c8d74520e9 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, file)
+$(shell $(SED_QUIET) '/^\<$(1)\>=/h;$${x;s/$(1)=//p;}' $(2))
+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] 8+ messages in thread
* [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
2020-02-27 12:39 [Buildroot] [PATCH 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 1/4] Makefile: add SED_QUIET unixmania at gmail.com
2020-02-27 12:39 ` [Buildroot] [PATCH 2/4] package/pkg-utils.mk: add KCONFIG_GET_OPT macro unixmania at gmail.com
@ 2020-02-27 12:39 ` unixmania at gmail.com
2020-02-27 17:27 ` Thomas Petazzoni
2020-02-27 12:39 ` [Buildroot] [PATCH 4/4] package/busybox: document the use of BUSYBOX_BUILD_CONFIG in openrc.mk unixmania at gmail.com
3 siblings, 1 reply; 8+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 12:39 UTC (permalink / raw)
To: buildroot
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(-)
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
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
2020-02-27 12:39 ` [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
@ 2020-02-27 17:27 ` Thomas Petazzoni
2020-02-27 18:57 ` Carlos Santos
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2020-02-27 17:27 UTC (permalink / raw)
To: buildroot
On Thu, 27 Feb 2020 09:39:37 -0300
unixmania at 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
2020-02-27 17:27 ` Thomas Petazzoni
@ 2020-02-27 18:57 ` Carlos Santos
2020-02-27 20:16 ` Carlos Santos
0 siblings, 1 reply; 8+ messages in thread
From: Carlos Santos @ 2020-02-27 18:57 UTC (permalink / raw)
To: buildroot
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 at 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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe"
2020-02-27 18:57 ` Carlos Santos
@ 2020-02-27 20:16 ` Carlos Santos
0 siblings, 0 replies; 8+ messages in thread
From: Carlos Santos @ 2020-02-27 20:16 UTC (permalink / raw)
To: buildroot
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 at 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.
--
Carlos Santos <unixmania@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 4/4] package/busybox: document the use of BUSYBOX_BUILD_CONFIG in openrc.mk
2020-02-27 12:39 [Buildroot] [PATCH 0/4] adapt openrc "modules" script to busybox modprobe unixmania at gmail.com
` (2 preceding siblings ...)
2020-02-27 12:39 ` [Buildroot] [PATCH 3/4] package/openrc: adapt "modules" init script to busybox "modprobe" unixmania at gmail.com
@ 2020-02-27 12:39 ` unixmania at gmail.com
3 siblings, 0 replies; 8+ messages in thread
From: unixmania at gmail.com @ 2020-02-27 12:39 UTC (permalink / raw)
To: buildroot
From: Carlos Santos <unixmania@gmail.com>
Prevent filures if the variable is removed or renamed in the future.
Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
package/busybox/busybox.mk | 2 ++
1 file changed, 2 insertions(+)
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 9eeb784d2a..a761ff569f 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) \
--
2.18.2
^ permalink raw reply related [flat|nested] 8+ messages in thread