Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/3] Rework of the init system
Date: Tue, 20 Dec 2011 09:03:41 +0100	[thread overview]
Message-ID: <201112200903.41149.arnout@mind.be> (raw)
In-Reply-To: <1322047811-12933-3-git-send-email-maxime.ripard@free-electrons.com>

On Wednesday 23 November 2011 12:30:10 Maxime Ripard wrote:
> Since we have now two uncompatible init systems, and we want only one of
> them at the same time in the rootfs, we need to select a particular init
> system. This patch also adds $(PKG)_INIT_SYSV and $(PKG)_INIT_SYSTEMD
> variables, that basically moves the init script installation in the
> package infrastructure, and installs them only when needed.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

> ---
>  package/Makefile.package.in  |    8 ++++++++
>  package/busybox/busybox.mk   |   11 +++++++++++
>  package/systemd/Config.in    |    1 +
>  package/sysvinit/Config.in   |    1 +
>  package/sysvinit/sysvinit.mk |    5 -----
>  target/generic/Config.in     |   19 +++++++++++++++++++
>  6 files changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/package/Makefile.package.in b/package/Makefile.package.in
> index bd9ceb5..c0684d0 100644
> --- a/package/Makefile.package.in
> +++ b/package/Makefile.package.in
> @@ -367,6 +367,10 @@ $(BUILD_DIR)/%/.stamp_images_installed:
>  # Install to target dir
>  $(BUILD_DIR)/%/.stamp_target_installed:
>  	@$(call MESSAGE,"Installing to target")
> +	$(if $(and $(BR2_INIT_SYSTEMD),$($(PKG)_INIT_SYSTEMD)),\
> +		$(foreach init,$($(PKG)_INIT_SYSTEMD),$(INSTALL) -m 0755 -D $(init) $(TARGET_DIR)/etc/init.d/$(notdir $(init))))
> +	$(if $(and $(or $(BR2_INIT_SYSV),$(BR2_INIT_BUSYBOX)),$($(PKG)_INIT_SYSV)),\
> +		$(foreach init,$($(PKG)_INIT_SYSV),$(INSTALL) -m 0755 -D $(init) $(TARGET_DIR)/etc/init.d/$(notdir $(init))))
 Since this is used twice, it makes sense to either define a function for
it or to go over SYSTEMD and SYSV in a loop.  Also to simplify things, I
would rename BR2_INIT_SYSV to BR2_INIT_SYSVINIT and define an additional 
BR2_INIT_SYSV that is selected by both INIT_BUSYBOX and INIT_SYSV (see 
below).  So this becomes (untested!):
	$(foreach style,SYSTEMD SYSV,\
	  $(if $(and $(BR2_INIT_$(style)),$($(PKG)_INIT_$(style))),\
	    $(foreach init,$($(PKG)_INIT_$(style)),\
	      $(INSTALL) -m 0755 -D $(init) $(TARGET_DIR)/etc/init.d/$(notdir $(init)))))

