summary refs log tree commit diff
path: root/pkgs/build-support/kernel/cpio-clean.pl
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/kernel/cpio-clean.pl')
-rw-r--r--pkgs/build-support/kernel/cpio-clean.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkgs/build-support/kernel/cpio-clean.pl b/pkgs/build-support/kernel/cpio-clean.pl
new file mode 100644
index 000000000000..de38dee49f0d
--- /dev/null
+++ b/pkgs/build-support/kernel/cpio-clean.pl
@@ -0,0 +1,20 @@
+use strict;
+
+# Make inode number, link info and mtime consistent in order to get a consistent hash.
+#
+# Author: Alexander Kjeldaas <ak@formalprivacy.com>
+
+use Archive::Cpio;
+
+my $cpio = Archive::Cpio->new;
+my $IN = \*STDIN;
+my $ino = 1;
+$cpio->read_with_handler($IN, sub {
+        my ($e) = @_;
+        $e->{inode} = $ino;
+        $ino++;
+        $e->{nlink} = 1;
+        $e->{mtime} = 1;
+	$cpio->write_one(\*STDOUT, $e);
+    });
+$cpio->write_trailer(\*STDOUT);