#!/hint/bash -euE # Copyright (C) 2023 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later post_install+=(99:reproducible:late) reproducible:late() { local arg_mountpoint=$1 local SOURCE_DATE_EPOCH # Set it to the last timestamp from any package any package. SOURCE_DATE_EPOCH=$(zcat "$arg_mountpoint"/var/lib/pacman/local/*/mtree | sed -n 's/.* time=//p' | cut -d' ' -f1 | cut -d. -f1 | sort -n | tail -n1) for file in "$arg_mountpoint"/var/lib/pacman/local/*/desc; do awk -v date="$SOURCE_DATE_EPOCH" ' BEGIN{x=0} $0 == "%INSTALLDATE%"{x=2} {if (x==1) { print date } else { print }; x--} ' <"$file" >"$file.tmp" mv -T -- "$file.tmp" "$file" done rm -f -- "$arg_mountpoint"/var/log/pacman.log rm -f -- "$arg_mountpoint"/etc/machine-id # systemd's pacman post-install script rm -f -- "$arg_mountpoint"/etc/ssl/certs/java/cacerts # libalpm/hooks/40-update-ca-trust.hook rm -f -- "$arg_mountpoint"/var/cache/ldconfig/aux-cache # glibc's pacman post-install script # Add 1 second so that post-install things can be # "after" extracted files. SOURCE_DATE_EPOCH=$((SOURCE_DATE_EPOCH+1)) touch --date="@$SOURCE_DATE_EPOCH" -- "$arg_mountpoint/.source_date_epoch" find "$arg_mountpoint" -xdev -depth \ -newer "$arg_mountpoint/.source_date_epoch" \ -exec touch --no-dereference --date="@$SOURCE_DATE_EPOCH" -- {} + rm -f -- "$arg_mountpoint/.source_date_epoch" touch --date="@$SOURCE_DATE_EPOCH" -- "$arg_mountpoint/" }