diff --git a/dracut.sh b/dracut.sh index 3b292910f3..cd8d3ae0b0 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2091,8 +2091,17 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do fi done +clamp_mtimes() { + find "$1" -newer "$dracutbasedir/dracut-functions.sh" -print0 \ + | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh" +} + if [[ $do_hardlink == yes ]] && command -v hardlink > /dev/null; then dinfo "*** Hardlinking files ***" + if [[ $DRACUT_REPRODUCIBLE ]]; then + # hardlink only de-dupes identical mtimes; clamp any dynamically-generated files. + clamp_mtimes "$initdir" + fi hardlink "$initdir" 2>&1 | ddebug dinfo "*** Hardlinking files done ***" fi @@ -2299,8 +2308,7 @@ if [[ $uefi == yes ]]; then fi if [[ $DRACUT_REPRODUCIBLE ]]; then - find "$initdir" -newer "$dracutbasedir/dracut-functions.sh" -print0 \ - | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh" + clamp_mtimes "$initdir" if [[ "$(cpio --help)" == *--reproducible* ]]; then CPIO_REPRODUCIBLE=1 @@ -2315,8 +2323,7 @@ if [[ $create_early_cpio == yes ]]; then echo 1 > "$early_cpio_dir/d/early_cpio" if [[ $DRACUT_REPRODUCIBLE ]]; then - find "$early_cpio_dir/d" -newer "$dracutbasedir/dracut-functions.sh" -print0 \ - | xargs -r -0 touch -h -m -c -r "$dracutbasedir/dracut-functions.sh" + clamp_mtimes "$early_cpio_dir/d" fi # The microcode blob is _before_ the initramfs blob, not after