about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-04-06 17:02:16 -0400
committerShea Levy <shea@shealevy.com>2014-04-06 17:02:16 -0400
commit9949d0255e8cf7ad9be455fecc9dd2c5211b70d7 (patch)
treedfce04f7b8bd0b32283265c55580015516818369 /pkgs/build-support
parent4b57acece18be9ee5d86349500f6afe01e3da3bd (diff)
parentf67015cae49400eba539b9ec8b9920643581c77c (diff)
downloadnixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar.gz
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar.bz2
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar.lz
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar.xz
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.tar.zst
nixlib-9949d0255e8cf7ad9be455fecc9dd2c5211b70d7.zip
Merge branch 'make-the-kernel-build-repeatable' of git://github.com/alexanderkjeldaas/nixpkgs
Make the kernel build and initrd generation binary repeatable (#2128)
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/kernel/cpio-clean.pl20
-rw-r--r--pkgs/build-support/kernel/make-initrd.nix5
-rw-r--r--pkgs/build-support/kernel/make-initrd.sh2
3 files changed, 24 insertions, 3 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);
diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix
index 4ddf0706e03e..0582ca553012 100644
--- a/pkgs/build-support/kernel/make-initrd.nix
+++ b/pkgs/build-support/kernel/make-initrd.nix
@@ -12,10 +12,10 @@
 # `contents = {object = ...; symlink = /init;}' is a typical
 # argument.
 
-{stdenv, perl, cpio, contents, ubootChooser, compressor}:
+{stdenv, perl, perlArchiveCpio, cpio, contents, ubootChooser, compressor}:
 
 let
-  inputsFun = ubootName : [perl cpio]
+  inputsFun = ubootName : [perl cpio perlArchiveCpio ]
     ++ stdenv.lib.optional (ubootName != null) [ (ubootChooser ubootName) ];
   makeUInitrdFun = ubootName : (ubootName != null);
 in
@@ -35,6 +35,7 @@ stdenv.mkDerivation {
   exportReferencesGraph =
     map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents;
   pathsFromGraph = ./paths-from-graph.pl;
+  cpioClean = ./cpio-clean.pl;
 
   crossAttrs = {
     nativeBuildInputs = inputsFun stdenv.cross.platform.uboot;
diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh
index f6cadaf02819..17b261f98407 100644
--- a/pkgs/build-support/kernel/make-initrd.sh
+++ b/pkgs/build-support/kernel/make-initrd.sh
@@ -36,7 +36,7 @@ storePaths=$(perl $pathsFromGraph closure-*)
 
 # Put the closure in a gzipped cpio archive.
 mkdir -p $out
-(cd root && find * -print0 | cpio -o -H newc --null | $compressor > $out/initrd)
+(cd root && find * -print0 | cpio -o -H newc --null | perl $cpioClean | $compressor > $out/initrd)
 
 if [ -n "$makeUInitrd" ]; then
     mv $out/initrd $out/initrd.gz