X-Git-Url: https://mattmccutchen.net/utils/utils.git/blobdiff_plain/40ea9b7868f2b7746e7cbabfba6aba982096392a..273c390351c42303171c25215304d1cfd6ca02d4:/rpm-overrides-matt diff --git a/rpm-overrides-matt b/rpm-overrides-matt new file mode 100755 index 0000000..aec9f71 --- /dev/null +++ b/rpm-overrides-matt @@ -0,0 +1,38 @@ +#!/bin/bash +# Tool to maintain my pattern for RPM overrides, with the live path a symlink to +# mattnew. Originally 2017-04-07. Revamped 2017-09-05 to automate the merge +# like rpmconf-matt; I think this is as much work as I want to put in for now. +set -e +# "let" has stupid behavior of exiting 1. I'll use $(()) instead. +unfinished_files=0 +# Prune /mnt to avoid error message about /mnt/root loop. There shouldn't be +# any overrides under /mnt . ~ 2017-11-11 +for f_new in $(find / -xdev -path '/mnt' -prune -or -name '*.mattnew' -print); do + f_live="${f_new%.mattnew}" + expected_target="$(basename "$f_new")" + if link_target="$(readlink "$f_live")" && [ "$link_target" == "$expected_target" ]; then + : # good + else + #echo "$f_live" + echo "- Merging $f_live." + if rpmconf-matt-merge "$f_live.mattmerge" "$f_live.mattorig" "$f_live.mattnew" "$f_live"; then + # Commit the merge. + ( + set -x + rm "$f_live.mattorig" "$f_live.mattnew" + mv "$f_live.mattmerge" "$f_live.mattnew" + mv "$f_live" "$f_live.mattorig" + ln -s "$expected_target" "$f_live" + ) + echo "- Merged $f_live." + else + unfinished_files=$((unfinished_files+1)) + echo "- Leaving $f_live merge unfinished." + fi + fi +done +if [ $unfinished_files -eq 0 ]; then + echo 'rpm overrides merge complete!' +else + echo "No more files to consider. $unfinished_files left unfinished." +fi