fix(dracut.sh): handle --kmoddir with trailing /

https://github.com/dracutdevs/dracut/pull/2237

Resolves: #2173100
This commit is contained in:
Pavel Valena 2023-02-24 19:48:28 +01:00
parent 05988c6a16
commit 61fb1e8e40
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From 6fb0f4b4d54eeb1b1e89c06cc54bdcab504138da Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Fri, 24 Feb 2023 19:19:59 +0100
Subject: [PATCH] fix(dracut.sh): kmoddir does not handle trailing /
Fixes https://github.com/dracutdevs/dracut/issues/2236
+(/) only works in bash interactive mode. Using any non-interactive
bash run simply doesn't remove anything.
The solution is copied from dracut-lib.sh, trim().
---
dracut.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut.sh b/dracut.sh
index 1aa3f8e1f..0c0f85c2d 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -1033,7 +1033,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
((stdloglvl < 0)) && stdloglvl=0
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
-drivers_dir="${drivers_dir%%+(/)}"
+drivers_dir="${drivers_dir%"${drivers_dir##*[!/]}"}"
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $do_strip ]] || do_strip=yes
[[ $aggressive_strip_l ]] && aggressive_strip=$aggressive_strip_l

View File

@ -7,7 +7,7 @@
%global __requires_exclude pkg-config
# rpmdev-bumpspec and releng automation compatible variable
%global baserelease 2
%global baserelease 3
Name: dracut
Version: 059
@ -44,6 +44,10 @@ Patch3: 2218-add-module-driver-support-for-macbook-keyboards.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2172269#c3
Patch4: 1934-revert-add-overlayfs-module.patch
# Fix: dracut --kmoddir fails on paths with traling /
# https://bugzilla.redhat.com/show_bug.cgi?id=2173100
Patch5: 2237-kmoddir-fix-trailing-forwardslash-handling.patch
BuildRequires: bash
BuildRequires: git-core
BuildRequires: pkgconfig(libkmod) >= 23
@ -449,6 +453,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%changelog
* Fri Feb 24 2023 Pavel Valena <pvalena@redhat.com> - 059-3
- fix(dracut.sh): handle --kmoddir with trailing /
* Tue Feb 21 2023 Pavel Valena <pvalena@redhat.com> - 059-2
- Revert: PR#1934 add overlayfs module