You are not logged in.
Pages: 1
Why not managing that problem like that
```
#!/bin/bash
# Run the system update and capture the failed output
update_output=$(sudo pacman -Syu 2>&1)
# Extract the list of files that caused conflicts from the output
conflicting_files=($(echo "$update_output" | grep -oE '/[^ ]+' | sort -u | tail +2))
# Backup the conflicting files with .pacold extension
for file in "${conflicting_files[@]}"; do
# Check if the file exists before renaming
if [[ -f "$file" ]]; then
backup_name="${file}.pacold"
# Rename while avoiding overwriting existing backup files
if [[ -f "$backup_name" ]]; then
counter=1
while [[ -f "${backup_name}.${counter}" ]]; do
((counter++))
done
backup_name="${file}.pacold.${counter}"
fi
sudo mv "$file" "$backup_name"
fi
done
# Retry the system update
sudo pacman -Syu
```
Instead of `--overwrite '*'`? Because if overwriting was the solution, then it would be automatic, without any flag to specify. If it is to specify it's that it's not the systematic solution. So if overwriting is not always good, isn't backuping always good? At least making it an option if even backup can be problematic for people really wanting to not touch anything
Offline
Because if there's a conflict, you need to stop and figure out why, not just blindly rename or overwrite.
Offline
Okay, so what about making an option? If overwrite is one, backup should too
Offline
If you've checked things out, you could have already made the backups where needed.
Offline
It can be a safe solution, overwrite making automatically a backup so if there is a problem, there is a backup
Offline
Then restoring the backup also causes problems. Now what?
Again, figure out WHY there's a conflict before anything, then you know what you need to do. If you end up with 2 packages owning the same file, no backup is going to save you.
Offline
Nobody talked about restoring backups, it is only about creating them, to the user don't lose them
Often there is two package owners that selected the same file, but it's not the problem here to resolve PKGBUILDs, it's only about not losing files
Offline
Often there is two package owners that selected the same file
Name two examples.
You're not supposed to run in such conflicts.
If you do, --overwrite can be one possible mitigation, but you need to understand the cause of the conflict and fix that.
Silently and automatically glossing over this by spamming the system w/ most likely pointless "backups" is akin to this approach:
Offline
It's not about "glossing over". It's about when you make the overwrite choice to make a backup automatically, just in case
Offline
Your script looksfor collisions, UNCONDITIONALLY moves them away and runs an update - how is that not "glossing over"?
Also, just in case of *what*?
By the time you issue an --overwrite you're supposed to have understood the collision and inferred that the existing file can be discarded. At that point "backups" aren't required.
You're looking for a way to non-interactively get collisions out of the way, but you are not supposed to encounter such collisions and user interaction is absolutely required in this situation.
Offline
Pages: 1