diff options
author | Martin Schwaighofer <mschwaig@users.noreply.github.com> | 2021-12-05 17:19:13 +0100 |
---|---|---|
committer | Martin Schwaighofer <mschwaig@users.noreply.github.com> | 2022-10-22 12:11:30 +0200 |
commit | f6ee247a1f0aa927e8e58da337a0bbf3deca08c9 (patch) | |
tree | d34128cd86b5b0575b0f854eea9ce959e00c330a /nixos/modules/installer | |
parent | eb569423a73c69031fe8964cc1bbe2e4297167e3 (diff) |
sd-image: make firmware partition deterministic
Based on how it works for the EFI partition of an iso-image at nixos/modules/installer/cd-dvd/iso-image.nix.
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r-- | nixos/modules/installer/sd-card/sd-image.nix | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix index cb2522d867890..2921491c9c96d 100644 --- a/nixos/modules/installer/sd-card/sd-image.nix +++ b/nixos/modules/installer/sd-card/sd-image.nix @@ -224,14 +224,24 @@ in # Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img eval $(partx $img -o START,SECTORS --nr 1 --pairs) truncate -s $((SECTORS * 512)) firmware_part.img - faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img + + faketime "2000-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img # Populate the files intended for /boot/firmware mkdir firmware ${config.sdImage.populateFirmwareCommands} + find firmware -exec touch --date=2000-01-01 {} + # Copy the populated /boot/firmware into the SD image - (cd firmware; mcopy -psvm -i ../firmware_part.img ./* ::) + (cd firmware; + # Force a fixed order in mcopy for better determinism, and avoid file globbing + for d in $(find . -type d -mindepth 1 | sort); do + faketime "2000-01-01 00:00:00" mmd -i ../firmware_part.img "::/$d" + done + for f in $(find . -type f | sort); do + mcopy -pvm -i ../firmware_part.img "$f" "::/$f" + done) + # Verify the FAT partition before copying it. fsck.vfat -vn firmware_part.img dd conv=notrunc if=firmware_part.img of=$img seek=$START count=$SECTORS |