* [Buildroot] [PATCH 01/13] system: reword merged-usr prompt
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH Yann E. MORIN
` (11 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
The current pro;pt is overly verbose, and departs from the usual
terminology used to refer to merged /usr, which, 10 years later [0],
makes it a little bit difficult to find or understand.
Furthermore, we're going to add another similar prompt for merged
/usr/sbin, and there's no way we want to introduce as similarly
convoluted prompt then.
Reword the prompt for the merged /usr option to the explicit "merged
/usr" everyone expects and understands.
[0] see commit c5bd8af65e50 (system: add options for /bin /sbin and
/lib to be symlinks into /usr)
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
system/Config.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/Config.in b/system/Config.in
index 8ff6c7213e..f747fdbc56 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -336,7 +336,7 @@ config BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES
Support extended attributes handling in device tables
config BR2_ROOTFS_MERGED_USR
- bool "Use symlinks to /usr for /bin, /sbin and /lib"
+ bool "Merged /usr"
help
If you say 'n' here, then /bin, /sbin and /lib and their
counterparts in /usr will be separate directories. This
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 01/13] system: reword merged-usr prompt Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init Yann E. MORIN
` (10 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Kconfig applies the default values in the order they are defined, and
stops at the first which condition is met. In this case, the two
conditions are mutually exclusive, so we can drop the second one. This
also makes it obvious there actually is a default value.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
system/Config.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/Config.in b/system/Config.in
index f747fdbc56..2499dc8208 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -534,7 +534,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
config BR2_SYSTEM_DEFAULT_PATH
string "Set the system's default PATH"
default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
- default "/bin:/sbin:/usr/bin:/usr/sbin" if !BR2_ROOTFS_MERGED_USR
+ default "/bin:/sbin:/usr/bin:/usr/sbin"
help
Sets the system's default PATH. It is being used in
/etc/profile in the skeleton-init-common package and by some
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 01/13] system: reword merged-usr prompt Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status Yann E. MORIN
` (9 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN, Norbert Lange, Sen Hastings
Since version 255, systemd no longer supports split-usr [0].
Move the select from the init system to the package, to explicitly
expose tha fact.
Drop our comment about our design decision, as it no longer applies.
[0] https://github.com/systemd/systemd/blob/v255/NEWS#L7
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Norbert Lange <nolange79@gmail.com>
Cc: Sen Hastings <sen@hastings.org>
---
package/systemd/Config.in | 1 +
system/Config.in | 5 -----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 851b91aeba..fd7671480c 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -24,6 +24,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
depends on BR2_HOST_GCC_AT_LEAST_8 # host-systemd
+ select BR2_ROOTFS_MERGED_USR
select BR2_PACKAGE_HAS_UDEV
select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
select BR2_PACKAGE_LIBCAP
diff --git a/system/Config.in b/system/Config.in
index 2499dc8208..2f42e5ddf9 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -115,10 +115,6 @@ comment "openrc needs a glibc or musl toolchain w/ dynamic library"
depends on BR2_USE_MMU
depends on BR2_STATIC_LIBS && BR2_TOOLCHAIN_USES_UCLIBC
-# In Buildroot, we decided not to support a split-usr when systemd is
-# used as an init system. This is a design decision, not a systemd
-# issue. Thus the select is with BR2_INIT_SYSTEMD (below) rather than
-# with BR2_PACKAGE_SYSTEMD.
config BR2_INIT_SYSTEMD
bool "systemd"
depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
@@ -130,7 +126,6 @@ config BR2_INIT_SYSTEMD
depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
depends on BR2_HOST_GCC_AT_LEAST_8
- select BR2_ROOTFS_MERGED_USR
select BR2_PACKAGE_SYSTEMD
select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_ROOTFS_SKELETON_DEFAULT
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (2 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:08 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs Yann E. MORIN
` (8 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Rather than repeat the same canned sequence over and over again, move it
to a function that we can reuse as many times as needed. This will come
handy when we later need to check merged sbin.
Switch to using bash as it allows for nicer functions (local variables),
but we anyway require it globally already so that's not an additional
dependency.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
support/scripts/check-merged-usr.sh | 46 ++++++++++++++++-------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/support/scripts/check-merged-usr.sh b/support/scripts/check-merged-usr.sh
index 433857cd8c..ed0c58e9b7 100755
--- a/support/scripts/check-merged-usr.sh
+++ b/support/scripts/check-merged-usr.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
#
# Check if a given custom skeleton or overlay complies to the merged /usr
# requirements:
@@ -10,30 +10,36 @@
# /usr/lib/
# /usr/sbin/
#
-# Output: the list of non-compliant paths (empty if compliant).
+# Input:
+# $1: the root directory (skeleton, overlay) to check
+# Output:
+# stdout: the list of non-compliant paths (empty if compliant).
#
+# The directory to check for merged-usr
+root="${1}"
+
# Extract the inode numbers for all of those directories. In case any is
# a symlink, we want to get the inode of the pointed-to directory, so we
# append '/.' to be sure we get the target directory. Since the symlinks
# can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
-# all of them.
+# each of them.
#
-lib_inode=$(stat -c '%i' "${1}/lib/." 2>/dev/null)
-bin_inode=$(stat -c '%i' "${1}/bin/." 2>/dev/null)
-sbin_inode=$(stat -c '%i' "${1}/sbin/." 2>/dev/null)
-usr_lib_inode=$(stat -c '%i' "${1}/usr/lib/." 2>/dev/null)
-usr_bin_inode=$(stat -c '%i' "${1}/usr/bin/." 2>/dev/null)
-usr_sbin_inode=$(stat -c '%i' "${1}/usr/sbin/." 2>/dev/null)
-not_merged_dirs=""
-test -z "$lib_inode" || \
- test "$lib_inode" = "$usr_lib_inode" || \
- not_merged_dirs="/lib"
-test -z "$bin_inode" || \
- test "$bin_inode" = "$usr_bin_inode" || \
- not_merged_dirs="$not_merged_dirs /bin"
-test -z "$sbin_inode" || \
- test "$sbin_inode" = "$usr_sbin_inode" || \
- not_merged_dirs="$not_merged_dirs /sbin"
-echo "${not_merged_dirs# }"
+test_merged() {
+ local root="${1}"
+ local dir1="${2}"
+ local dir2="${3}"
+ local inode1 inode2
+
+ inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
+ inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
+
+ test -z "${inode1}" || \
+ test "${inode1}" = "${inode2}" || \
+ printf '%s\n' "${dir1}"
+}
+
+test_merged "${root}" "/lib" "/usr/lib"
+test_merged "${root}" "/bin" "/usr/bin"
+test_merged "${root}" "/sbin" "/usr/sbin"
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (3 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 7:59 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh Yann E. MORIN
` (7 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Currently, we accept that the merged usr is bqckward, i.e. that the
/usr/bin, /usr/sbin, and /usr/lib entries be symlinks to, resp., /bin,
/sbin, and /lib. We also allow either entries to be symlinks to other
parts of the root. Both are accepted despite the comment at the top of
the script explaining what should be accepted.
However, a properly merged usr is the other way around: /bin, /sbin, and
/lib are the symlinks to resp. /usr/bin, /usr/sbin, and /usr/lib, and
the latters are actual directories.
Fix the check-merged-usr script accordingly; extend the hedaing-comment
to be more explicit (and drop '/' as there is nothing to say about it).
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
support/scripts/check-merged-usr.sh | 34 +++++++++++++++++------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/support/scripts/check-merged-usr.sh b/support/scripts/check-merged-usr.sh
index ed0c58e9b7..9459d975fe 100755
--- a/support/scripts/check-merged-usr.sh
+++ b/support/scripts/check-merged-usr.sh
@@ -2,13 +2,12 @@
#
# Check if a given custom skeleton or overlay complies to the merged /usr
# requirements:
-# /
-# /bin -> usr/bin
-# /lib -> usr/lib
-# /sbin -> usr/sbin
-# /usr/bin/
-# /usr/lib/
-# /usr/sbin/
+# /bin missing or symlink to usr/bin
+# /lib missing or symlink to usr/lib
+# /sbin missing or symlink to usr/sbin
+# /usr/bin/ directory
+# /usr/lib/ directory
+# /usr/sbin/ directory
#
# Input:
# $1: the root directory (skeleton, overlay) to check
@@ -21,10 +20,8 @@ root="${1}"
# Extract the inode numbers for all of those directories. In case any is
# a symlink, we want to get the inode of the pointed-to directory, so we
-# append '/.' to be sure we get the target directory. Since the symlinks
-# can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
-# each of them.
-#
+# append '/.' to be sure we get the target directory. To check whether
+# the symlink is backward, we need to append '/.' to each tested entry.
test_merged() {
local root="${1}"
@@ -32,12 +29,21 @@ test_merged() {
local dir2="${3}"
local inode1 inode2
+ # OK if missing first entry and second entry is an actual directory
+ test -e "${root}${dir1}" || { test -d "${root}${dir2}" && return; }
+
inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
- test -z "${inode1}" || \
- test "${inode1}" = "${inode2}" || \
- printf '%s\n' "${dir1}"
+ # OK if first entry is a symlink, second entry is a directoy, and
+ # both have the same inode (once dereferenced)
+ test -L "${root}${dir1}" \
+ && test -d "${root}${dir2}" \
+ && test "${inode1}" = "${inode2}" \
+ && return
+
+ # Otherwise, this directory is not merged
+ printf '%s\n' "${dir1}"
}
test_merged "${root}" "/lib" "/usr/lib"
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (4 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:35 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check Yann E. MORIN
` (6 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
We're going to need it to check merged-bin, so the naming would be
misleading as it would no longer be just about merged-usr.
Also drop the extension, it's useless.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
Makefile | 2 +-
package/skeleton-custom/skeleton-custom.mk | 2 +-
support/scripts/{check-merged-usr.sh => check-merged} | 0
3 files changed, 2 insertions(+), 2 deletions(-)
rename support/scripts/{check-merged-usr.sh => check-merged} (100%)
diff --git a/Makefile b/Makefile
index 411e1de515..a5aa1c6553 100644
--- a/Makefile
+++ b/Makefile
@@ -784,7 +784,7 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
@$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \
- $(Q)not_merged_dirs="$$(support/scripts/check-merged-usr.sh $(d))"; \
+ $(Q)not_merged_dirs="$$(support/scripts/check-merged $(d))"; \
test -n "$$not_merged_dirs" && { \
echo "ERROR: The overlay in $(d) is not" \
"using a merged /usr for the following directories:" \
diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
index b05c834b94..7d64959711 100644
--- a/package/skeleton-custom/skeleton-custom.mk
+++ b/package/skeleton-custom/skeleton-custom.mk
@@ -27,7 +27,7 @@ endif
# counterparts are appropriately setup as symlinks ones to the others.
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
- $(shell support/scripts/check-merged-usr.sh $(SKELETON_CUSTOM_PATH))
+ $(shell support/scripts/check-merged $(SKELETON_CUSTOM_PATH))
endif # merged /usr
ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
diff --git a/support/scripts/check-merged-usr.sh b/support/scripts/check-merged
similarity index 100%
rename from support/scripts/check-merged-usr.sh
rename to support/scripts/check-merged
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (5 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:24 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin) Yann E. MORIN
` (5 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
Makefile | 10 +++++-----
package/skeleton-custom/skeleton-custom.mk | 7 ++++---
support/scripts/check-merged | 19 +++++++++++++++----
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index a5aa1c6553..1248dfb9e0 100644
--- a/Makefile
+++ b/Makefile
@@ -780,11 +780,13 @@ endif
# For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
# counterparts are appropriately setup as symlinks ones to the others.
-ifeq ($(BR2_ROOTFS_MERGED_USR),y)
-
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
@$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \
- $(Q)not_merged_dirs="$$(support/scripts/check-merged $(d))"; \
+ $(Q)not_merged_dirs="$$(\
+ support/scripts/check-merged \
+ $(d) \
+ $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
+ )"; \
test -n "$$not_merged_dirs" && { \
echo "ERROR: The overlay in $(d) is not" \
"using a merged /usr for the following directories:" \
@@ -792,8 +794,6 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
exit 1; \
} || true$(sep))
-endif # merged /usr
-
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
@$(call MESSAGE,"Copying overlay $(d)")$(sep) \
$(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep))
diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
index 7d64959711..e583d2d731 100644
--- a/package/skeleton-custom/skeleton-custom.mk
+++ b/package/skeleton-custom/skeleton-custom.mk
@@ -25,10 +25,11 @@ endif
# For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
# counterparts are appropriately setup as symlinks ones to the others.
-ifeq ($(BR2_ROOTFS_MERGED_USR),y)
SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
- $(shell support/scripts/check-merged $(SKELETON_CUSTOM_PATH))
-endif # merged /usr
+ $(shell support/scripts/check-merged \
+ $(SKELETON_CUSTOM_PATH) \
+ $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
+ )
ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
diff --git a/support/scripts/check-merged b/support/scripts/check-merged
index 9459d975fe..7fea4e1dea 100755
--- a/support/scripts/check-merged
+++ b/support/scripts/check-merged
@@ -11,12 +11,14 @@
#
# Input:
# $1: the root directory (skeleton, overlay) to check
+# $*: the list of merged checks to perform: merged-usr
# Output:
# stdout: the list of non-compliant paths (empty if compliant).
#
-# The directory to check for merged-usr
+# The directory to check for $what
root="${1}"
+shift
# Extract the inode numbers for all of those directories. In case any is
# a symlink, we want to get the inode of the pointed-to directory, so we
@@ -46,6 +48,15 @@ test_merged() {
printf '%s\n' "${dir1}"
}
-test_merged "${root}" "/lib" "/usr/lib"
-test_merged "${root}" "/bin" "/usr/bin"
-test_merged "${root}" "/sbin" "/usr/sbin"
+for what; do
+ case "${what}" in
+ (merged-usr)
+ test_merged "${root}" "/lib" "/usr/lib"
+ test_merged "${root}" "/bin" "/usr/bin"
+ test_merged "${root}" "/sbin" "/usr/sbin"
+ ;;
+ (*)
+ printf 'Error: unknown type of test %s\n' "${what}"
+ ;;
+ esac
+done
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin)
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (6 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
2025-05-17 16:52 ` Edgar Bonet via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 09/13] package/systemd: require merged-bin Yann E. MORIN
` (4 subsequent siblings)
12 siblings, 2 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Starting with version 256 [0], systemd warns when /usr/bin and /usr/sbin
are different directories; in the future, it may even refuse to boot in
such a situation.
Add support for merged-bin, not unlike we have support for merged-usr;
we also make merged-bin a sub-case of merged-usr (i.e. it is not
possible to do merged-bin without merged-usr).
[0] https://github.com/systemd/systemd/blob/v256/NEWS#L265
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
Makefile | 1 +
package/skeleton-custom/skeleton-custom.mk | 3 ++-
support/scripts/check-merged | 5 ++++-
system/Config.in | 11 +++++++++++
system/skeleton/usr/sbin/.empty | 0
system/system.mk | 11 +++++++++++
6 files changed, 29 insertions(+), 2 deletions(-)
delete mode 100644 system/skeleton/usr/sbin/.empty
diff --git a/Makefile b/Makefile
index 1248dfb9e0..477179dd64 100644
--- a/Makefile
+++ b/Makefile
@@ -786,6 +786,7 @@ endif
support/scripts/check-merged \
$(d) \
$(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
+ $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
)"; \
test -n "$$not_merged_dirs" && { \
echo "ERROR: The overlay in $(d) is not" \
diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
index e583d2d731..7f9f10b81d 100644
--- a/package/skeleton-custom/skeleton-custom.mk
+++ b/package/skeleton-custom/skeleton-custom.mk
@@ -29,12 +29,13 @@ SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
$(shell support/scripts/check-merged \
$(SKELETON_CUSTOM_PATH) \
$(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
+ $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
)
ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
$(error The custom skeleton in $(SKELETON_CUSTOM_PATH) is not \
- using a merged /usr for the following directories: \
+ using a merged structuren for the following directories: \
$(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS))
endif
endif
diff --git a/support/scripts/check-merged b/support/scripts/check-merged
index 7fea4e1dea..0e51c032c5 100755
--- a/support/scripts/check-merged
+++ b/support/scripts/check-merged
@@ -11,7 +11,7 @@
#
# Input:
# $1: the root directory (skeleton, overlay) to check
-# $*: the list of merged checks to perform: merged-usr
+# $*: the list of merged checks to perform: merged-usr, merged-bin
# Output:
# stdout: the list of non-compliant paths (empty if compliant).
#
@@ -55,6 +55,9 @@ for what; do
test_merged "${root}" "/bin" "/usr/bin"
test_merged "${root}" "/sbin" "/usr/sbin"
;;
+ (merged-bin)
+ test_merged "${root}" "/usr/sbin" "/usr/bin"
+ ;;
(*)
printf 'Error: unknown type of test %s\n' "${what}"
;;
diff --git a/system/Config.in b/system/Config.in
index 2f42e5ddf9..5007f101e2 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -342,6 +342,16 @@ config BR2_ROOTFS_MERGED_USR
symlinks to their counterparts in /usr. In this case, /usr can
not be a separate filesystem.
+config BR2_ROOTFS_MERGED_SBIN
+ bool "Merged /usr/sbin"
+ depends on BR2_ROOTFS_MERGED_USR
+ help
+ If you say 'n' here, then /usr/bin and /usr/sbin will be
+ separate directories; this is the historical UNIX way.
+
+ If you say 'y' here, then /usr/sbin will be a relative
+ symlink to /usr/bin.
+
if BR2_ROOTFS_SKELETON_DEFAULT
config BR2_TARGET_ENABLE_ROOT_LOGIN
@@ -528,6 +538,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
config BR2_SYSTEM_DEFAULT_PATH
string "Set the system's default PATH"
+ default "/usr/bin" if BR2_ROOTFS_MERGED_SBIN
default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
default "/bin:/sbin:/usr/bin:/usr/sbin"
help
diff --git a/system/skeleton/usr/sbin/.empty b/system/skeleton/usr/sbin/.empty
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/system/system.mk b/system/system.mk
index 8fe2c138b0..530b26c162 100644
--- a/system/system.mk
+++ b/system/system.mk
@@ -34,16 +34,27 @@
# This function handles the merged or non-merged /usr cases
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
+ifeq ($(BR2_ROOTFS_MERGED_SBIN),y)
+define SYSTEM_SBIN_SYMLINKS_OR_DIRS
+ ln -snf bin $(1)/usr/sbin
+endef
+else
+define SYSTEM_SBIN_SYMLINKS_OR_DIRS
+ $(INSTALL) -d -m 0755 $(1)/usr/sbin
+endef
+endif
define SYSTEM_USR_SYMLINKS_OR_DIRS
ln -snf usr/bin $(1)/bin
ln -snf usr/sbin $(1)/sbin
ln -snf usr/lib $(1)/lib
+ $(SYSTEM_SBIN_SYMLINKS_OR_DIRS)
endef
else
define SYSTEM_USR_SYMLINKS_OR_DIRS
$(INSTALL) -d -m 0755 $(1)/bin
$(INSTALL) -d -m 0755 $(1)/sbin
$(INSTALL) -d -m 0755 $(1)/lib
+ $(INSTALL) -d -m 0755 $(1)/usr/sbin
endef
endif
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 09/13] package/systemd: require merged-bin
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (7 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin) Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 10/13] package/coreutils: no need for chroot workaround with merged-bin Yann E. MORIN
` (3 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN, Norbert Lange, Sen Hastings
Since version 256, systemd will taint the system if /usr/bin and
/usr/sbin are not merged, known as merged-bin. Although this is
not yet an error, it will be in the future.
To be as ready as we can be when that happens, forcibly enable
merged-bin, like we did when we initially added merged-usr.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Norbert Lange <nolange79@gmail.com>
Cc: Sen Hastings <sen@hastings.org>
---
package/systemd/Config.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index fd7671480c..5eaa092444 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -25,6 +25,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
depends on BR2_HOST_GCC_AT_LEAST_8 # host-systemd
select BR2_ROOTFS_MERGED_USR
+ select BR2_ROOTFS_MERGED_SBIN
select BR2_PACKAGE_HAS_UDEV
select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
select BR2_PACKAGE_LIBCAP
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin)
@ 2025-05-14 16:58 Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 01/13] system: reword merged-usr prompt Yann E. MORIN
` (12 more replies)
0 siblings, 13 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot
Cc: Giulio Benetti, Sen Hastings, Thomas Petazzoni, Romain Naour,
Yann E . MORIN, Norbert Lange
Hello All!
This series introduces support for so-called merged-bin, where /usr/sbin
is merged with /sur/bin, as an extra step after merged-usr, now
requested, and later required in a relatively close future, by systemd.
The series is organised in 4 main steps::
1. patches 1-3 are cleanups in the Kconfig menu, related to the
merged-usr prompt, to the defaults for PATH, and to the rationale
for selecting merged-usr with systemd; those can be applied without
considering the rest of the series;
2. then patches 4-6 prepare support/scripts/check-merged-usr.sh to
check for more than merged-usr: a good cleanup, and better check the
merged state; those patch can also be applied without considering
the rest of the series;
3. with patches 7-9, support for merged-bin is added, and made mandatory
for systemd;
4. finally, patches 10-13 introduce workarounds for a few packages to
properly support merged-bin. For ease of review, those are separate
patches, but that means the series _may_ break if the merged-bin
support is applied but not the per-package workarounds.
Although the series was tested with a large set of packages and a large
set of toolchains, and although it is a critical change, it is still
pretty well confined to just a few spots.
Regards,
Yann E. MORIN.
----------------------------------------------------------------
Yann E. MORIN (13):
system: reword merged-usr prompt
system: drop superfluous negative condition for default PATH
package/systemd: select merged-usr from package, not init
support/scripts: comonalise checking merged status
support/scripts: fix and restrict conditions to accept merged dirs
support/scripts: rename check-merged-usr.sh
support/scripts; teach check-merged what to check
system: add support for merged /usr/sbin (aka merged-bin)
package/systemd: require merged-bin
package/coreutils: no need for chroot workaround with merged-bin
package/kmod: adjust paths for merged-bin
package/util-linux: adjust paths for merged-bin
toolchain/external: support merged-bin
Makefile | 11 ++---
package/coreutils/coreutils.mk | 2 +
package/kmod/kmod.mk | 12 +++++-
package/skeleton-custom/skeleton-custom.mk | 10 +++--
package/systemd/Config.in | 2 +
package/util-linux/util-linux.mk | 8 +++-
support/scripts/check-merged | 65 ++++++++++++++++++++++++++++++
support/scripts/check-merged-usr.sh | 39 ------------------
system/Config.in | 20 +++++----
system/skeleton/usr/sbin/.empty | 0
system/system.mk | 11 +++++
toolchain/helpers.mk | 8 +++-
12 files changed, 128 insertions(+), 60 deletions(-)
create mode 100755 support/scripts/check-merged
delete mode 100755 support/scripts/check-merged-usr.sh
delete mode 100644 system/skeleton/usr/sbin/.empty
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 10/13] package/coreutils: no need for chroot workaround with merged-bin
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (8 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 09/13] package/systemd: require merged-bin Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 11/13] package/kmod: adjust paths for merged-bin Yann E. MORIN
` (2 subsequent siblings)
12 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
package/coreutils/coreutils.mk | 2 ++
1 file changed, 2 insertions(+)
diff --git a/package/coreutils/coreutils.mk b/package/coreutils/coreutils.mk
index a6d193b49e..cbfc2cd88c 100644
--- a/package/coreutils/coreutils.mk
+++ b/package/coreutils/coreutils.mk
@@ -125,6 +125,7 @@ define COREUTILS_CREATE_TEST_SYMLINK
endef
COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CREATE_TEST_SYMLINK
+ifeq ($(BR2_ROOTFS_MERGED_SBIN),)
# gnu thinks chroot is in bin, debian thinks it's in sbin
ifeq ($(BR2_PACKAGE_COREUTILS_INDIVIDUAL_BINARIES),y)
define COREUTILS_FIX_CHROOT_LOCATION
@@ -137,6 +138,7 @@ define COREUTILS_FIX_CHROOT_LOCATION
endef
endif
COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_FIX_CHROOT_LOCATION
+endif
# Explicitly install ln and realpath, which we *are* insterested in.
# A lot of other programs still get installed, however, but disabling
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 11/13] package/kmod: adjust paths for merged-bin
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (9 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 10/13] package/coreutils: no need for chroot workaround with merged-bin Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 12/13] package/util-linux: " Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 13/13] toolchain/external: support merged-bin Yann E. MORIN
12 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
---
package/kmod/kmod.mk | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/package/kmod/kmod.mk b/package/kmod/kmod.mk
index dfdd17b955..4635b8702d 100644
--- a/package/kmod/kmod.mk
+++ b/package/kmod/kmod.mk
@@ -68,16 +68,24 @@ ifeq ($(BR2_PACKAGE_KMOD_TOOLS),y)
KMOD_LICENSE += , GPL-2.0+ (tools)
KMOD_LICENSE_FILES += COPYING
-# /sbin is really /usr/sbin with merged /usr, so adjust relative symlink
+# /sbin is really /usr/sbin with merged /usr, and /usr/sbin is
+# really /usr/bin with merged sbin, so adjust relative symlink
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
+ifeq ($(BR2_ROOTFS_MERGED_SBIN),y)
+KMOD_BIN_PATH = kmod
+KMOD_SBIN_DIR = bin
+else
KMOD_BIN_PATH = ../bin/kmod
+KMOD_SBIN_DIR = sbin
+endif
else
KMOD_BIN_PATH = ../usr/bin/kmod
+KMOD_SBIN_DIR = sbin
endif
define KMOD_INSTALL_TOOLS
for i in depmod insmod lsmod modinfo modprobe rmmod; do \
- ln -sf $(KMOD_BIN_PATH) $(TARGET_DIR)/sbin/$$i; \
+ ln -sf $(KMOD_BIN_PATH) $(TARGET_DIR)/$(KMOD_SBIN_DIR)/$$i; \
done
endef
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 12/13] package/util-linux: adjust paths for merged-bin
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (10 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 11/13] package/kmod: adjust paths for merged-bin Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 13/13] toolchain/external: support merged-bin Yann E. MORIN
12 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
package/util-linux/util-linux.mk | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/package/util-linux/util-linux.mk b/package/util-linux/util-linux.mk
index ed30c0b107..ba3474b99f 100644
--- a/package/util-linux/util-linux.mk
+++ b/package/util-linux/util-linux.mk
@@ -74,7 +74,13 @@ endif
# ${usrlib_execdir} (/usr/lib) to ${libdir} (/lib), since both paths are
# the same when merged usr is in use.
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
-UTIL_LINUX_CONF_OPTS += --bindir=/usr/bin --sbindir=/usr/sbin --libdir=/usr/lib
+UTIL_LINUX_CONF_OPTS += --bindir=/usr/bin --libdir=/usr/lib
+# Ditto for /usr/sbin and /usr/bin when merge sbin is in use
+ifeq ($(BR2_ROOTFS_MERGED_SBIN),y)
+UTIL_LINUX_CONF_OPTS += --sbindir=/usr/bin
+else
+UTIL_LINUX_CONF_OPTS += --sbindir=/usr/sbin
+endif
endif
ifeq ($(BR2_PACKAGE_SYSTEMD),y)
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Buildroot] [PATCH 13/13] toolchain/external: support merged-bin
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
` (11 preceding siblings ...)
2025-05-14 16:58 ` [Buildroot] [PATCH 12/13] package/util-linux: " Yann E. MORIN
@ 2025-05-14 16:58 ` Yann E. MORIN
12 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-14 16:58 UTC (permalink / raw)
To: buildroot; +Cc: Yann E. MORIN, Giulio Benetti, Romain Naour, Thomas Petazzoni
When an external toolchain does not have a merged-bin, we can end up
with a situation where the toolchain installs an staging/usr/sbin/
directory, overriding the sbin symlink with an actual directory. When
not using PPD, this does not cause any harm.
However, with PPD, the build fails when preparing the staging (the
host/) for packages when the skeleton is eventually rsynced, e.g.:
$ cat defconfig
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PER_PACKAGE_DIRECTORIES=y
BR2_INIT_NONE=y
BR2_ROOTFS_MERGED_USR=y
BR2_ROOTFS_MERGED_SBIN=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_ZLIB=y
# BR2_TARGET_ROOTFS_TAR is not set
$ make zlib
[...]
>>> zlib Configuring
mkdir -p [...]/per-package/zlib/host
rsync -a --hard-links --link-dest=[...]/per-package/host-skeleton/host/ [...]/per-package/host-skeleton/host/ [...]/per-package/zlib/host
rsync -a --hard-links --link-dest=[...]/per-package/libzlib/host/ [...]/per-package/libzlib/host/ [...]/per-package/zlib/host
rsync -a --hard-links --link-dest=[...]/per-package/skeleton/host/ [...]/per-package/skeleton/host/ [...]/per-package/zlib/host
could not make way for new symlink: aarch64-buildroot-linux-gnu/sysroot/usr/sbin
cannot delete non-empty directory: aarch64-buildroot-linux-gnu/sysroot/usr/sbin
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.3.0]
make[1]: *** [package/pkg-generic.mk:256: [...]/build/zlib/.stamp_configured] Error 23
make: *** [Makefile:23: _all] Error 2
The root cause is that, in the skeleton, we end up with
[staging]/usr/sbin as a synlink to bin, but when the external toolchain
gets installed, the symlinbk is replaced by a directory. Later, when we
aggregate the PPD before configuring a package, it often happens that a
dependant package be rsynced before the toolchain and the skeleton, as
seen above, in which case the sbin directory from the toolchain, by way
of the dependency to a package, is already present when rsync wants to
create a symlink as rsynced from the skeleton.
In the example above, this plays in this order:
1. skeleton gets installed, provides a symlink
2. toolchain-external-bootlin rsyncs from skeleton, gets a symlink
3. toolchain-external-bootlin gets installed, replaces symlink with a
directory
4. libzlib rsyncs from skeleton, gets a ymlink, then rsyncs from
toolchain-e-b, gets a directory
5. zlib rsyncs from libzlib first (because alphabetical ordering), gets
a directory, then rsyncs from skeleton, which rsyncs from a symlink,
but the dstination is a non-empty directory, so rsync fails.
It is perfectly legit that an external toolchain does not use a
merged-bin setup, so we must accept that as input. We do so by treating
the /usr/sbin entry specially, like we already do for a few others, of
which /sbin itself for example.
Note that the merged-usr setup has no issue, because we already handle
the lib dirctories speically too.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
toolchain/helpers.mk | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index f3fdaaec07..21c710d0fb 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -96,6 +96,10 @@ copy_toolchain_lib_root = \
# Note that the 'locale' directories are not copied. They are huge
# (400+MB) in CodeSourcery toolchains, and they are not really useful.
#
+# usr/sbin may be a directory in the source toolchain, but a symlink
+# in the destination sysroot, when we are using a merged-bin. Account
+# for that.
+#
# $1: main sysroot directory of the toolchain
# $2: arch specific sysroot directory of the toolchain
# $3: arch specific subdirectory in the sysroot
@@ -109,13 +113,13 @@ copy_toolchain_sysroot = \
ARCH_SUBDIR="$(strip $3)"; \
ARCH_LIB_DIR="$(strip $4)" ; \
SUPPORT_LIB_DIR="$(strip $5)" ; \
- for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \
+ for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR} usr/sbin; do \
if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
continue ; \
fi ; \
if [ "$$i" = "usr" ]; then \
rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
- --include '/libexec*/' --exclude '/lib*/' \
+ --include '/libexec*/' --exclude '/lib*/' --exclude '/sbin' \
$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
else \
rsync -au --chmod=u=rwX,go=rX --exclude 'locale/' \
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs
2025-05-14 16:58 ` [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs Yann E. MORIN
@ 2025-05-17 7:59 ` Yann E. MORIN
2025-05-17 9:12 ` Arnout Vandecappelle via buildroot
2025-05-17 10:13 ` Arnout Vandecappelle via buildroot
0 siblings, 2 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-17 7:59 UTC (permalink / raw)
To: buildroot
All,
On 2025-05-14 18:58 +0200, Yann E. MORIN spake thusly:
> Currently, we accept that the merged usr is bqckward, i.e. that the
> /usr/bin, /usr/sbin, and /usr/lib entries be symlinks to, resp., /bin,
> /sbin, and /lib. We also allow either entries to be symlinks to other
> parts of the root. Both are accepted despite the comment at the top of
> the script explaining what should be accepted.
>
> However, a properly merged usr is the other way around: /bin, /sbin, and
> /lib are the symlinks to resp. /usr/bin, /usr/sbin, and /usr/lib, and
> the latters are actual directories.
[--SNIP--]
> @@ -32,12 +29,21 @@ test_merged() {
> local dir2="${3}"
> local inode1 inode2
>
> + # OK if missing first entry and second entry is an actual directory
> + test -e "${root}${dir1}" || { test -d "${root}${dir2}" && return; }
> +
> inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
> inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
>
> - test -z "${inode1}" || \
> - test "${inode1}" = "${inode2}" || \
> - printf '%s\n' "${dir1}"
> + # OK if first entry is a symlink, second entry is a directoy, and
> + # both have the same inode (once dereferenced)
> + test -L "${root}${dir1}" \
> + && test -d "${root}${dir2}" \
> + && test "${inode1}" = "${inode2}" \
> + && return
> +
> + # Otherwise, this directory is not merged
> + printf '%s\n' "${dir1}"
This new test is still quite complex, and is in fact still wrong in
weird cases. For example, with BASE a custom skeleton or rootfs overlay,
if BASE/sbin and BASE/usr/sbin ar absolute symlinks to /usr/sbin, the
test above will accept BASE as being properly merged, while it is in
fact broken.
I'm preparing a v2 which greatly simplifies the test, and makes it cover
more (all, hopefully) cases.
Regards,
Yann E. MORIN.
> }
>
> test_merged "${root}" "/lib" "/usr/lib"
> --
> 2.47.0
>
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs
2025-05-17 7:59 ` Yann E. MORIN
@ 2025-05-17 9:12 ` Arnout Vandecappelle via buildroot
2025-05-17 10:13 ` Arnout Vandecappelle via buildroot
1 sibling, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 9:12 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 17/05/2025 09:59, Yann E. MORIN wrote:
> All,
>
> On 2025-05-14 18:58 +0200, Yann E. MORIN spake thusly:
>> Currently, we accept that the merged usr is bqckward, i.e. that the
>> /usr/bin, /usr/sbin, and /usr/lib entries be symlinks to, resp., /bin,
>> /sbin, and /lib. We also allow either entries to be symlinks to other
>> parts of the root. Both are accepted despite the comment at the top of
>> the script explaining what should be accepted.
>>
>> However, a properly merged usr is the other way around: /bin, /sbin, and
>> /lib are the symlinks to resp. /usr/bin, /usr/sbin, and /usr/lib, and
>> the latters are actual directories.
> [--SNIP--]
>> @@ -32,12 +29,21 @@ test_merged() {
>> local dir2="${3}"
>> local inode1 inode2
>>
>> + # OK if missing first entry and second entry is an actual directory
>> + test -e "${root}${dir1}" || { test -d "${root}${dir2}" && return; }
>> +
>> inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
>> inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
>>
>> - test -z "${inode1}" || \
>> - test "${inode1}" = "${inode2}" || \
>> - printf '%s\n' "${dir1}"
>> + # OK if first entry is a symlink, second entry is a directoy, and
>> + # both have the same inode (once dereferenced)
>> + test -L "${root}${dir1}" \
>> + && test -d "${root}${dir2}" \
>> + && test "${inode1}" = "${inode2}" \
>> + && return
>> +
>> + # Otherwise, this directory is not merged
>> + printf '%s\n' "${dir1}"
>
> This new test is still quite complex, and is in fact still wrong in
> weird cases. For example, with BASE a custom skeleton or rootfs overlay,
> if BASE/sbin and BASE/usr/sbin ar absolute symlinks to /usr/sbin, the
> test above will accept BASE as being properly merged, while it is in
> fact broken.
>
> I'm preparing a v2 which greatly simplifies the test, and makes it cover
> more (all, hopefully) cases.
With that in mind, I'll quickly review the series now and mark it as Changes
Requested in patchwork, OK?
Thanks,
Arnout
>
> Regards,
> Yann E. MORIN.
>
>> }
>>
>> test_merged "${root}" "/lib" "/usr/lib"
>> --
>> 2.47.0
>>
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 01/13] system: reword merged-usr prompt
2025-05-14 16:58 ` [Buildroot] [PATCH 01/13] system: reword merged-usr prompt Yann E. MORIN
@ 2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:07 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> The current pro;pt is overly verbose, and departs from the usual
> terminology used to refer to merged /usr, which, 10 years later [0],
> makes it a little bit difficult to find or understand.
>
> Furthermore, we're going to add another similar prompt for merged
> /usr/sbin, and there's no way we want to introduce as similarly
> convoluted prompt then.
>
> Reword the prompt for the merged /usr option to the explicit "merged
> /usr" everyone expects and understands.
>
> [0] see commit c5bd8af65e50 (system: add options for /bin /sbin and
> /lib to be symlinks into /usr)
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
> ---
> system/Config.in | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/system/Config.in b/system/Config.in
> index 8ff6c7213e..f747fdbc56 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -336,7 +336,7 @@ config BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES
> Support extended attributes handling in device tables
>
> config BR2_ROOTFS_MERGED_USR
> - bool "Use symlinks to /usr for /bin, /sbin and /lib"
> + bool "Merged /usr"
> help
> If you say 'n' here, then /bin, /sbin and /lib and their
> counterparts in /usr will be separate directories. This
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH
2025-05-14 16:58 ` [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH Yann E. MORIN
@ 2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:07 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Kconfig applies the default values in the order they are defined, and
> stops at the first which condition is met. In this case, the two
> conditions are mutually exclusive, so we can drop the second one. This
> also makes it obvious there actually is a default value.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
> ---
> system/Config.in | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/system/Config.in b/system/Config.in
> index f747fdbc56..2499dc8208 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -534,7 +534,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
> config BR2_SYSTEM_DEFAULT_PATH
> string "Set the system's default PATH"
> default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
> - default "/bin:/sbin:/usr/bin:/usr/sbin" if !BR2_ROOTFS_MERGED_USR
> + default "/bin:/sbin:/usr/bin:/usr/sbin"
> help
> Sets the system's default PATH. It is being used in
> /etc/profile in the skeleton-init-common package and by some
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init
2025-05-14 16:58 ` [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init Yann E. MORIN
@ 2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:07 UTC (permalink / raw)
To: Yann E. MORIN, buildroot; +Cc: Norbert Lange, Sen Hastings
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Since version 255, systemd no longer supports split-usr [0].
>
> Move the select from the init system to the package, to explicitly
> expose tha fact.
>
> Drop our comment about our design decision, as it no longer applies.
>
> [0] https://github.com/systemd/systemd/blob/v255/NEWS#L7
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Norbert Lange <nolange79@gmail.com>
> Cc: Sen Hastings <sen@hastings.org>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
> ---
> package/systemd/Config.in | 1 +
> system/Config.in | 5 -----
> 2 files changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 851b91aeba..fd7671480c 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -24,6 +24,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
> depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
> depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
> depends on BR2_HOST_GCC_AT_LEAST_8 # host-systemd
> + select BR2_ROOTFS_MERGED_USR
> select BR2_PACKAGE_HAS_UDEV
> select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
> select BR2_PACKAGE_LIBCAP
> diff --git a/system/Config.in b/system/Config.in
> index 2499dc8208..2f42e5ddf9 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -115,10 +115,6 @@ comment "openrc needs a glibc or musl toolchain w/ dynamic library"
> depends on BR2_USE_MMU
> depends on BR2_STATIC_LIBS && BR2_TOOLCHAIN_USES_UCLIBC
>
> -# In Buildroot, we decided not to support a split-usr when systemd is
> -# used as an init system. This is a design decision, not a systemd
> -# issue. Thus the select is with BR2_INIT_SYSTEMD (below) rather than
> -# with BR2_PACKAGE_SYSTEMD.
> config BR2_INIT_SYSTEMD
> bool "systemd"
> depends on BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
> @@ -130,7 +126,6 @@ config BR2_INIT_SYSTEMD
> depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15
> depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
> depends on BR2_HOST_GCC_AT_LEAST_8
> - select BR2_ROOTFS_MERGED_USR
> select BR2_PACKAGE_SYSTEMD
> select BR2_PACKAGE_SKELETON_INIT_SYSTEMD if BR2_ROOTFS_SKELETON_DEFAULT
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status
2025-05-14 16:58 ` [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status Yann E. MORIN
@ 2025-05-17 10:08 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:08 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Rather than repeat the same canned sequence over and over again, move it
> to a function that we can reuse as many times as needed. This will come
> handy when we later need to check merged sbin.
>
> Switch to using bash as it allows for nicer functions (local variables),
> but we anyway require it globally already so that's not an additional
> dependency.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
> ---
> support/scripts/check-merged-usr.sh | 46 ++++++++++++++++-------------
> 1 file changed, 26 insertions(+), 20 deletions(-)
>
> diff --git a/support/scripts/check-merged-usr.sh b/support/scripts/check-merged-usr.sh
> index 433857cd8c..ed0c58e9b7 100755
> --- a/support/scripts/check-merged-usr.sh
> +++ b/support/scripts/check-merged-usr.sh
> @@ -1,4 +1,4 @@
> -#!/bin/sh
> +#!/usr/bin/env bash
> #
> # Check if a given custom skeleton or overlay complies to the merged /usr
> # requirements:
> @@ -10,30 +10,36 @@
> # /usr/lib/
> # /usr/sbin/
> #
> -# Output: the list of non-compliant paths (empty if compliant).
> +# Input:
> +# $1: the root directory (skeleton, overlay) to check
> +# Output:
> +# stdout: the list of non-compliant paths (empty if compliant).
> #
>
> +# The directory to check for merged-usr
> +root="${1}"
> +
> # Extract the inode numbers for all of those directories. In case any is
> # a symlink, we want to get the inode of the pointed-to directory, so we
> # append '/.' to be sure we get the target directory. Since the symlinks
> # can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
> -# all of them.
> +# each of them.
> #
> -lib_inode=$(stat -c '%i' "${1}/lib/." 2>/dev/null)
> -bin_inode=$(stat -c '%i' "${1}/bin/." 2>/dev/null)
> -sbin_inode=$(stat -c '%i' "${1}/sbin/." 2>/dev/null)
> -usr_lib_inode=$(stat -c '%i' "${1}/usr/lib/." 2>/dev/null)
> -usr_bin_inode=$(stat -c '%i' "${1}/usr/bin/." 2>/dev/null)
> -usr_sbin_inode=$(stat -c '%i' "${1}/usr/sbin/." 2>/dev/null)
>
> -not_merged_dirs=""
> -test -z "$lib_inode" || \
> - test "$lib_inode" = "$usr_lib_inode" || \
> - not_merged_dirs="/lib"
> -test -z "$bin_inode" || \
> - test "$bin_inode" = "$usr_bin_inode" || \
> - not_merged_dirs="$not_merged_dirs /bin"
> -test -z "$sbin_inode" || \
> - test "$sbin_inode" = "$usr_sbin_inode" || \
> - not_merged_dirs="$not_merged_dirs /sbin"
> -echo "${not_merged_dirs# }"
> +test_merged() {
> + local root="${1}"
> + local dir1="${2}"
> + local dir2="${3}"
> + local inode1 inode2
> +
> + inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
> + inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
> +
> + test -z "${inode1}" || \
> + test "${inode1}" = "${inode2}" || \
> + printf '%s\n' "${dir1}"
> +}
> +
> +test_merged "${root}" "/lib" "/usr/lib"
> +test_merged "${root}" "/bin" "/usr/bin"
> +test_merged "${root}" "/sbin" "/usr/sbin"
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs
2025-05-17 7:59 ` Yann E. MORIN
2025-05-17 9:12 ` Arnout Vandecappelle via buildroot
@ 2025-05-17 10:13 ` Arnout Vandecappelle via buildroot
2025-05-17 15:02 ` Yann E. MORIN
1 sibling, 1 reply; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:13 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 17/05/2025 09:59, Yann E. MORIN wrote:
> All,
>
> On 2025-05-14 18:58 +0200, Yann E. MORIN spake thusly:
>> Currently, we accept that the merged usr is bqckward, i.e. that the
>> /usr/bin, /usr/sbin, and /usr/lib entries be symlinks to, resp., /bin,
>> /sbin, and /lib. We also allow either entries to be symlinks to other
>> parts of the root. Both are accepted despite the comment at the top of
>> the script explaining what should be accepted.
>>
>> However, a properly merged usr is the other way around: /bin, /sbin, and
>> /lib are the symlinks to resp. /usr/bin, /usr/sbin, and /usr/lib, and
>> the latters are actual directories.
> [--SNIP--]
>> @@ -32,12 +29,21 @@ test_merged() {
>> local dir2="${3}"
>> local inode1 inode2
>>
>> + # OK if missing first entry and second entry is an actual directory
>> + test -e "${root}${dir1}" || { test -d "${root}${dir2}" && return; }
>> +
>> inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
>> inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
>>
>> - test -z "${inode1}" || \
>> - test "${inode1}" = "${inode2}" || \
>> - printf '%s\n' "${dir1}"
>> + # OK if first entry is a symlink, second entry is a directoy, and
>> + # both have the same inode (once dereferenced)
>> + test -L "${root}${dir1}" \
>> + && test -d "${root}${dir2}" \
>> + && test "${inode1}" = "${inode2}" \
>> + && return
>> +
>> + # Otherwise, this directory is not merged
>> + printf '%s\n' "${dir1}"
>
> This new test is still quite complex, and is in fact still wrong in
> weird cases. For example, with BASE a custom skeleton or rootfs overlay,
> if BASE/sbin and BASE/usr/sbin ar absolute symlinks to /usr/sbin, the
> test above will accept BASE as being properly merged, while it is in
> fact broken.
>
> I'm preparing a v2 which greatly simplifies the test, and makes it cover
> more (all, hopefully) cases.
I guess the test should simply be:
test -L "${root}${dir1}" \
&& test -d "${root}${dir2}" \
&& test "$(readlink "${root}${dir1}")" = "${dir2}" \
&& return
(which is not actually simpler... except that you can remove all the stat stuff)
Regards,
Arnout
>
> Regards,
> Yann E. MORIN.
>
>> }
>>
>> test_merged "${root}" "/lib" "/usr/lib"
>> --
>> 2.47.0
>>
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check
2025-05-14 16:58 ` [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check Yann E. MORIN
@ 2025-05-17 10:24 ` Arnout Vandecappelle via buildroot
2025-05-17 15:07 ` Yann E. MORIN
0 siblings, 1 reply; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:24 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
> Makefile | 10 +++++-----
> package/skeleton-custom/skeleton-custom.mk | 7 ++++---
> support/scripts/check-merged | 19 +++++++++++++++----
> 3 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index a5aa1c6553..1248dfb9e0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -780,11 +780,13 @@ endif
>
> # For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
> # counterparts are appropriately setup as symlinks ones to the others.
> -ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> -
> $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
> @$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \
> - $(Q)not_merged_dirs="$$(support/scripts/check-merged $(d))"; \
> + $(Q)not_merged_dirs="$$(\
> + support/scripts/check-merged \
> + $(d) \
> + $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + )"; \
> test -n "$$not_merged_dirs" && { \
> echo "ERROR: The overlay in $(d) is not" \
> "using a merged /usr for the following directories:" \
> @@ -792,8 +794,6 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> exit 1; \
> } || true$(sep))
>
> -endif # merged /usr
> -
> $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
> @$(call MESSAGE,"Copying overlay $(d)")$(sep) \
> $(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep))
> diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
> index 7d64959711..e583d2d731 100644
> --- a/package/skeleton-custom/skeleton-custom.mk
> +++ b/package/skeleton-custom/skeleton-custom.mk
> @@ -25,10 +25,11 @@ endif
>
> # For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
> # counterparts are appropriately setup as symlinks ones to the others.
> -ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
> - $(shell support/scripts/check-merged $(SKELETON_CUSTOM_PATH))
> -endif # merged /usr
> + $(shell support/scripts/check-merged \
> + $(SKELETON_CUSTOM_PATH) \
> + $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + )
While you're anyway working on this: I think there's little point of doing
this as a "preliminary" check, I think it's fine to do this check while
"building" the custom skeleton (i.e. in SKELETON_CUSTOM_INSTALL_TARGET_CMDS).
That would allow us to move the error message to the check-merged script
itself, and let it return 1 in case it's not properly merged. And with that,
both instances can simply call the script without capturing its output. It's
going to save +-10 lines of code and make things easier to understand IMHO.
>
> ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
> ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
> diff --git a/support/scripts/check-merged b/support/scripts/check-merged
> index 9459d975fe..7fea4e1dea 100755
> --- a/support/scripts/check-merged
> +++ b/support/scripts/check-merged
> @@ -11,12 +11,14 @@
> #
> # Input:
> # $1: the root directory (skeleton, overlay) to check
> +# $*: the list of merged checks to perform: merged-usr
If you make this an option (i.e. --merged-usr), then we can replace $1 with a
$* that covers all directories, and we can get rid of the foreach in Makefile's
check of the overlays, and that code could simplify to:
@$(call MESSAGE,"Sanity check in overlays)
support/scripts/check-merged \
$(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
$(call qstrip,$(BR2_ROOTFS_OVERLAY))
Of course, there's a risk that I'm overengineering things, so feel free to
ignore my suggestions.
Regards,
Arnout
> # Output:
> # stdout: the list of non-compliant paths (empty if compliant).
> #
>
> -# The directory to check for merged-usr
> +# The directory to check for $what
> root="${1}"
> +shift
>
> # Extract the inode numbers for all of those directories. In case any is
> # a symlink, we want to get the inode of the pointed-to directory, so we
> @@ -46,6 +48,15 @@ test_merged() {
> printf '%s\n' "${dir1}"
> }
>
> -test_merged "${root}" "/lib" "/usr/lib"
> -test_merged "${root}" "/bin" "/usr/bin"
> -test_merged "${root}" "/sbin" "/usr/sbin"
> +for what; do
> + case "${what}" in
> + (merged-usr)
> + test_merged "${root}" "/lib" "/usr/lib"
> + test_merged "${root}" "/bin" "/usr/bin"
> + test_merged "${root}" "/sbin" "/usr/sbin"
> + ;;
> + (*)
> + printf 'Error: unknown type of test %s\n' "${what}"
> + ;;
> + esac
> +done
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh
2025-05-14 16:58 ` [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh Yann E. MORIN
@ 2025-05-17 10:35 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:35 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> We're going to need it to check merged-bin, so the naming would be
> misleading as it would no longer be just about merged-usr.
>
> Also drop the extension, it's useless.
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
> ---
> Makefile | 2 +-
> package/skeleton-custom/skeleton-custom.mk | 2 +-
> support/scripts/{check-merged-usr.sh => check-merged} | 0
> 3 files changed, 2 insertions(+), 2 deletions(-)
> rename support/scripts/{check-merged-usr.sh => check-merged} (100%)
>
> diff --git a/Makefile b/Makefile
> index 411e1de515..a5aa1c6553 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -784,7 +784,7 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y)
>
> $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
> @$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \
> - $(Q)not_merged_dirs="$$(support/scripts/check-merged-usr.sh $(d))"; \
> + $(Q)not_merged_dirs="$$(support/scripts/check-merged $(d))"; \
> test -n "$$not_merged_dirs" && { \
> echo "ERROR: The overlay in $(d) is not" \
> "using a merged /usr for the following directories:" \
> diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
> index b05c834b94..7d64959711 100644
> --- a/package/skeleton-custom/skeleton-custom.mk
> +++ b/package/skeleton-custom/skeleton-custom.mk
> @@ -27,7 +27,7 @@ endif
> # counterparts are appropriately setup as symlinks ones to the others.
> ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
> - $(shell support/scripts/check-merged-usr.sh $(SKELETON_CUSTOM_PATH))
> + $(shell support/scripts/check-merged $(SKELETON_CUSTOM_PATH))
> endif # merged /usr
>
> ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
> diff --git a/support/scripts/check-merged-usr.sh b/support/scripts/check-merged
> similarity index 100%
> rename from support/scripts/check-merged-usr.sh
> rename to support/scripts/check-merged
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin)
2025-05-14 16:58 ` [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin) Yann E. MORIN
@ 2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
2025-05-17 16:52 ` Edgar Bonet via buildroot
1 sibling, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:38 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Starting with version 256 [0], systemd warns when /usr/bin and /usr/sbin
> are different directories; in the future, it may even refuse to boot in
> such a situation.
>
> Add support for merged-bin, not unlike we have support for merged-usr;
> we also make merged-bin a sub-case of merged-usr (i.e. it is not
> possible to do merged-bin without merged-usr).
>
> [0] https://github.com/systemd/systemd/blob/v256/NEWS#L265
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle <arnout@mind.be>
I don't really like how complicated the logic in system.mk is becoming, but I
don't have better ideas either.
Regards,
Arnout
> ---
> Makefile | 1 +
> package/skeleton-custom/skeleton-custom.mk | 3 ++-
> support/scripts/check-merged | 5 ++++-
> system/Config.in | 11 +++++++++++
> system/skeleton/usr/sbin/.empty | 0
> system/system.mk | 11 +++++++++++
> 6 files changed, 29 insertions(+), 2 deletions(-)
> delete mode 100644 system/skeleton/usr/sbin/.empty
>
> diff --git a/Makefile b/Makefile
> index 1248dfb9e0..477179dd64 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -786,6 +786,7 @@ endif
> support/scripts/check-merged \
> $(d) \
> $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
> )"; \
> test -n "$$not_merged_dirs" && { \
> echo "ERROR: The overlay in $(d) is not" \
> diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
> index e583d2d731..7f9f10b81d 100644
> --- a/package/skeleton-custom/skeleton-custom.mk
> +++ b/package/skeleton-custom/skeleton-custom.mk
> @@ -29,12 +29,13 @@ SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
> $(shell support/scripts/check-merged \
> $(SKELETON_CUSTOM_PATH) \
> $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
> )
>
> ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
> ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
> $(error The custom skeleton in $(SKELETON_CUSTOM_PATH) is not \
> - using a merged /usr for the following directories: \
> + using a merged structuren for the following directories: \
> $(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS))
> endif
> endif
> diff --git a/support/scripts/check-merged b/support/scripts/check-merged
> index 7fea4e1dea..0e51c032c5 100755
> --- a/support/scripts/check-merged
> +++ b/support/scripts/check-merged
> @@ -11,7 +11,7 @@
> #
> # Input:
> # $1: the root directory (skeleton, overlay) to check
> -# $*: the list of merged checks to perform: merged-usr
> +# $*: the list of merged checks to perform: merged-usr, merged-bin
> # Output:
> # stdout: the list of non-compliant paths (empty if compliant).
> #
> @@ -55,6 +55,9 @@ for what; do
> test_merged "${root}" "/bin" "/usr/bin"
> test_merged "${root}" "/sbin" "/usr/sbin"
> ;;
> + (merged-bin)
> + test_merged "${root}" "/usr/sbin" "/usr/bin"
> + ;;
> (*)
> printf 'Error: unknown type of test %s\n' "${what}"
> ;;
> diff --git a/system/Config.in b/system/Config.in
> index 2f42e5ddf9..5007f101e2 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -342,6 +342,16 @@ config BR2_ROOTFS_MERGED_USR
> symlinks to their counterparts in /usr. In this case, /usr can
> not be a separate filesystem.
>
> +config BR2_ROOTFS_MERGED_SBIN
> + bool "Merged /usr/sbin"
> + depends on BR2_ROOTFS_MERGED_USR
> + help
> + If you say 'n' here, then /usr/bin and /usr/sbin will be
> + separate directories; this is the historical UNIX way.
> +
> + If you say 'y' here, then /usr/sbin will be a relative
> + symlink to /usr/bin.
> +
> if BR2_ROOTFS_SKELETON_DEFAULT
>
> config BR2_TARGET_ENABLE_ROOT_LOGIN
> @@ -528,6 +538,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
>
> config BR2_SYSTEM_DEFAULT_PATH
> string "Set the system's default PATH"
> + default "/usr/bin" if BR2_ROOTFS_MERGED_SBIN
> default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
> default "/bin:/sbin:/usr/bin:/usr/sbin"
> help
> diff --git a/system/skeleton/usr/sbin/.empty b/system/skeleton/usr/sbin/.empty
> deleted file mode 100644
> index e69de29bb2..0000000000
> diff --git a/system/system.mk b/system/system.mk
> index 8fe2c138b0..530b26c162 100644
> --- a/system/system.mk
> +++ b/system/system.mk
> @@ -34,16 +34,27 @@
>
> # This function handles the merged or non-merged /usr cases
> ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> +ifeq ($(BR2_ROOTFS_MERGED_SBIN),y)
> +define SYSTEM_SBIN_SYMLINKS_OR_DIRS
> + ln -snf bin $(1)/usr/sbin
> +endef
> +else
> +define SYSTEM_SBIN_SYMLINKS_OR_DIRS
> + $(INSTALL) -d -m 0755 $(1)/usr/sbin
> +endef
> +endif
> define SYSTEM_USR_SYMLINKS_OR_DIRS
> ln -snf usr/bin $(1)/bin
> ln -snf usr/sbin $(1)/sbin
> ln -snf usr/lib $(1)/lib
> + $(SYSTEM_SBIN_SYMLINKS_OR_DIRS)
> endef
> else
> define SYSTEM_USR_SYMLINKS_OR_DIRS
> $(INSTALL) -d -m 0755 $(1)/bin
> $(INSTALL) -d -m 0755 $(1)/sbin
> $(INSTALL) -d -m 0755 $(1)/lib
> + $(INSTALL) -d -m 0755 $(1)/usr/sbin
> endef
> endif
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 09/13] package/systemd: require merged-bin
2025-05-14 16:58 ` [Buildroot] [PATCH 09/13] package/systemd: require merged-bin Yann E. MORIN
@ 2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
0 siblings, 0 replies; 29+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2025-05-17 10:38 UTC (permalink / raw)
To: Yann E. MORIN, buildroot; +Cc: Norbert Lange, Sen Hastings
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Since version 256, systemd will taint the system if /usr/bin and
> /usr/sbin are not merged, known as merged-bin. Although this is
> not yet an error, it will be in the future.
>
> To be as ready as we can be when that happens, forcibly enable
> merged-bin, like we did when we initially added merged-usr.
Except that this time we don't add a comment about it :-)
Acked-by: Arnout Vandecappelle <arnout@mind.be>
Regards,
Arnout
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Norbert Lange <nolange79@gmail.com>
> Cc: Sen Hastings <sen@hastings.org>
> ---
> package/systemd/Config.in | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index fd7671480c..5eaa092444 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -25,6 +25,7 @@ menuconfig BR2_PACKAGE_SYSTEMD
> depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
> depends on BR2_HOST_GCC_AT_LEAST_8 # host-systemd
> select BR2_ROOTFS_MERGED_USR
> + select BR2_ROOTFS_MERGED_SBIN
> select BR2_PACKAGE_HAS_UDEV
> select BR2_PACKAGE_DBUS if !BR2_PACKAGE_DBUS_BROKER # runtime
> select BR2_PACKAGE_LIBCAP
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs
2025-05-17 10:13 ` Arnout Vandecappelle via buildroot
@ 2025-05-17 15:02 ` Yann E. MORIN
0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-17 15:02 UTC (permalink / raw)
To: Arnout Vandecappelle; +Cc: buildroot
Arnout, All,
On 2025-05-17 12:13 +0200, Arnout Vandecappelle spake thusly:
> On 17/05/2025 09:59, Yann E. MORIN wrote:
> > On 2025-05-14 18:58 +0200, Yann E. MORIN spake thusly:
> > > Currently, we accept that the merged usr is bqckward, i.e. that the
> > > /usr/bin, /usr/sbin, and /usr/lib entries be symlinks to, resp., /bin,
> > > /sbin, and /lib. We also allow either entries to be symlinks to other
> > > parts of the root. Both are accepted despite the comment at the top of
> > > the script explaining what should be accepted.
> > >
> > > However, a properly merged usr is the other way around: /bin, /sbin, and
> > > /lib are the symlinks to resp. /usr/bin, /usr/sbin, and /usr/lib, and
> > > the latters are actual directories.
> > [--SNIP--]
> > > @@ -32,12 +29,21 @@ test_merged() {
> > > local dir2="${3}"
> > > local inode1 inode2
> > > + # OK if missing first entry and second entry is an actual directory
> > > + test -e "${root}${dir1}" || { test -d "${root}${dir2}" && return; }
> > > +
> > > inode1="$(stat -c '%i' "${root}${dir1}/." 2>/dev/null)"
> > > inode2="$(stat -c '%i' "${root}${dir2}/." 2>/dev/null)"
> > > - test -z "${inode1}" || \
> > > - test "${inode1}" = "${inode2}" || \
> > > - printf '%s\n' "${dir1}"
> > > + # OK if first entry is a symlink, second entry is a directoy, and
> > > + # both have the same inode (once dereferenced)
> > > + test -L "${root}${dir1}" \
> > > + && test -d "${root}${dir2}" \
> > > + && test "${inode1}" = "${inode2}" \
> > > + && return
> > > +
> > > + # Otherwise, this directory is not merged
> > > + printf '%s\n' "${dir1}"
> >
> > This new test is still quite complex, and is in fact still wrong in
> > weird cases. For example, with BASE a custom skeleton or rootfs overlay,
> > if BASE/sbin and BASE/usr/sbin ar absolute symlinks to /usr/sbin, the
> > test above will accept BASE as being properly merged, while it is in
> > fact broken.
> >
> > I'm preparing a v2 which greatly simplifies the test, and makes it cover
> > more (all, hopefully) cases.
>
> I guess the test should simply be:
>
> test -L "${root}${dir1}" \
> && test -d "${root}${dir2}" \
> && test "$(readlink "${root}${dir1}")" = "${dir2}" \
This test for the target of the symlink is wrong: if dir1 is bin, and
points to /usr/bin, then this is wrong: we really want relative
symlinks.
> && return
>
> (which is not actually simpler... except that you can remove all the stat stuff)
I'm going with an even simpler, more strict solution, that simply
implements word-for-word our requirements. Indeed, I just drop all the
stat stuff that could get things wrong.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check
2025-05-17 10:24 ` Arnout Vandecappelle via buildroot
@ 2025-05-17 15:07 ` Yann E. MORIN
0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-17 15:07 UTC (permalink / raw)
To: Arnout Vandecappelle; +Cc: buildroot
Arnout, All,
On 2025-05-17 12:24 +0200, Arnout Vandecappelle spake thusly:
> On 14/05/2025 18:58, Yann E. MORIN wrote:
> > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
[--SNIP--]
> > diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
> > index 7d64959711..e583d2d731 100644
> > --- a/package/skeleton-custom/skeleton-custom.mk
> > +++ b/package/skeleton-custom/skeleton-custom.mk
> > @@ -25,10 +25,11 @@ endif
> > # For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
> > # counterparts are appropriately setup as symlinks ones to the others.
> > -ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> > SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
> > - $(shell support/scripts/check-merged $(SKELETON_CUSTOM_PATH))
> > -endif # merged /usr
> > + $(shell support/scripts/check-merged \
> > + $(SKELETON_CUSTOM_PATH) \
> > + $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> > + )
>
> While you're anyway working on this: I think there's little point of doing
> this as a "preliminary" check, I think it's fine to do this check while
> "building" the custom skeleton (i.e. in
> SKELETON_CUSTOM_INSTALL_TARGET_CMDS).
>
> That would allow us to move the error message to the check-merged script
> itself, and let it return 1 in case it's not properly merged. And with that,
> both instances can simply call the script without capturing its output. It's
> going to save +-10 lines of code and make things easier to understand IMHO.
I was considering something in that spirit, so your suggesting it just
confirms that it is a good idea, and I'll look into doing that.
> > ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
> > ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
> > diff --git a/support/scripts/check-merged b/support/scripts/check-merged
> > index 9459d975fe..7fea4e1dea 100755
> > --- a/support/scripts/check-merged
> > +++ b/support/scripts/check-merged
> > @@ -11,12 +11,14 @@
> > #
> > # Input:
> > # $1: the root directory (skeleton, overlay) to check
> > +# $*: the list of merged checks to perform: merged-usr
>
> If you make this an option (i.e. --merged-usr), then we can replace $1 with
> a $* that covers all directories, and we can get rid of the foreach in
> Makefile's check of the overlays, and that code could simplify to:
>
> @$(call MESSAGE,"Sanity check in overlays)
> support/scripts/check-merged \
> $(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
> $(call qstrip,$(BR2_ROOTFS_OVERLAY))
>
> Of course, there's a risk that I'm overengineering things, so feel free to
> ignore my suggestions.
I also like it a bit better, indeed. Let's see what I can come up
with...
Thanks.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin)
2025-05-14 16:58 ` [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin) Yann E. MORIN
2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
@ 2025-05-17 16:52 ` Edgar Bonet via buildroot
2025-05-17 20:10 ` Yann E. MORIN
1 sibling, 1 reply; 29+ messages in thread
From: Edgar Bonet via buildroot @ 2025-05-17 16:52 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
Hello!
On 14/05/2025 18:58, Yann E. MORIN wrote:
> Starting with version 256 [0], systemd warns when /usr/bin and /usr/sbin
> are different directories; in the future, it may even refuse to boot in
> such a situation.
>
> Add support for merged-bin, not unlike we have support for merged-usr;
> we also make merged-bin a sub-case of merged-usr (i.e. it is not
> possible to do merged-bin without merged-usr).
>
> [0] https://github.com/systemd/systemd/blob/v256/NEWS#L265
>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
> Makefile | 1 +
> package/skeleton-custom/skeleton-custom.mk | 3 ++-
> support/scripts/check-merged | 5 ++++-
> system/Config.in | 11 +++++++++++
> system/skeleton/usr/sbin/.empty | 0
> system/system.mk | 11 +++++++++++
> 6 files changed, 29 insertions(+), 2 deletions(-)
> delete mode 100644 system/skeleton/usr/sbin/.empty
>
> diff --git a/Makefile b/Makefile
> index 1248dfb9e0..477179dd64 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -786,6 +786,7 @@ endif
> support/scripts/check-merged \
> $(d) \
> $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
> )"; \
> test -n "$$not_merged_dirs" && { \
> echo "ERROR: The overlay in $(d) is not" \
> diff --git a/package/skeleton-custom/skeleton-custom.mk b/package/skeleton-custom/skeleton-custom.mk
> index e583d2d731..7f9f10b81d 100644
> --- a/package/skeleton-custom/skeleton-custom.mk
> +++ b/package/skeleton-custom/skeleton-custom.mk
> @@ -29,12 +29,13 @@ SKELETON_CUSTOM_NOT_MERGED_USR_DIRS = \
> $(shell support/scripts/check-merged \
> $(SKELETON_CUSTOM_PATH) \
> $(if $(BR2_ROOTFS_MERGED_USR),merged-usr) \
> + $(if $(BR2_ROOTFS_MERGED_SBIN),merged-bin) \
> )
>
> ifeq ($(BR2_PACKAGE_SKELETON_CUSTOM)$(BR_BUILDING),yy)
> ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS),)
> $(error The custom skeleton in $(SKELETON_CUSTOM_PATH) is not \
> - using a merged /usr for the following directories: \
> + using a merged structuren for the following directories: \
Small typo: s/structuren/structure/
Regards,
Edgar Bonet.
> $(SKELETON_CUSTOM_NOT_MERGED_USR_DIRS))
> endif
> endif
> diff --git a/support/scripts/check-merged b/support/scripts/check-merged
> index 7fea4e1dea..0e51c032c5 100755
> --- a/support/scripts/check-merged
> +++ b/support/scripts/check-merged
> @@ -11,7 +11,7 @@
> #
> # Input:
> # $1: the root directory (skeleton, overlay) to check
> -# $*: the list of merged checks to perform: merged-usr
> +# $*: the list of merged checks to perform: merged-usr, merged-bin
> # Output:
> # stdout: the list of non-compliant paths (empty if compliant).
> #
> @@ -55,6 +55,9 @@ for what; do
> test_merged "${root}" "/bin" "/usr/bin"
> test_merged "${root}" "/sbin" "/usr/sbin"
> ;;
> + (merged-bin)
> + test_merged "${root}" "/usr/sbin" "/usr/bin"
> + ;;
> (*)
> printf 'Error: unknown type of test %s\n' "${what}"
> ;;
> diff --git a/system/Config.in b/system/Config.in
> index 2f42e5ddf9..5007f101e2 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -342,6 +342,16 @@ config BR2_ROOTFS_MERGED_USR
> symlinks to their counterparts in /usr. In this case, /usr can
> not be a separate filesystem.
>
> +config BR2_ROOTFS_MERGED_SBIN
> + bool "Merged /usr/sbin"
> + depends on BR2_ROOTFS_MERGED_USR
> + help
> + If you say 'n' here, then /usr/bin and /usr/sbin will be
> + separate directories; this is the historical UNIX way.
> +
> + If you say 'y' here, then /usr/sbin will be a relative
> + symlink to /usr/bin.
> +
> if BR2_ROOTFS_SKELETON_DEFAULT
>
> config BR2_TARGET_ENABLE_ROOT_LOGIN
> @@ -528,6 +538,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
>
> config BR2_SYSTEM_DEFAULT_PATH
> string "Set the system's default PATH"
> + default "/usr/bin" if BR2_ROOTFS_MERGED_SBIN
> default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
> default "/bin:/sbin:/usr/bin:/usr/sbin"
> help
> diff --git a/system/skeleton/usr/sbin/.empty b/system/skeleton/usr/sbin/.empty
> deleted file mode 100644
> index e69de29bb2..0000000000
> diff --git a/system/system.mk b/system/system.mk
> index 8fe2c138b0..530b26c162 100644
> --- a/system/system.mk
> +++ b/system/system.mk
> @@ -34,16 +34,27 @@
>
> # This function handles the merged or non-merged /usr cases
> ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> +ifeq ($(BR2_ROOTFS_MERGED_SBIN),y)
> +define SYSTEM_SBIN_SYMLINKS_OR_DIRS
> + ln -snf bin $(1)/usr/sbin
> +endef
> +else
> +define SYSTEM_SBIN_SYMLINKS_OR_DIRS
> + $(INSTALL) -d -m 0755 $(1)/usr/sbin
> +endef
> +endif
> define SYSTEM_USR_SYMLINKS_OR_DIRS
> ln -snf usr/bin $(1)/bin
> ln -snf usr/sbin $(1)/sbin
> ln -snf usr/lib $(1)/lib
> + $(SYSTEM_SBIN_SYMLINKS_OR_DIRS)
> endef
> else
> define SYSTEM_USR_SYMLINKS_OR_DIRS
> $(INSTALL) -d -m 0755 $(1)/bin
> $(INSTALL) -d -m 0755 $(1)/sbin
> $(INSTALL) -d -m 0755 $(1)/lib
> + $(INSTALL) -d -m 0755 $(1)/usr/sbin
> endef
> endif
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin)
2025-05-17 16:52 ` Edgar Bonet via buildroot
@ 2025-05-17 20:10 ` Yann E. MORIN
0 siblings, 0 replies; 29+ messages in thread
From: Yann E. MORIN @ 2025-05-17 20:10 UTC (permalink / raw)
To: Edgar Bonet; +Cc: buildroot
Edgar, All,
On 2025-05-17 18:52 +0200, Edgar Bonet spake thusly:
> On 14/05/2025 18:58, Yann E. MORIN wrote:
[--SNIP--]
> > + using a merged structuren for the following directories: \
> Small typo: s/structuren/structure/
Good catch, thanks!
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2025-05-17 20:10 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14 16:58 [Buildroot] [PATCH 00/13] system: add support for merged-bin (branch yem/merged-bin) Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 01/13] system: reword merged-usr prompt Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 02/13] system: drop superfluous negative condition for default PATH Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 03/13] package/systemd: select merged-usr from package, not init Yann E. MORIN
2025-05-17 10:07 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 04/13] support/scripts: comonalise checking merged status Yann E. MORIN
2025-05-17 10:08 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 05/13] support/scripts: fix and restrict conditions to accept merged dirs Yann E. MORIN
2025-05-17 7:59 ` Yann E. MORIN
2025-05-17 9:12 ` Arnout Vandecappelle via buildroot
2025-05-17 10:13 ` Arnout Vandecappelle via buildroot
2025-05-17 15:02 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 06/13] support/scripts: rename check-merged-usr.sh Yann E. MORIN
2025-05-17 10:35 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 07/13] support/scripts; teach check-merged what to check Yann E. MORIN
2025-05-17 10:24 ` Arnout Vandecappelle via buildroot
2025-05-17 15:07 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 08/13] system: add support for merged /usr/sbin (aka merged-bin) Yann E. MORIN
2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
2025-05-17 16:52 ` Edgar Bonet via buildroot
2025-05-17 20:10 ` Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 09/13] package/systemd: require merged-bin Yann E. MORIN
2025-05-17 10:38 ` Arnout Vandecappelle via buildroot
2025-05-14 16:58 ` [Buildroot] [PATCH 10/13] package/coreutils: no need for chroot workaround with merged-bin Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 11/13] package/kmod: adjust paths for merged-bin Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 12/13] package/util-linux: " Yann E. MORIN
2025-05-14 16:58 ` [Buildroot] [PATCH 13/13] toolchain/external: support merged-bin Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox