2 # Tool to maintain my pattern for RPM overrides, with the live path a symlink to
3 # mattnew. Originally 2017-04-07. Revamped 2017-09-05 to automate the merge
4 # like rpmconf-matt; I think this is as much work as I want to put in for now.
6 # "let" has stupid behavior of exiting 1. I'll use $(()) instead.
8 # Prune /mnt to avoid error message about /mnt/root loop. There shouldn't be
9 # any overrides under /mnt . ~ 2017-11-11
10 for f_new in $(find / -xdev -path '/mnt' -prune -or -name '*.mattnew' -print); do
11 f_live="${f_new%.mattnew}"
12 expected_target="$(basename "$f_new")"
13 if link_target="$(readlink "$f_live")" && [ "$link_target" == "$expected_target" ]; then
17 echo "- Merging $f_live."
18 if rpmconf-matt-merge "$f_live.mattmerge" "$f_live.mattorig" "$f_live.mattnew" "$f_live"; then
22 rm "$f_live.mattorig" "$f_live.mattnew"
23 mv "$f_live.mattmerge" "$f_live.mattnew"
24 mv "$f_live" "$f_live.mattorig"
25 ln -s "$expected_target" "$f_live"
27 echo "- Merged $f_live."
29 unfinished_files=$((unfinished_files+1))
30 echo "- Leaving $f_live merge unfinished."
34 if [ $unfinished_files -eq 0 ]; then
35 echo 'rpm overrides merge complete!'
37 echo "No more files to consider. $unfinished_files left unfinished."