diff options
Diffstat (limited to 'meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch')
-rw-r--r-- | meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch | 69 |
1 files changed, 69 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 000000000..13d2cfa87 --- /dev/null +++ b/meta-initramfs/recipes-devtools/dracut/dracut/0001-set-viriable-_drv-not-local.patch | |||
@@ -0,0 +1,69 @@ | |||
1 | From 6e0da103effe64832eea52fad5c44a328f7141b7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Thu, 20 Jun 2019 17:31:11 +0800 | ||
4 | Subject: [PATCH] set viriable _drv not local | ||
5 | |||
6 | If shebang is set to /bin/sh and /bin/sh is a symlink to /bin/bash, | ||
7 | bash turn on posix mode. | ||
8 | |||
9 | Since bash is upgraded to 5.0, it follows 'IEEE 1003.2 POSIX Shell | ||
10 | Standard', to implement 'functions do not have local traps or options, | ||
11 | and it is not possible to define local variables' | ||
12 | |||
13 | For more detail, see variables.c:push_posix_temp_var in the following commit | ||
14 | http://git.savannah.gnu.org/cgit/bash.git/commit/?id=d233b485e83c3a784b803fb894280773f16f2deb | ||
15 | |||
16 | The IEEE 1003.2 POSIX Shell Standard: | ||
17 | https://www.cs.ait.ac.th/~on/O/oreilly/unix/ksh/appa_02.htm | ||
18 | |||
19 | While /bin/sh points to bash 5.0, it caused the following issue: | ||
20 | |||
21 | $ cat <<ENDOF>case.sh | ||
22 | fsck_drv_com(){ | ||
23 | echo "issuing \$_drv" | ||
24 | } | ||
25 | |||
26 | fsck_able() { | ||
27 | _drv="_drv=e2fsck fsck_drv_com" | ||
28 | } | ||
29 | |||
30 | fsck_single() { | ||
31 | local _drv | ||
32 | fsck_able | ||
33 | eval "\$_drv" | ||
34 | } | ||
35 | fsck_single | ||
36 | ENDOF | ||
37 | $ chmod a+x case.sh | ||
38 | |||
39 | Unexpected: | ||
40 | $ ./cash.sh | ||
41 | issuing _drv=e2fsck fsck_drv_com | ||
42 | |||
43 | Set viriable _drv not local, get expected result: | ||
44 | $ ./case.sh | ||
45 | issuing e2fsck | ||
46 | |||
47 | Upstream-Status: Submitted [https://github.com/dracutdevs/dracut/pull/587] | ||
48 | |||
49 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
50 | --- | ||
51 | modules.d/99fs-lib/fs-lib.sh | 2 +- | ||
52 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
53 | |||
54 | diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh | ||
55 | index d39ca1b..60877ee 100755 | ||
56 | --- a/modules.d/99fs-lib/fs-lib.sh | ||
57 | +++ b/modules.d/99fs-lib/fs-lib.sh | ||
58 | @@ -142,7 +142,7 @@ fsck_single() { | ||
59 | local _fs="${2:-auto}" | ||
60 | local _fsopts="$3" | ||
61 | local _fop="$4" | ||
62 | - local _drv | ||
63 | + _drv="" | ||
64 | |||
65 | [ $# -lt 2 ] && return 255 | ||
66 | # if UUID= marks more than one device, take only the first one | ||
67 | -- | ||
68 | 2.7.4 | ||
69 | |||