blob: 85bcecc0781b67c2d0e096e47b80b20c37586b26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env bash
set -euo pipefail
# pacdiff-merge - Merge .pacnew files using pacdiff and meld (or $MERGE_TOOL)
MERGE_TOOL="${MERGE_TOOL:-/usr/bin/meld}"
REQUIRED_CMDS=(pacdiff sudo snapper "$MERGE_TOOL")
for cmd in "${REQUIRED_CMDS[@]}"; do
command -v "${cmd%% *}" >/dev/null 2>&1 || { echo "Missing required command: $cmd"; exit 1; }
done
export SUDO_EDITOR="$MERGE_TOOL"
mapfile -t pacfiles < <(/usr/bin/pacdiff --output)
if [[ ${#pacfiles[@]} -eq 0 ]]; then
echo "No .pacnew files found. Nothing to merge."
if [[ -t 0 ]]; then
read -rp "Press enter to finish."
fi
exit 0
fi
echo "Creating pre-merge snapshot..."
snap=$(sudo snapper create -d "Before PacDiff merge" -p)
echo "Created snapshot ${snap}"
for i in "${pacfiles[@]}"; do
echo -e "\nMerging ${i} ..."
/usr/bin/sudo -e "${i}" "${i/.pacnew/}"
while true; do
read -erp 'Were the files successfully merged? (delete .pacnew) [y/N/q] ' answer
case "$answer" in
[Yy]*) echo "Deleting ${i}..."; sudo rm "${i}"; break ;;
[Qq]*) echo "Aborting."; exit 1 ;;
[Nn]*|"") break ;;
*) echo "Invalid input. Please enter 'y', 'n', or 'q'." ;;
esac
done
done
echo -e "\nAll .pacnew files processed."
read -rp "Press enter to finish."
|