make-initrd-ng: fix reproducibility problems

The previous find invocation didn't match the root directory, so the
root directory's access and modification time wasn't set to a
deterministic value and the build time leaked into the output.

`make-initrd` replaced `cpio` with `bsdtar` in #165892 because the
former includes the number of hardlinks in the created archive, which
depends on the filesystem (and can also be influenced by `nix-store
--optimise`). The same problem applies to `make-initrd-ng`, so this
commit replaces `cpio` with `libarchive`'s `bsdtar`.

+4 -4
+4 -4
pkgs/build-support/kernel/make-initrd-ng.nix
··· 8 # compression type and filename extension. 9 compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1; 10 in 11 - { stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, binutils, runCommand 12 # Name of the derivation (not of the resulting file!) 13 , name ? "initrd" 14 ··· 74 passAsFile = ["contents"]; 75 contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${lib.optionalString (symlink != null) symlink}") contents + "\n"; 76 77 - nativeBuildInputs = [makeInitrdNGTool cpio] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils; 78 79 STRIP = if strip then "${pkgsBuildHost.binutils.targetPrefix}strip" else null; 80 }) '' 81 mkdir -p ./root/var/empty 82 make-initrd-ng "$contentsPath" ./root 83 mkdir "$out" 84 - (cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +) 85 for PREP in $prepend; do 86 cat $PREP >> $out/initrd 87 done 88 - (cd root && find . -print0 | sort -z | cpio -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd") 89 90 if [ -n "$makeUInitrd" ]; then 91 mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img
··· 8 # compression type and filename extension. 9 compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1; 10 in 11 + { stdenvNoCC, libarchive, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, binutils, runCommand 12 # Name of the derivation (not of the resulting file!) 13 , name ? "initrd" 14 ··· 74 passAsFile = ["contents"]; 75 contents = lib.concatMapStringsSep "\n" ({ object, symlink, ... }: "${object}\n${lib.optionalString (symlink != null) symlink}") contents + "\n"; 76 77 + nativeBuildInputs = [makeInitrdNGTool libarchive] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils; 78 79 STRIP = if strip then "${pkgsBuildHost.binutils.targetPrefix}strip" else null; 80 }) '' 81 mkdir -p ./root/var/empty 82 make-initrd-ng "$contentsPath" ./root 83 mkdir "$out" 84 + (cd root && find . -exec touch -h -d '@1' '{}' +) 85 for PREP in $prepend; do 86 cat $PREP >> $out/initrd 87 done 88 + (cd root && find . -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @- | eval -- $compress >> "$out/initrd") 89 90 if [ -n "$makeUInitrd" ]; then 91 mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img