]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(cpio): unit test regression from GNU cpio changes
authorDavid Disseldorp <ddiss@suse.de>
Mon, 22 Sep 2025 12:52:20 +0000 (14:52 +0200)
committerLaszlo <laszlo.gombos@gmail.com>
Thu, 25 Sep 2025 19:02:05 +0000 (15:02 -0400)
dracut-cpio unit tests compare binary archive output with that of GNU
cpio, for the same set of input files. A recent change to upstream GNU
cpio, commit 6a94d5e ("New option --ignore-dirnlink"), causes some tests
to fail.
The failure is due to GNU cpio `--reproducible` now hardcoding directory
nlink values to 2, instead of using the st_nlink value reported by
stat().

Fix the unit tests by dropping the GNU cpio `--reproducible` alias
parameter, and instead specify `--ignore-devno --renumber-inodes`
explicitly, matching pre-6a94d5e GNU cpio `--reproducible` behaviour.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1694
src/dracut-cpio/src/main.rs

index 89662fe4cfee349063ed92b44861e9b7167506a0..7d409c8fe5f944056f5a98fe325306a5d865077a 100644 (file)
@@ -939,7 +939,19 @@ mod tests {
 
     fn gnu_cpio_create(stdinput: &[u8], out: &str) {
         let mut proc = Command::new("cpio")
-            .args(&["--quiet", "-o", "-H", "newc", "--reproducible", "-F", out])
+            // As of GNU cpio commit 6a94d5e ("New option --ignore-dirnlink"),
+            // the --reproducible option hardcodes archived directory nlink
+            // values as 2. Omit it and use the dir.st_nlink value.
+            .args(&[
+                "--quiet",
+                "-o",
+                "-H",
+                "newc",
+                "--ignore-devno",
+                "--renumber-inodes",
+                "-F",
+                out,
+            ])
             .stdin(Stdio::piped())
             .spawn()
             .expect("GNU cpio failed to start");
@@ -1522,7 +1534,8 @@ mod tests {
                 "-o",
                 "-H",
                 "newc",
-                "--reproducible",
+                "--ignore-devno",
+                "--renumber-inodes",
                 "-F",
                 "gnu.cpio",
                 "--null",