install-multi-user: ignore profile_target backups that have no change

If there was a prior nix installation that created this backup file and
then you tried to install it again, it would stop to tell you there is
this file. But if the file and its backup are identical in content,
there is no harm in continuing and in a later step overwriting the
existing backup file with the identical one. This is just a convenience
feature.
This commit is contained in:
Michael Lohmann 2023-01-12 15:45:19 +01:00
parent eaa20f2574
commit c74248c56e

View file

@ -445,6 +445,14 @@ EOF
# a row for different files. # a row for different files.
if [ -e "$profile_target$PROFILE_BACKUP_SUFFIX" ]; then if [ -e "$profile_target$PROFILE_BACKUP_SUFFIX" ]; then
# this backup process first released in Nix 2.1 # this backup process first released in Nix 2.1
if diff -q "$profile_target$PROFILE_BACKUP_SUFFIX" "$profile_target" > /dev/null; then
# a backup file for the rc-file exist, but they are identical,
# so we can safely ignore it and overwrite it with the same
# content later
continue
fi
failure <<EOF failure <<EOF
I back up shell profile/rc scripts before I add Nix to them. I back up shell profile/rc scripts before I add Nix to them.
I need to back up $profile_target to $profile_target$PROFILE_BACKUP_SUFFIX, I need to back up $profile_target to $profile_target$PROFILE_BACKUP_SUFFIX,