From: Xiangyu Chen <[email protected]>

Signed-off-by: Xiangyu Chen <[email protected]>
---
 ...box-contains-init-use-it-in-containe.patch | 45 +++++++++++++++++++
 recipes-containers/lxc/lxc_git.bb             |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 
recipes-containers/lxc/files/0001-template-if-busybox-contains-init-use-it-in-containe.patch

diff --git 
a/recipes-containers/lxc/files/0001-template-if-busybox-contains-init-use-it-in-containe.patch
 
b/recipes-containers/lxc/files/0001-template-if-busybox-contains-init-use-it-in-containe.patch
new file mode 100644
index 0000000..760ebe6
--- /dev/null
+++ 
b/recipes-containers/lxc/files/0001-template-if-busybox-contains-init-use-it-in-containe.patch
@@ -0,0 +1,45 @@
+From 2789860daaa7780e1542bb1c60a89860e5661739 Mon Sep 17 00:00:00 2001
+From: Xiangyu Chen <[email protected]>
+Date: Wed, 1 Mar 2023 09:25:35 +0800
+Subject: [PATCH] template: if busybox contains init, use it in container
+
+The lxc test code using busybox template, some cases would be failed or hang 
+if the init progress not from busybox. This cause ptest report lots of failed.
+
+The changes is checking whether the busybox has built-in init, if it has,use 
it.
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Xiangyu Chen <[email protected]>
+---
+ templates/lxc-busybox.in | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
+index dab7c1faf..e2beae7a4 100755
+--- a/templates/lxc-busybox.in
++++ b/templates/lxc-busybox.in
+@@ -184,10 +184,16 @@ configure_busybox()
+       return 1
+   fi
+ 
+-  # copy bash binary as the container init
+-  if ! cp "$(which bash)" "${rootfs}/sbin/init"; then
+-      echo "ERROR: Failed to copy bash binary"
+-      return 1
++  # checking whether busybox has init or not
++  if ! ${rootfs}/bin/busybox --list | grep "init" > /dev/null; then
++      # copy bash binary as the container init
++      if ! cp "$(which bash)" "${rootfs}/sbin/init"; then
++          echo "ERROR: Failed to copy bash binary"
++          return 1
++      fi
++  else
++      # relink /sbin/init
++      ln "${rootfs}/bin/busybox" "${rootfs}/sbin/init"
+   fi
+ 
+ 
+-- 
+2.34.1
+
diff --git a/recipes-containers/lxc/lxc_git.bb 
b/recipes-containers/lxc/lxc_git.bb
index 7bc969e..073ed9c 100644
--- a/recipes-containers/lxc/lxc_git.bb
+++ b/recipes-containers/lxc/lxc_git.bb
@@ -44,6 +44,7 @@ SRC_URI = 
"git://github.com/lxc/lxc.git;branch=stable-5.0;protocol=https \
        file://templates-use-curl-instead-of-wget.patch \
        file://0001-download-don-t-try-compatbility-index.patch \
        file://tests-our-init-is-not-busybox.patch \
+       file://0001-template-if-busybox-contains-init-use-it-in-containe.patch \
        file://dnsmasq.conf \
        file://lxc-net \
        file://0001-Patching-an-incoming-CVE-CVE-2022-47952.patch \
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7909): 
https://lists.yoctoproject.org/g/meta-virtualization/message/7909
Mute This Topic: https://lists.yoctoproject.org/mt/97306619/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to