aboutsummaryrefslogtreecommitdiffstats
path: root/meta-initramfs
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2019-06-20 22:56:09 -0400
committerKhem Raj <raj.khem@gmail.com>2019-06-21 06:22:19 -0700
commit4d45ebe7ad77864bde2cbbadb3c7844aec106164 (patch)
treea2621b2fb5696788462d0fb262d4fcf3d091a5e7 /meta-initramfs
parentb3ae42d56e9a10b0866dfdc21a2aa6be8db8bf05 (diff)
downloadmeta-openembedded-contrib-4d45ebe7ad77864bde2cbbadb3c7844aec106164.tar.gz
dracut: fix generated initramfs boot failure under bash 5
If shebang is set to /bin/sh and /bin/sh is a symlink to /bin/bash, bash turn on posix mode. Since bash is upgraded to 5.0, it follows 'IEEE 1003.2 POSIX Shell Standard', to implement 'functions do not have local traps or options, and it is not possible to define local variables' For more detail, see variables.c:push_posix_temp_var in the following commit http://git.savannah.gnu.org/cgit/bash.git/commit/?id=d233b485e83c3a784b803fb894280773f16f2deb The IEEE 1003.2 POSIX Shell Standard: https://www.cs.ait.ac.th/~on/O/oreilly/unix/ksh/appa_02.htm Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-initramfs')
-rw-r--r--meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch69
-rw-r--r--meta-initramfs/recipes-devtools/dracut/dracut_git.bb1
2 files changed, 70 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch b/meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch
new file mode 100644
index 00000000000..13d2cfa8775
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch
@@ -0,0 +1,69 @@
+From 6e0da103effe64832eea52fad5c44a328f7141b7 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Thu, 20 Jun 2019 17:31:11 +0800
+Subject: [PATCH] set viriable _drv not local
+
+If shebang is set to /bin/sh and /bin/sh is a symlink to /bin/bash,
+bash turn on posix mode.
+
+Since bash is upgraded to 5.0, it follows 'IEEE 1003.2 POSIX Shell
+Standard', to implement 'functions do not have local traps or options,
+and it is not possible to define local variables'
+
+For more detail, see variables.c:push_posix_temp_var in the following commit
+http://git.savannah.gnu.org/cgit/bash.git/commit/?id=d233b485e83c3a784b803fb894280773f16f2deb
+
+The IEEE 1003.2 POSIX Shell Standard:
+https://www.cs.ait.ac.th/~on/O/oreilly/unix/ksh/appa_02.htm
+
+While /bin/sh points to bash 5.0, it caused the following issue:
+
+$ cat <<ENDOF>case.sh
+fsck_drv_com(){
+ echo "issuing \$_drv"
+}
+
+fsck_able() {
+ _drv="_drv=e2fsck fsck_drv_com"
+}
+
+fsck_single() {
+ local _drv
+ fsck_able
+ eval "\$_drv"
+}
+fsck_single
+ENDOF
+$ chmod a+x case.sh
+
+Unexpected:
+$ ./cash.sh
+issuing _drv=e2fsck fsck_drv_com
+
+Set viriable _drv not local, get expected result:
+$ ./case.sh
+issuing e2fsck
+
+Upstream-Status: Submitted [https://github.com/dracutdevs/dracut/pull/587]
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ modules.d/99fs-lib/fs-lib.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
+index d39ca1b..60877ee 100755
+--- a/modules.d/99fs-lib/fs-lib.sh
++++ b/modules.d/99fs-lib/fs-lib.sh
+@@ -142,7 +142,7 @@ fsck_single() {
+ local _fs="${2:-auto}"
+ local _fsopts="$3"
+ local _fop="$4"
+- local _drv
++ _drv=""
+
+ [ $# -lt 2 ] && return 255
+ # if UUID= marks more than one device, take only the first one
+--
+2.7.4
+
diff --git a/meta-initramfs/recipes-devtools/dracut/dracut_git.bb b/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
index 344dfecbbbf..13cf5f6ded7 100644
--- a/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
+++ b/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
@@ -13,6 +13,7 @@ SRCREV = "225e4b94cbdb702cf512490dcd2ad9ca5f5b22c1"
SRC_URI = "git://git.kernel.org/pub/scm/boot/dracut/dracut.git;protocol=http \
file://0001-util.h-include-sys-reg.h-when-libc-glibc.patch \
file://0001-dracut.sh-improve-udevdir.patch \
+ file://0001-set-viriable-_drv-not-local.patch \
"
DEPENDS += "kmod"