Skip to contentSkip to conversation

system: Move skeleton-init-* selection to init

PATCH New Brandon Maier 2 participants 8 messages Oct 13, 2020 – Oct 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 system: Move skeleton-init-* selection to init

In preparation for supporting br2-external inits, move the 'select' for the BR2_PACKAGE_SKELETON_INIT_* to their respective init systems. This will allow a br2-external init to 'select' which skeleton it needs.

---
 system/Config.in | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
system/Config.in +11 -10
index b8b7c16529..ec61fac781 100644
@@ -1,21 +1,17 @@
 menu "System configuration"
 
-# Note: usually, it is not possible to select a provider of a virtual
-# package. But here we have an exception: there are only four providers
-# and they only get selected by separate entries in this choice and
-# under different, exclusive conditions. So this is a safe situation.
+# Note on package/skeleton: usually, it is not safe to 'select' a
+# provider of a virtual package. But below we have an exception: each
+# init system may select one of the virtual skeleton-init-* packages. As
+# only one init system may be enabled, only one skeleton-init-* may be
+# selected. So this is a safe situation.
 choice
 	prompt "Root FS skeleton"
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
-	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_INIT_SYSV
-	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_INIT_BUSYBOX
-	select BR2_PACKAGE_SKELETON_INIT_OPENRC if BR2_INIT_OPENRC
-	select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_INIT_SYSTEMD
-	select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_INIT_NONE
 	help
-	  Use default target skeleton
+	  Use default target skeleton for selected init system.
 
 config BR2_ROOTFS_SKELETON_CUSTOM
 	bool "custom target skeleton"
@@ -91,6 +87,7 @@ config BR2_INIT_BUSYBOX
 	bool "BusyBox"
 	select BR2_PACKAGE_BUSYBOX
 	select BR2_PACKAGE_INITSCRIPTS
+	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_INIT_SYSV
 	bool "systemV"
@@ -98,12 +95,14 @@ config BR2_INIT_SYSV
 	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit
 	select BR2_PACKAGE_INITSCRIPTS
 	select BR2_PACKAGE_SYSVINIT
+	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_INIT_OPENRC
 	bool "OpenRC"
 	depends on BR2_USE_MMU
 	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_OPENRC
+	select BR2_PACKAGE_SKELETON_INIT_OPENRC if BR2_ROOTFS_SKELETON_DEFAULT
 
 comment "openrc needs a toolchain w/ dynamic library"
 	depends on BR2_USE_MMU
@@ -126,6 +125,7 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_HOST_GCC_AT_LEAST_5
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
+	select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_ROOTFS_SKELETON_DEFAULT
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10, host and target gcc >= 5"
 	depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
@@ -138,6 +138,7 @@ comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10, host and targe
 
 config BR2_INIT_NONE
 	bool "None"
+	select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_ROOTFS_SKELETON_DEFAULT
 	help
 	  Buildroot will not install any init system. You will
 	  have to provide your own, either with a new package
Signature · 1 line
2.28.0
#1 lore raw

PATCH 2/2 system: support br2-external init systems

Some externals may wish to provide custom init systems for tightly integrated boot. This has been supported through the BR2_INIT_NONE, however a downside to the BR2_INIT_NONE is it forces the custom init system to use either skeleton-custom and roll a custom skeleton for each target, or skeleton-init-none which isn't a complete skeleton.

Allowing br2-external to define custom BR2_INIT_* means they can now safely 'select' the BR2_PACKAGE_SKELETON_INIT_* and use a sysv style skeleton if they want.

---
 support/scripts/br2-external | 17 +++++++++++++++++
 system/Config.in             |  3 +++
 2 files changed, 20 insertions(+)
support/scripts/br2-external +17 -0
index ededd2d900..f6ad722f72 100755
@@ -161,6 +161,7 @@ do_kconfig() {
         toolchains
         jpeg
         openssl
+        init
     )
 
     for br2 in "${items[@]}"; do
@@ -224,7 +225,23 @@ do_kconfig() {
         else
             printf '# No openssl from: %s\n\n' "${br2_desc}"
         fi >>"${outputdir}/.br2-external.in.openssl"
+
+        if [ -f "${br2_ext}/provides/init.in" ]; then
+            printf 'comment "init from: %s"\n' "${br2_desc}"
+            printf 'source "%s/provides/init.in"\n' "${br2_ext}"
+            printf '\n'
+        else
+            printf '# No init from: %s\n\n' "${br2_desc}"
+        fi >>"${outputdir}/.br2-external.in.init"
     done
+        if [ -f "${br2_ext}/provides/toolchains.in" ]; then
+            printf 'comment "Toolchains from: %s"\n' "${br2_desc}"
+            printf 'source "%s/provides/toolchains.in"\n' "${br2_ext}"
+            printf '\n'
+        else
+            printf '# No toolchain from: %s\n\n' "${br2_desc}"
+        fi >>"${outputdir}/.br2-external.in.toolchains"
+
 
     printf 'endmenu\n' >>"${outputdir}/.br2-external.in.menus"
 }
