File initramfs-Going-forward-bin-or-sbin-are-mere-links-to-usr-cater-for-this.patch of Package warewulf

From: Egbert Eich <eich@suse.com>
Date: Sat Oct 9 10:50:49 2021 +0200
Subject: initramfs: Going forward, /bin or /sbin are mere links to /usr - cater for this
Patch-mainline: Not yet
Git-commit: 80dd992c331f88ab92a7c3591f0811a55a003b47
References: 

If the busybox installation hasn't installed symlinks in /[s]bin
if the initfs copy all busybox links from /usr/[s]bin. Make sure
there is a busybox binary (or link) under /bin.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 provision/initramfs/Makefile.am | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/provision/initramfs/Makefile.am b/provision/initramfs/Makefile.am
index cc032d4..262b971 100644
--- a/provision/initramfs/Makefile.am
+++ b/provision/initramfs/Makefile.am
@@ -132,6 +132,17 @@ rootfs: busybox e2fsprogs libarchive parted
 	else \
 		cp -av _work/$(BUSYBOX_DIR)/_install/* rootfs/ ;\
 	fi
+	if [ ! -L rootfs/bin/sh ]; then \
+		for i in `find rootfs/usr/bin -type l -a -lname "*busybox"`; do \
+			cp -av $$i rootfs/bin; \
+		done; \
+		for i in `find rootfs/usr/sbin -type l -a -lname "*busybox"`; do \
+			cp -av $$i rootfs/sbin; \
+		done; \
+		if [ ! -e rootfs/bin/busybox -o -L rootfs/bin/busybox ]; then \
+			test -e rootfs/usr/bin/busybox && ln -s /usr/bin/busybox rootfs/bin; \
+		fi; \
+	fi
 	if [ -n "@local_e2fsprogs_path@" -a -f "@local_e2fsprogs_path@" ]; then \
 		cp -av "@local_e2fsprogs_path@" rootfs/sbin/mkfs.ext4 ;\
 	else \
openSUSE Build Service is sponsored by