Summary: | sys-kernel/dracut-049 drops to shell with /lib/fs-lib.sh: line 109: _drv=e2fsck fsck_drv_com: command not found | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Vadim Dyadkin <gentoo> |
Component: | Current packages | Assignee: | Patrick McLean <chutzpah> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alexander, chewi, Dessa, floppym, gentoo, julien.sanchez, mark, mmokrejs, phantom4 |
Priority: | Normal | Keywords: | PullRequest |
Version: | unspecified | ||
Hardware: | AMD64 | ||
OS: | Linux | ||
See Also: | https://github.com/gentoo/gentoo/pull/14127 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 676344 | ||
Bug Blocks: | |||
Attachments: |
test.sh
test2.sh test2.sh Use bash for init rather than sh so bashisms work |
Description
Vadim Dyadkin
2019-01-26 11:14:52 UTC
It doesn't seem like the dracut code has changed much recently. Does this work in earlier versions of dracut? Created attachment 562912 [details]
test.sh
This is a problem with POSIX mode in bash-5.0:
dash:
$ dash test.sh
issuing echo hello
hello world
bash-4.3:
$ bash test.sh
issuing echo hello
hello world
$ bash --posix test.sh
issuing echo hello
hello world
bash-5.0:
$ bash test.sh
issuing echo hello
hello world
$ bash --posix test.sh
issuing _drv=echo fsck_drv_com hello
test.sh: line 10: _drv=echo: command not found
Note: when bash is called via /bin/sh symlink, then POSIX mode is enabled. (In reply to Alexander Tsoy from comment #2) > Created attachment 562912 [details] > test.sh After commenting out "local _drv" in fsck_single(), with bash-5.0: $ bash test.sh issuing echo hello hello world $ bash --posix test.sh issuing echo hello hello world Created attachment 562914 [details]
test2.sh
Minimal test case.
$ bash test2.sh
foo: hello world
bar: hello world
$ bash --posix test2.sh
bar: hello world
Created attachment 562916 [details]
test2.sh
This should better demonstrate what's going on:
$ bash --posix test2.sh
foo: bye bye
bar: hello world
$ bash test2.sh
foo: hello world
bar: hello world
(In reply to Mike Gilbert from comment #1) > It doesn't seem like the dracut code has changed much recently. > > Does this work in earlier versions of dracut? No, it started to happen like a week ago, after a typical "emerge -uDN world". When it started on I second computer, I got worried. (In reply to Alexander Tsoy from comment #6) > Created attachment 562916 [details] > test2.sh > > This should better demonstrate what's going on: Do I still need to test it with earlier versions of dracut as Mike suggested? Or the problem is clearly in bash? I just hit the same issue after updating the system and getting bash 5. I found a patch used by Void Linux: https://raw.githubusercontent.com/void-linux/void-packages/fdeed0979a8f63e380d7b8cba24fa0eb2d6f5c7f/srcpkgs/dracut/patches/fix-bash-5.patch I applied it to dracut 049 and after that the boot process works fine. (In reply to Vadim Dyadkin from comment #8) No need to test older dracut versions. I had the same error. I found the following Debian bug report which has some more info. I applied the one-line fix locally ("3rd option" as suggested in the Debian bug) and it worked for me. YMMV https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920563 > The 3rd option could be easily accomplished by adding the following line > to the top of /init (/usr/lib/dracut/modules.d/99base/init.sh) after the > initial comment block: > > [ -f /bin/bash ] && [ "$BASH" = "/bin/sh" ] && exec /bin/bash /init Have same problem after dracut and bash-5.0_p2 upgrade. It would be helpful if someone would report this to dracut upstream, since bash-5.0 is not going to be "fixed". Maybe Alexander can send a patch with rationale? Created attachment 565024 [details, diff]
Use bash for init rather than sh so bashisms work
(In reply to Mark Wagner from comment #14) > Created attachment 565024 [details, diff] [details, diff] > Use bash for init rather than sh so bashisms work :) From a brief examination of the source code dracut is full of bashisms and other shells have given in and implemented them (in various ways because there is no standard.) The most egregious is local variables which dracut uses heavily. Other shells have implemented local in kinda the same way which leads to problems on edge cases. See http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_09_18 "Local variables within a function were considered and included in another early proposal (controlled by the special built-in local), but were removed because they do not fit the simple model developed for functions and because there was some opposition to adding yet another new special built-in that was not part of historical practice." See however http://austingroupbugs.net/view.php?id=767 Send patches upstream. (In reply to Mike Gilbert from comment #16) > Send patches upstream. I didn't send my patch upstream but I did create a bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1676988 (In reply to Mike Gilbert from comment #13) > Maybe Alexander can send a patch with rationale? Sorry, I was on vacation. I'll look into it this week if I have time. Please block >=app-shells/bash-5.0 from within sys-kernel/dracut-049 until a fix lands portage tree. (In reply to Martin Mokrejš from comment #19) > Please block >=app-shells/bash-5.0 from within sys-kernel/dracut-049 until a > fix lands portage tree. I hesitate to do that because only a subset of dracut users are affected. Anyone using the systemd module does not run into the problem. Please try with app-shells/bash-5.0_p3-r1 (In reply to Alexander Tsoy from comment #21) > Please try with app-shells/bash-5.0_p3-r1 That fixed it for me! (In reply to Alexander Tsoy from comment #21) > Please try with app-shells/bash-5.0_p3-r1 Fixed for me too. The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=980830b7e4a2953550338f13dd8525bcad28d8fc commit 980830b7e4a2953550338f13dd8525bcad28d8fc Author: Alexander Tsoy <alexander@tsoy.me> AuthorDate: 2019-12-26 14:26:15 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2019-12-29 19:36:23 +0000 sys-kernel/dracut: Add a bunch of upstream patches * fix dracut-install crashes * install kernel module dependencies of dependencies * add support for compressed firmware files * add support for rngd service * bash-5 compatibility * add fts-standalone dependency and configure check for musl * fix udevdir detection Closes: https://bugs.gentoo.org/676268 Closes: https://bugs.gentoo.org/677788 Closes: https://bugs.gentoo.org/687602 Bug: https://bugs.gentoo.org/703438 Signed-off-by: Alexander Tsoy <alexander@tsoy.me> Signed-off-by: Mike Gilbert <floppym@gentoo.org> sys-kernel/dracut/dracut-049-r3.ebuild | 176 +++++++++++++++++++++ ...gure-find-cflags-and-libs-for-fts-on-musl.patch | 97 ++++++++++++ ...t-create-locking-directory-run-cryptsetup.patch | 32 ++++ ...all-Support-the-compressed-firmware-files.patch | 63 ++++++++ .../049-dracut.sh-Fix-udevdir-detection.patch | 38 +++++ .../dracut/files/049-fs-lib-drop-a-bashism.patch | 99 ++++++++++++ ...cut-install.c-install-module-dependencies.patch | 79 +++++++++ ...ing_hash_func-should-not-be-fed-with-NULL.patch | 38 +++++ ...g-the-systemdutildir-variable-before-it-s.patch | 55 +++++++ ...ager-call-the-online-hook-for-connected-d.patch | 32 ++++ ...ager-fix-getting-of-ifname-from-the-sysfs.patch | 37 +++++ ...rk-manager-remove-useless-use-of-basename.patch | 26 +++ ...dule-running-early-during-boot-to-help-ge.patch | 88 +++++++++++ 13 files changed, 860 insertions(+) |