system/Config.in +3 -0
index ec61fac781..ff7a470561 100644
@@ -144,6 +144,9 @@ config BR2_INIT_NONE
 	  have to provide your own, either with a new package
 	  or with a rootfs-overlay.
 
+# Init systems from br2-external trees, if any
+source "$BR2_BASE_DIR/.br2-external.in.init"
+
 endchoice
 
 choice
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 1/5 system: support br2-external skeleton packages

In reply to Brandon Maier

Today, the BR2_ROOTFS_SKELETON_CUSTOM is the only way to build a custom skeleton. But it's limiting as users must provide a pre-built skeleton for each target. Supporting a br2-external package allows users to build up a skeleton and customize it with their own KConfig options.

---
 support/scripts/br2-external | 9 +++++++++
 system/Config.in             | 3 +++
 2 files changed, 12 insertions(+)
support/scripts/br2-external +9 -0
index ededd2d900..01804e1220 100755
@@ -161,6 +161,7 @@ do_kconfig() {
         toolchains
         jpeg
         openssl
+        skeleton
     )
 
     for br2 in "${items[@]}"; do
@@ -224,6 +225,14 @@ do_kconfig() {
         else
             printf '# No openssl from: %s\n\n' "${br2_desc}"
         fi >>"${outputdir}/.br2-external.in.openssl"
+
+        if [ -f "${br2_ext}/provides/skeleton.in" ]; then
+            printf 'comment "skeleton from: %s"\n' "${br2_desc}"
+            printf 'source "%s/provides/skeleton.in"\n' "${br2_ext}"
+            printf '\n'
+        else
+            printf '# No skeleton from: %s\n\n' "${br2_desc}"
+        fi >>"${outputdir}/.br2-external.in.skeleton"
     done
 
     printf 'endmenu\n' >>"${outputdir}/.br2-external.in.menus"
system/Config.in +3 -0
index b8b7c16529..a363e099e5 100644
@@ -23,6 +23,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  Use custom target skeleton.
 
+# skeleton from br2-external trees, if any
+source "$BR2_BASE_DIR/.br2-external.in.skeleton"
+
 endchoice
 
 if BR2_ROOTFS_SKELETON_CUSTOM
Signature · 1 line
2.28.0
#3 lore raw

PATCH v2 1/5 system: support br2-external skeleton packages

Brandon, All,

On 2020-10-13 17:36 -0500, Brandon Maier spake thusly:

Quoted 6 lines

Today, the BR2_ROOTFS_SKELETON_CUSTOM is the only way to build a custom skeleton. But it's limiting as users must provide a pre-built skeleton for each target. Supporting a br2-external package allows users to build up a skeleton and customize it with their own KConfig options.

Series applied to master, thanks!

I only did very minor tweaks; please see the ammended commit logs.

Regards,
Yann E. MORIN.

Quoted 49 lines
---
 support/scripts/br2-external | 9 +++++++++
 system/Config.in             | 3 +++
 2 files changed, 12 insertions(+)
support/scripts/br2-external +9 -0
index ededd2d900..01804e1220 100755
@@ -161,6 +161,7 @@ do_kconfig() {
         toolchains
         jpeg
         openssl
+        skeleton
     )
 
     for br2 in "${items[@]}"; do
@@ -224,6 +225,14 @@ do_kconfig() {
         else
             printf '# No openssl from: %s\n\n' "${br2_desc}"
         fi >>"${outputdir}/.br2-external.in.openssl"
+
+        if [ -f "${br2_ext}/provides/skeleton.in" ]; then
+            printf 'comment "skeleton from: %s"\n' "${br2_desc}"
+            printf 'source "%s/provides/skeleton.in"\n' "${br2_ext}"
+            printf '\n'
+        else
+            printf '# No skeleton from: %s\n\n' "${br2_desc}"
+        fi >>"${outputdir}/.br2-external.in.skeleton"
     done
 
     printf 'endmenu\n' >>"${outputdir}/.br2-external.in.menus"
system/Config.in +3 -0
index b8b7c16529..a363e099e5 100644
@@ -23,6 +23,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  Use custom target skeleton.
 
+# skeleton from br2-external trees, if any
+source "$BR2_BASE_DIR/.br2-external.in.skeleton"
+
 endchoice
 
 if BR2_ROOTFS_SKELETON_CUSTOM
Signature · 1 line
2.28.0
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v2 2/5 docs/manual: add section about br2-external skeleton

In reply to Brandon Maier
---
 docs/manual/customize-outside-br.txt | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
docs/manual/customize-outside-br.txt +22 -0
index 5f7d623aea..c24516680c 100644
@@ -202,6 +202,7 @@ a set of files that define those alternatives:
   will then be listed in the toolchain selection;
 * +provides/jpeg.in+ defines the alternative libjpeg implementations;
 * +provides/openssl.in+ defines the alternative openssl implementations.
+* +provides/skeleton.in+ defines the alternative skeleton implementations.
 
 ===== Free-form content
 
@@ -321,6 +322,27 @@ illustration, of course):
   |     |$(eval $(toolchain-external-package))
   |     `----
   |
+  |- provides/skeleton.in
+  |     |config BR2_ROOTFS_SKELETON_MINE
+  |     |    bool "my custom skeleton"
+  |     |    select BR2_PACKAGE_SKELETON_MINE
+  |     `----
+  |- package/skeleton-mine/Config.in
+  |     |config BR2_PACKAGE_SKELETON_MINE
+  |     |    bool
+  |     |    select BR2_PACKAGE_HAS_SKELETON
+  |     |
+  |     |config BR2_PACKAGE_PROVIDES_SKELETON
+  |     |    default "skeleton-mine" if BR2_PACKAGE_SKELETON_MINE
+  |     `----
+  |- package/skeleton-mine/skeleton-mine.mk
+  |     |SKELETON_MINE_ADD_TOOLCHAIN_DEPENDENCY = NO
+  |     |SKELETON_MINE_ADD_SKELETON_DEPENDENCY = NO
+  |     |SKELETON_MINE_PROVIDES = skeleton
+  |     |SKELETON_MINE_INSTALL_STAGING = YES
+  |     |$(eval $(generic-package))
+  |     `----
+  |
   |- linux/Config.ext.in
   |     |config BR2_LINUX_KERNEL_EXT_EXAMPLE_DRIVER
   |     |    bool "example-external-driver"
Signature · 1 line
2.28.0
#5 lore raw

PATCH v2 3/5 system: Move skeleton-init-* selection to init

In reply to Brandon Maier

In preparation for supporting br2-external inits, move the 'select' for the BR2_PACKAGE_SKELETON_INIT_* to their respective init systems. This will allow a br2-external init to 'select' which skeleton it needs.

---
 system/Config.in | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
system/Config.in +11 -10
index a363e099e5..f062e5be93 100644
@@ -1,21 +1,17 @@
 menu "System configuration"
 
-# Note: usually, it is not possible to select a provider of a virtual
-# package. But here we have an exception: there are only four providers
-# and they only get selected by separate entries in this choice and
-# under different, exclusive conditions. So this is a safe situation.
+# Note on package/skeleton: usually, it is not safe to 'select' a
+# provider of a virtual package. But below we have an exception: each
+# init system may select one of the virtual skeleton-init-* packages. As
+# only one init system may be enabled, only one skeleton-init-* may be
+# selected. So this is a safe situation.
 choice
 	prompt "Root FS skeleton"
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
-	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_INIT_SYSV
-	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_INIT_BUSYBOX
-	select BR2_PACKAGE_SKELETON_INIT_OPENRC if BR2_INIT_OPENRC
-	select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_INIT_SYSTEMD
-	select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_INIT_NONE
 	help
-	  Use default target skeleton
+	  Use default target skeleton for selected init system.
 
 config BR2_ROOTFS_SKELETON_CUSTOM
 	bool "custom target skeleton"
@@ -94,6 +90,7 @@ config BR2_INIT_BUSYBOX
 	bool "BusyBox"
 	select BR2_PACKAGE_BUSYBOX
 	select BR2_PACKAGE_INITSCRIPTS
+	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_INIT_SYSV
 	bool "systemV"
@@ -101,12 +98,14 @@ config BR2_INIT_SYSV
 	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit
 	select BR2_PACKAGE_INITSCRIPTS
 	select BR2_PACKAGE_SYSVINIT
+	select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_INIT_OPENRC
 	bool "OpenRC"
 	depends on BR2_USE_MMU
 	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_OPENRC
+	select BR2_PACKAGE_SKELETON_INIT_OPENRC if BR2_ROOTFS_SKELETON_DEFAULT
 
 comment "openrc needs a toolchain w/ dynamic library"
 	depends on BR2_USE_MMU
@@ -129,6 +128,7 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_HOST_GCC_AT_LEAST_5
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
+	select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_ROOTFS_SKELETON_DEFAULT
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10, host and target gcc >= 5"
 	depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
@@ -141,6 +141,7 @@ comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10, host and targe
 
 config BR2_INIT_NONE
 	bool "None"
+	select BR2_PACKAGE_SKELETON_INIT_NONE if BR2_ROOTFS_SKELETON_DEFAULT
 	help
 	  Buildroot will not install any init system. You will
 	  have to provide your own, either with a new package
Signature · 1 line
2.28.0
#6 lore raw

PATCH v2 4/5 system: support br2-external init systems

In reply to Brandon Maier

Some externals may wish to provide custom init systems for tightly integrated boot. This has been supported through the BR2_INIT_NONE, however a downside to the BR2_INIT_NONE is it forces the custom init system to use either skeleton-custom and roll a custom skeleton for each target, or skeleton-init-none which isn't a complete skeleton.

Allowing br2-external to define custom BR2_INIT_* means they can now safely 'select' the BR2_PACKAGE_SKELETON_INIT_* and use a sysv style skeleton if they want.

---
v2
- Remove bad code from a rebase

---
 support/scripts/br2-external | 9 +++++++++
 system/Config.in             | 3 +++
 2 files changed, 12 insertions(+)
support/scripts/br2-external +9 -0
index 01804e1220..56dc6f53ca 100755
@@ -162,6 +162,7 @@ do_kconfig() {
         jpeg
         openssl
         skeleton
+        init
     )
 
     for br2 in "${items[@]}"; do
@@ -233,6 +234,14 @@ do_kconfig() {
         else
             printf '# No skeleton from: %s\n\n' "${br2_desc}"
         fi >>"${outputdir}/.br2-external.in.skeleton"
+
+        if [ -f "${br2_ext}/provides/init.in" ]; then
+            printf 'comment "init from: %s"\n' "${br2_desc}"
+            printf 'source "%s/provides/init.in"\n' "${br2_ext}"
+            printf '\n'
+        else
+            printf '# No init from: %s\n\n' "${br2_desc}"
+        fi >>"${outputdir}/.br2-external.in.init"
     done
 
     printf 'endmenu\n' >>"${outputdir}/.br2-external.in.menus"
system/Config.in +3 -0
index f062e5be93..33abb9beb1 100644
@@ -147,6 +147,9 @@ config BR2_INIT_NONE
 	  have to provide your own, either with a new package
 	  or with a rootfs-overlay.
 
+# Init systems from br2-external trees, if any
+source "$BR2_BASE_DIR/.br2-external.in.init"
+
 endchoice
 
 choice
Signature · 1 line
2.28.0
#7 lore raw

PATCH v2 5/5 docs/manual: add section about br2-external init

In reply to Brandon Maier
---
 docs/manual/customize-outside-br.txt | 9 +++++++++
 1 file changed, 9 insertions(+)
docs/manual/customize-outside-br.txt +9 -0
index c24516680c..59a01f278d 100644
@@ -203,6 +203,8 @@ a set of files that define those alternatives:
 * +provides/jpeg.in+ defines the alternative libjpeg implementations;
 * +provides/openssl.in+ defines the alternative openssl implementations.
 * +provides/skeleton.in+ defines the alternative skeleton implementations.
+* +provides/init.in+ defines the alternative init system implementations, this
+  can be used to select a default skeleton for your init.
 
 ===== Free-form content
 
@@ -343,6 +345,13 @@ illustration, of course):
   |     |$(eval $(generic-package))
   |     `----
   |
+  |- provides/init.in
+  |     |config BR2_INIT_MINE
+  |     |    bool "my custom init"
+  |     |    select BR2_PACKAGE_MY_INIT
+  |     |    select BR2_PACKAGE_SKELETON_INIT_SYSV if BR2_ROOTFS_SKELETON_DEFAULT
+  |     `----
+  |
   |- linux/Config.ext.in
   |     |config BR2_LINUX_KERNEL_EXT_EXAMPLE_DRIVER
   |     |    bool "example-external-driver"
Signature · 1 line
2.28.0