]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test(SKIPCPIO): check 3cpio for supported features
authorBenjamin Drung <benjamin.drung@canonical.com>
Sun, 28 Sep 2025 11:45:34 +0000 (13:45 +0200)
committerLaszlo <laszlo.gombos@gmail.com>
Sun, 28 Sep 2025 12:33:51 +0000 (08:33 -0400)
Ubuntu 24.04 ships 3cpio 0.5.1 which does not have `--create` and
`--parts`. So check 3cpio for these features and fall back to `cpio`.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1720
test/TEST-81-SKIPCPIO/test.sh

index 1bdeb1c8ebe74021c848baa5d596d283880a66db..9e458e0f6448d113923223ebf28dc3c514240524 100755 (executable)
@@ -7,8 +7,8 @@ set -eu
 TEST_DESCRIPTION="test skipcpio"
 
 test_check() {
-    if ! command -v 3cpio &> /dev/null && ! command -v cpio &> /dev/null; then
-        echo "Neither 3cpio nor cpio are available."
+    if ! 3cpio --help 2> /dev/null | grep -q -- --create && ! command -v cpio &> /dev/null; then
+        echo "Neither 3cpio >= 0.10 nor cpio are available."
         return 1
     fi
 
@@ -16,7 +16,7 @@ test_check() {
 }
 
 cpio_create() {
-    if command -v 3cpio &> /dev/null; then
+    if 3cpio --help 2> /dev/null | grep -q -- --create; then
         find . | sort | 3cpio --create
     else
         find . -print0 | sort -z | cpio -o --null -H newc
@@ -25,7 +25,7 @@ cpio_create() {
 
 cpio_list_first() {
     local file="$1"
-    if command -v 3cpio &> /dev/null; then
+    if 3cpio --help 2> /dev/null | grep -q -- --parts; then
         3cpio --list --parts 1 "$file"
     else
         cpio --extract --quiet --list < "$file"