Commit | Line | Data |
---|---|---|
273c3903 MM |
1 | #!/bin/bash |
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. | |
5 | set -e | |
6 | # "let" has stupid behavior of exiting 1. I'll use $(()) instead. | |
7 | unfinished_files=0 | |
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 | |
14 | : # good | |
15 | else | |
16 | #echo "$f_live" | |
17 | echo "- Merging $f_live." | |
18 | if rpmconf-matt-merge "$f_live.mattmerge" "$f_live.mattorig" "$f_live.mattnew" "$f_live"; then | |
19 | # Commit the merge. | |
20 | ( | |
21 | set -x | |
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" | |
26 | ) | |
27 | echo "- Merged $f_live." | |
28 | else | |
29 | unfinished_files=$((unfinished_files+1)) | |
30 | echo "- Leaving $f_live merge unfinished." | |
31 | fi | |
32 | fi | |
33 | done | |
34 | if [ $unfinished_files -eq 0 ]; then | |
35 | echo 'rpm overrides merge complete!' | |
36 | else | |
37 | echo "No more files to consider. $unfinished_files left unfinished." | |
38 | fi |