mirror of
https://git.busybox.net/buildroot
synced 2025-12-20 01:10:56 +08:00
system: add support for merged /usr/sbin (aka merged-bin)
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 the support we have 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> Acked-by: TIAN Yuanhao <tianyuanhao3@163.com> Cc: Edgar Bonet <bonet@grenoble.cnrs.fr> Signed-off-by: Romain Naour <romain.naour@smile.fr>
This commit is contained in:
committed by
Romain Naour
parent
fc3cdc6d1e
commit
428ac6fcc4
1
Makefile
1
Makefile
@@ -785,6 +785,7 @@ endif
|
|||||||
support/scripts/check-merged \
|
support/scripts/check-merged \
|
||||||
--type overlay \
|
--type overlay \
|
||||||
$(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
|
$(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
|
||||||
|
$(if $(BR2_ROOTFS_MERGED_BIN),--merged-bin) \
|
||||||
$(call qstrip,$(BR2_ROOTFS_OVERLAY))
|
$(call qstrip,$(BR2_ROOTFS_OVERLAY))
|
||||||
|
|
||||||
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
|
$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ define SKELETON_CUSTOM_CONFIGURE_CMDS
|
|||||||
support/scripts/check-merged \
|
support/scripts/check-merged \
|
||||||
--type skeleton \
|
--type skeleton \
|
||||||
$(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
|
$(if $(BR2_ROOTFS_MERGED_USR),--merged-usr) \
|
||||||
|
$(if $(BR2_ROOTFS_MERGED_BIN),--merged-bin) \
|
||||||
$(SKELETON_CUSTOM_PATH)
|
$(SKELETON_CUSTOM_PATH)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Check if a given custom skeleton or overlay complies to the merged /usr
|
# Check if a given custom skeleton or overlay complies to the merged
|
||||||
# requirements:
|
# requirements:
|
||||||
|
#
|
||||||
|
# - for merged-usr:
|
||||||
# /bin missing, or a relative symlink to usr/bin
|
# /bin missing, or a relative symlink to usr/bin
|
||||||
# /lib missing, or a relative symlink to usr/lib
|
# /lib missing, or a relative symlink to usr/lib
|
||||||
# /sbin missing, or a relative symlink to usr/sbin
|
# /sbin missing, or a relative symlink to usr/sbin
|
||||||
@@ -11,9 +13,14 @@
|
|||||||
#
|
#
|
||||||
# *: must be present for skeletons, can be missing for overlays
|
# *: must be present for skeletons, can be missing for overlays
|
||||||
#
|
#
|
||||||
|
# - for merged-bin: all of the above, except:
|
||||||
|
# /usr/sbin missing, or a relative symlink to bin (thus points
|
||||||
|
# to /usr/bin)
|
||||||
|
#
|
||||||
# Input:
|
# Input:
|
||||||
# --type TYPE the type of root to check: 'skeleton' or 'overlay'
|
# --type TYPE the type of root to check: 'skeleton' or 'overlay'
|
||||||
# --merged-usr check for merged /usr
|
# --merged-usr check for merged /usr
|
||||||
|
# --merged-bin check for merged /usr/bin
|
||||||
# $*: the root directories (skeleton, overlays) to check
|
# $*: the root directories (skeleton, overlays) to check
|
||||||
# Output:
|
# Output:
|
||||||
# stdout: the list of non-compliant paths (empty if compliant).
|
# stdout: the list of non-compliant paths (empty if compliant).
|
||||||
@@ -22,12 +29,13 @@
|
|||||||
# !0: if any directory to check is improperly merged
|
# !0: if any directory to check is improperly merged
|
||||||
#
|
#
|
||||||
|
|
||||||
opts="type:,merged-usr"
|
opts="type:,merged-usr,merged-bin"
|
||||||
ARGS="$(getopt -n check-merged -o "" -l "${opts}" -- "${@}")" || exit 1
|
ARGS="$(getopt -n check-merged -o "" -l "${opts}" -- "${@}")" || exit 1
|
||||||
eval set -- "${ARGS}"
|
eval set -- "${ARGS}"
|
||||||
|
|
||||||
type=
|
type=
|
||||||
merged_usr=false
|
merged_usr=false
|
||||||
|
merged_bin=false
|
||||||
while :; do
|
while :; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
(--type)
|
(--type)
|
||||||
@@ -38,6 +46,10 @@ while :; do
|
|||||||
merged_usr=true
|
merged_usr=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
(--merged-bin)
|
||||||
|
merged_bin=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
(--)
|
(--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@@ -110,10 +122,14 @@ for root; do
|
|||||||
if ${merged_usr}; then
|
if ${merged_usr}; then
|
||||||
test_dir "${type}" "${root}" "/" "usr/bin"
|
test_dir "${type}" "${root}" "/" "usr/bin"
|
||||||
test_dir "${type}" "${root}" "/" "usr/lib"
|
test_dir "${type}" "${root}" "/" "usr/lib"
|
||||||
test_dir "${type}" "${root}" "/" "usr/sbin"
|
|
||||||
test_merged "${type}" "${root}" "/" "bin" "usr/bin"
|
test_merged "${type}" "${root}" "/" "bin" "usr/bin"
|
||||||
test_merged "${type}" "${root}" "/" "lib" "usr/lib"
|
test_merged "${type}" "${root}" "/" "lib" "usr/lib"
|
||||||
test_merged "${type}" "${root}" "/" "sbin" "usr/sbin"
|
test_merged "${type}" "${root}" "/" "sbin" "usr/sbin"
|
||||||
|
if ${merged_bin}; then
|
||||||
|
test_merged "${type}" "${root}" "/usr/" "sbin" "bin"
|
||||||
|
else
|
||||||
|
test_dir "${type}" "${root}" "/" "usr/sbin"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -343,6 +343,16 @@ config BR2_ROOTFS_MERGED_USR
|
|||||||
symlinks to their counterparts in /usr. In this case, /usr can
|
symlinks to their counterparts in /usr. In this case, /usr can
|
||||||
not be a separate filesystem.
|
not be a separate filesystem.
|
||||||
|
|
||||||
|
config BR2_ROOTFS_MERGED_BIN
|
||||||
|
bool "Merged /usr/bin"
|
||||||
|
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
|
if BR2_ROOTFS_SKELETON_DEFAULT
|
||||||
|
|
||||||
config BR2_TARGET_ENABLE_ROOT_LOGIN
|
config BR2_TARGET_ENABLE_ROOT_LOGIN
|
||||||
@@ -529,6 +539,7 @@ endif # BR2_ROOTFS_SKELETON_DEFAULT
|
|||||||
|
|
||||||
config BR2_SYSTEM_DEFAULT_PATH
|
config BR2_SYSTEM_DEFAULT_PATH
|
||||||
string "Set the system's default PATH"
|
string "Set the system's default PATH"
|
||||||
|
default "/usr/bin" if BR2_ROOTFS_MERGED_BIN
|
||||||
default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
|
default "/usr/bin:/usr/sbin" if BR2_ROOTFS_MERGED_USR
|
||||||
default "/bin:/sbin:/usr/bin:/usr/sbin"
|
default "/bin:/sbin:/usr/bin:/usr/sbin"
|
||||||
help
|
help
|
||||||
|
|||||||
@@ -32,18 +32,30 @@
|
|||||||
# set inittab to remount root read-write or read-only
|
# set inittab to remount root read-write or read-only
|
||||||
#
|
#
|
||||||
|
|
||||||
# This function handles the merged or non-merged /usr cases
|
# This function handles the merged or non-merged /usr, and merged or
|
||||||
|
# non-merged /usr/bin cases
|
||||||
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
|
ifeq ($(BR2_ROOTFS_MERGED_USR),y)
|
||||||
|
ifeq ($(BR2_ROOTFS_MERGED_BIN),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
|
define SYSTEM_USR_SYMLINKS_OR_DIRS
|
||||||
ln -snf usr/bin $(1)/bin
|
ln -snf usr/bin $(1)/bin
|
||||||
ln -snf usr/sbin $(1)/sbin
|
ln -snf usr/sbin $(1)/sbin
|
||||||
ln -snf usr/lib $(1)/lib
|
ln -snf usr/lib $(1)/lib
|
||||||
|
$(SYSTEM_SBIN_SYMLINKS_OR_DIRS)
|
||||||
endef
|
endef
|
||||||
else
|
else
|
||||||
define SYSTEM_USR_SYMLINKS_OR_DIRS
|
define SYSTEM_USR_SYMLINKS_OR_DIRS
|
||||||
$(INSTALL) -d -m 0755 $(1)/bin
|
$(INSTALL) -d -m 0755 $(1)/bin
|
||||||
$(INSTALL) -d -m 0755 $(1)/sbin
|
$(INSTALL) -d -m 0755 $(1)/sbin
|
||||||
$(INSTALL) -d -m 0755 $(1)/lib
|
$(INSTALL) -d -m 0755 $(1)/lib
|
||||||
|
$(INSTALL) -d -m 0755 $(1)/usr/sbin
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user