>  	$($(PKG)_INSTALL_TARGET_CMDS)
>  	$(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
>  	$(Q)touch $@
> @@ -384,6 +388,8 @@ $(BUILD_DIR)/%/.stamp_uninstalled:
>  	rm -f $($(PKG)_TARGET_INSTALL_STAGING)
>  	$($(PKG)_UNINSTALL_TARGET_CMDS)
>  	rm -f $($(PKG)_TARGET_INSTALL_TARGET)
> +	$(foreach init, $($(PKG)_INIT_SYSV), rm -f $(TARGET_DIR)/etc/init.d/$(notdir $(init)))
> +	$(foreach init, $($(PKG)_INIT_SYSTEMD), rm -f $(TARGET_DIR)/etc/init.d/$(notdir $(init)))
>  
>  # Remove package sources
>  $(BUILD_DIR)/%/.stamp_dircleaned:
> @@ -479,6 +485,8 @@ endif
>  endif
>  
>  $(2)_DEPENDENCIES		?=
> +$(2)_INIT_SYSTEMD		?=
> +$(2)_INIT_SYSV			?=
>  $(2)_INSTALL_STAGING		?= NO
>  $(2)_INSTALL_IMAGES		?= NO
>  $(2)_INSTALL_TARGET		?= YES
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index 9e91136..73c4969 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -129,6 +129,16 @@ define BUSYBOX_DISABLE_MMU_APPLETS
>  endef
>  endif
>  
> +ifeq ($(BR2_INIT_BUSYBOX),y)
> +define BUSYBOX_SET_INIT
> +	$(call KCONFIG_ENABLE_OPT,CONFIG_INIT,$(BUSYBOX_BUILD_CONFIG))
> +endef
> +else
> +define BUSYBOX_SET_INIT
> +	$(call KCONFIG_DISABLE_OPT,CONFIG_INIT,$(BUSYBOX_BUILD_CONFIG))
> +endef
> +endif
> +
 I'm not sure if I'd want to have the disable there if BR2_INIT_BUSYBOX
is not selected.  There's nothing against a parallel install of
systemd and busybox-init, selectable by 'init=...' on the kernel
command line.  (Well, except that systemd's symlinks destroy busybox init.)

>  define BUSYBOX_INSTALL_LOGGING_SCRIPT
>  	if grep -q CONFIG_SYSLOGD=y $(@D)/.config; then \
>  		[ -f $(TARGET_DIR)/etc/init.d/S01logging ] || \
> @@ -145,6 +155,7 @@ define BUSYBOX_CONFIGURE_CMDS
>  	$(BUSYBOX_SET_BB_PWD)
>  	$(BUSYBOX_SET_LARGEFILE)
>  	$(BUSYBOX_SET_IPV6)
> +	$(BUSYBOX_SET_INIT)
>  	$(BUSYBOX_SET_RPC)
>  	$(BUSYBOX_PREFER_STATIC)
>  	$(BUSYBOX_SET_MDEV)
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 09cedb9..33d5ccf 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -1,5 +1,6 @@
>  config BR2_PACKAGE_SYSTEMD
>  	bool "systemd"
> +	depends on BR2_INIT_SYSTEMD
 Again, there is no reason why you can't have sysvinit and systemd in
parallel (except for the symlinks).  Also, if you really want them to
be mutually exclusive, I'd prefer the more explicit
	depends on !BR2_PACKAGE_SYSVINIT

>  	depends on BR2_PACKAGE_UDEV
>  	depends on BR2_PACKAGE_DBUS
>  	select BR2_PACKAGE_LIBCAP
> diff --git a/package/sysvinit/Config.in b/package/sysvinit/Config.in
> index 34ec391..d91c643 100644
> --- a/package/sysvinit/Config.in
> +++ b/package/sysvinit/Config.in
> @@ -1,5 +1,6 @@
>  config BR2_PACKAGE_SYSVINIT
>  	bool "sysvinit"
> +	depends on BR2_INIT_SYSV
>  	help
>  	  /sbin/init - parent of all processes
>  
> diff --git a/package/sysvinit/sysvinit.mk b/package/sysvinit/sysvinit.mk
> index 0d65c43..163ba9b 100644
> --- a/package/sysvinit/sysvinit.mk
> +++ b/package/sysvinit/sysvinit.mk
> @@ -8,11 +8,6 @@ SYSVINIT_SOURCE  = sysvinit_$(SYSVINIT_VERSION)dsf.orig.tar.gz
>  SYSVINIT_PATCH   = sysvinit_$(SYSVINIT_VERSION)dsf-13.1.diff.gz
>  SYSVINIT_SITE    = $(BR2_DEBIAN_MIRROR)/debian/pool/main/s/sysvinit
>  
> -# Override Busybox implementations if Busybox is enabled.
> -ifeq ($(BR2_PACKAGE_BUSYBOX),y)
> -SYSVINIT_DEPENDENCIES = busybox
> -endif
> -
>  define SYSVINIT_DEBIAN_PATCHES
>  	if [ -d $(@D)/debian/patches ]; then \
>  		support/scripts/apply-patches.sh $(@D) $(@D)/debian/patches \*.patch; \
> diff --git a/target/generic/Config.in b/target/generic/Config.in
> index a91de32..d9b93af 100644
> --- a/target/generic/Config.in
> +++ b/target/generic/Config.in
> @@ -32,6 +32,25 @@ config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
>  
>  endchoice
>  
> +choice
> +	prompt "Init system"
> +	default BR2_INIT_BUSYBOX
> +
> +config BR2_INIT_BUSYBOX
> +	bool "Busybox init"
> +	select BR2_PACKAGE_BUSYBOX
> +
> +config BR2_INIT_SYSTEMD
> +	bool "Use systemd"
> +	depends on BR2_PACKAGE_UDEV
 Missing:
	depends on BR2_PACKAGE_DBUS
 Also missing the comment in case the dependencies are not met.
> +	select BR2_PACKAGE_SYSTEMD
> +
> +config BR2_INIT_SYSV
> +	bool "Use systemV init"
> +	select BR2_PACKAGE_SYSVINIT
> +
> +endchoice
> +
 I'd prefer the ordering to be busybox, sysvinit, systemd, because:
- systemd is newer
- systemd has more dependencies


 Regards,
 Arnout


>  config BR2_ROOTFS_DEVICE_TABLE
>  	string "Path to the permission tables"
>  	default "target/generic/device_table.txt"
> 

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  31BB CF53 8660 6F88 345D  54CC A836 5879 20D7 CF43

  reply	other threads:[~2011-12-20  8:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 11:30 [Buildroot] [RFC] Add systemd to buildroot Maxime Ripard
2011-11-23 11:30 ` [Buildroot] [PATCH 1/3] Add the systemd package Maxime Ripard
2011-11-23 11:57   ` Baruch Siach
2011-11-23 13:53     ` Maxime Ripard
2011-12-20  7:05   ` Arnout Vandecappelle
2012-01-02  9:35     ` Maxime Ripard
2011-11-23 11:30 ` [Buildroot] [PATCH 2/3] Rework of the init system Maxime Ripard
2011-12-20  8:03   ` Arnout Vandecappelle [this message]
2012-01-02  9:52     ` Maxime Ripard
2012-01-02 14:52       ` Thomas Petazzoni
2012-01-06  7:13       ` Arnout Vandecappelle
2012-01-06  9:15         ` Maxime Ripard
2012-01-09  6:37           ` Arnout Vandecappelle
2011-11-23 11:30 ` [Buildroot] [PATCH 3/3] Migrate the packages to the new infra Maxime Ripard
2011-12-20 21:29   ` Arnout Vandecappelle
2012-01-02 10:02     ` Maxime Ripard
2012-01-06  6:52       ` Arnout Vandecappelle
2011-11-23 14:05 ` [Buildroot] [RFC] Add systemd to buildroot Maxime Ripard
2011-11-23 21:14 ` Belisko Marek
2011-11-23 21:35   ` Maxime Ripard
2011-12-20 21:14     ` Arnout Vandecappelle
2011-12-14 10:43 ` Maxime Ripard
2011-12-20  6:49 ` Arnout Vandecappelle
2012-01-02  9:58   ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201112200903.41149.arnout@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox