]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test(SKIPCPIO): support 3cpio
authorBenjamin Drung <benjamin.drung@canonical.com>
Thu, 25 Sep 2025 10:35:00 +0000 (12:35 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sat, 27 Sep 2025 22:46:16 +0000 (18:46 -0400)
Support using 3cpio in the skipcpio test to allow not having `cpio`
installed.

test/TEST-81-SKIPCPIO/test.sh

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