Skip to content

Commit 0f216e2

Browse files
committed
tree-wide: switch initrd generators back to gnu cpio
Originally, we switched to bsdtar from libarchive to solve a reproducibility issue related to hardlinks As of gnu cpio 2.14 the --ignore-dirnlink option is introduced and now included in --reproducible, which solves this issue By switching back, we are in turn solving an issue in libarchive >=3.7.5 erroring out with "Error reading archive -: (null)" Change-Id: Ib6140d599b6547d8e941b0251ce996e303c41fa6
1 parent faf294a commit 0f216e2

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

nixos/modules/system/boot/stage-1.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ let
405405
${lib.optionalString (config.boot.initrd.secrets == {})
406406
"exit 0"}
407407
408-
export PATH=${pkgs.coreutils}/bin:${pkgs.libarchive}/bin:${pkgs.gzip}/bin:${pkgs.findutils}/bin
408+
export PATH=${pkgs.coreutils}/bin:${pkgs.cpio}/bin:${pkgs.gzip}/bin:${pkgs.findutils}/bin
409409
410410
function cleanup {
411411
if [ -n "$tmp" -a -d "$tmp" ]; then
@@ -426,7 +426,7 @@ let
426426
}
427427
428428
# mindepth 1 so that we don't change the mode of /
429-
(cd "$tmp" && find . -mindepth 1 | xargs touch -amt 197001010000 && find . -mindepth 1 -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @-) | \
429+
(cd "$tmp" && find . -mindepth 1 | xargs touch -amt 197001010000 && find . -mindepth 1 -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null) | \
430430
${compressorExe} ${lib.escapeShellArgs initialRamdisk.compressorArgs} >> "$1"
431431
'';
432432

pkgs/build-support/kernel/make-initrd-ng.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let
88
# compression type and filename extension.
99
compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1;
1010
in
11-
{ stdenvNoCC, libarchive, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, binutils, runCommand
11+
{ stdenvNoCC, cpio, ubootTools, lib, pkgsBuildHost, makeInitrdNGTool, binutils, runCommand
1212
# Name of the derivation (not of the resulting file!)
1313
, name ? "initrd"
1414

@@ -74,7 +74,7 @@ in
7474
passAsFile = ["contents"];
7575
contents = builtins.toJSON contents;
7676

77-
nativeBuildInputs = [makeInitrdNGTool libarchive] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils;
77+
nativeBuildInputs = [makeInitrdNGTool cpio] ++ lib.optional makeUInitrd ubootTools ++ lib.optional strip binutils;
7878

7979
STRIP = if strip then "${pkgsBuildHost.binutils.targetPrefix}strip" else null;
8080
}) ''
@@ -85,7 +85,7 @@ in
8585
for PREP in $prepend; do
8686
cat $PREP >> $out/initrd
8787
done
88-
(cd root && find . -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @- | eval -- $compress >> "$out/initrd")
88+
(cd root && find . -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd")
8989
9090
if [ -n "$makeUInitrd" ]; then
9191
mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img

pkgs/build-support/kernel/make-initrd.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let
1818
# compression type and filename extension.
1919
compressorName = fullCommand: builtins.elemAt (builtins.match "([^ ]*/)?([^ ]+).*" fullCommand) 1;
2020
in
21-
{ stdenvNoCC, perl, libarchive, ubootTools, lib, pkgsBuildHost
21+
{ stdenvNoCC, perl, cpio, ubootTools, lib, pkgsBuildHost
2222
# Name of the derivation (not of the resulting file!)
2323
, name ? "initrd"
2424

@@ -80,7 +80,7 @@ in stdenvNoCC.mkDerivation (rec {
8080

8181
builder = ./make-initrd.sh;
8282

83-
nativeBuildInputs = [ perl libarchive ]
83+
nativeBuildInputs = [ perl cpio ]
8484
++ lib.optional makeUInitrd ubootTools;
8585

8686
compress = "${_compressorExecutable} ${lib.escapeShellArgs _compressorArgsReal}";

pkgs/build-support/kernel/make-initrd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ for PREP in $prepend; do
4040
cat $PREP >> $out/initrd
4141
done
4242
(cd root && find * .[^.*] -exec touch -h -d '@1' '{}' +)
43-
(cd root && find * .[^.*] -print0 | sort -z | bsdtar --uid 0 --gid 0 -cnf - -T - | bsdtar --null -cf - --format=newc @- | eval -- $compress >> "$out/initrd")
43+
(cd root && find * .[^.*] -print0 | sort -z | cpio --quiet -o -H newc -R +0:+0 --reproducible --null | eval -- $compress >> "$out/initrd")
4444

4545
if [ -n "$makeUInitrd" ]; then
4646
mkimage -A "$uInitrdArch" -O linux -T ramdisk -C "$uInitrdCompression" -d "$out/initrd" $out/initrd.img

0 commit comments

Comments
 (0)