From 18859afb02ca0b78a0307f86b0eac7fb06b89310 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 13 Aug 2021 15:24:52 +0200 Subject: [busybox] compat: /bin/ash in NEWROOT --- modules.d/busybox/install-busybox-stage4.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules.d/busybox/install-busybox-stage4.sh b/modules.d/busybox/install-busybox-stage4.sh index 03071773..bcd1f94d 100644 --- a/modules.d/busybox/install-busybox-stage4.sh +++ b/modules.d/busybox/install-busybox-stage4.sh @@ -1,18 +1,26 @@ #!/bin/bash if hash busybox; then - # check if the stage4 has a busybox in the same location - # as within the initramfs. If so, we keep it and just hope - # that everything works out and that the apps are symlinked. - # Otherwise we copy it and activate applets in /opt/openslx/{s,}/bin - bb_path="$(type -p busybox)" - if [ -n "$bb_path" ] && [ ! -x "${NEWROOT}/opt/openslx/bin/busybox" ]; then + # copy busybox to NEWROOT unless one exists at the expected path. + bb_target_path="/opt/openslx/bin/busybox" + bb_source_path="$(type -p busybox)" + + if [ -n "$bb_source_path" ] && [ ! -x "${NEWROOT}${bb_target_path}" ]; then mkdir -p "${NEWROOT}"/opt/openslx/{s,}bin - cp -f "$bb_path" "${NEWROOT}/opt/openslx/bin/busybox" + cp -f "$bb_source_path" "${NEWROOT}${bb_target_path}" # --list-full gives {s,}bin prefixes for app in $(busybox --list-full); do - ln -s "/opt/openslx/bin/busybox" "${NEWROOT}/opt/openslx/$app" + ln -s "$bb_target_path" "${NEWROOT}/opt/openslx/$app" done fi + # compat: /bin/ash if not exists + if [ ! -e "${NEWROOT}/bin/ash" ]; then + # either dead symlink or nothing there. + ln -sf "$bb_target_path" "${NEWROOT}/bin/ash" + else + # either valid symlink or binary, log it and ignore. + type -p warn &>/dev/null || . /lib/dracut-lib.sh + warn "'/bin/ash' is a valid symlink or binary, ignoring." + fi fi true -- cgit v1.2.3-55-g7522