From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Tue, 18 Nov 2025 19:34:52 +0100
Subject: test: replace rev command by sed

On Debian-based systems, the `rev` command is shipped by the
bsdextrautils package. Replace the `rev` command by `sed` which is an
essential command and does not need additional packages.

Forwarded: https://github.com/dracut-ng/dracut-ng/pull/1856
---
 test/container/Dockerfile-debian | 1 -
 test/run-qemu                    | 2 +-
 test/test-functions              | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/container/Dockerfile-debian b/test/container/Dockerfile-debian
index a97caad..5a6a1eb 100644
--- a/test/container/Dockerfile-debian
+++ b/test/container/Dockerfile-debian
@@ -28,7 +28,6 @@ RUN \
     DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -o Dpkg::Use-Pty=0 \
     asciidoctor \
     bluez \
-    bsdextrautils \
     btrfs-progs \
     ca-certificates \
     cargo \
diff --git a/test/run-qemu b/test/run-qemu
index b957018..cf110d3 100755
--- a/test/run-qemu
+++ b/test/run-qemu
@@ -138,7 +138,7 @@ ARGS+=("$@")
 # only set -kernel if -initrd is specified
 initrd=$(get_initrd "${ARGS[@]}")
 if [[ -n $initrd ]]; then
-    KVERSION=$(lsinitrd "$initrd" | grep modules.dep | head -1 | rev | cut -d'/' -f2 | rev)
+    KVERSION=$(lsinitrd "$initrd" | grep modules.dep | head -1 | sed 's;.*/\([^/]\+\)/modules.dep;\1;')
     set_vmlinux_env
     ARGS+=(-kernel "$VMLINUZ")
     add_to_append "console=${console:-ttyS0},115200"
diff --git a/test/test-functions b/test/test-functions
index c0c55bc..5b8d6fc 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -133,7 +133,7 @@ command -v test_cleanup &> /dev/null || test_cleanup() {
 }
 
 determine_kernel_version() {
-    lsinitrd "$1" | grep modules.dep | head -1 | rev | cut -d'/' -f2 | rev
+    lsinitrd "$1" | grep modules.dep | head -1 | sed 's;.*/\([^/]\+\)/modules.dep;\1;'
 }
 
 determine_kernel_image() {
