2010-10-13 18:50:54 -04:00
|
|
|
#!@BASH_SHELL@
|
2009-02-17 17:40:11 -05:00
|
|
|
# pacdiff : a simple pacnew/pacorig/pacsave updater
|
2007-02-23 03:03:50 -05:00
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-02-23 03:03:50 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
diffprog=${DIFFPROG:-vimdiff}
|
2009-10-21 17:46:47 -04:00
|
|
|
diffsearchpath=${DIFFSEARCHPATH:-/etc}
|
2009-02-17 17:40:11 -05:00
|
|
|
locate=0
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "pacdiff : a simple pacnew/pacorig/pacsave updater"
|
|
|
|
echo "Usage : pacdiff [-l]"
|
2009-10-21 17:46:47 -04:00
|
|
|
echo " -l/--locate makes pacdiff use locate rather than find"
|
|
|
|
echo " DIFFPROG variable allows to override the default vimdiff"
|
|
|
|
echo " DIFFSEARCHPATH allows to override the default /etc path"
|
|
|
|
echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff"
|
2009-02-17 17:40:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd() {
|
|
|
|
if [ $locate -eq 1 ]; then
|
|
|
|
locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave
|
|
|
|
else
|
2009-10-21 17:46:47 -04:00
|
|
|
find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \) -print0
|
2009-02-17 17:40:11 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
case $1 in
|
|
|
|
-l|--locate)
|
|
|
|
locate=1;;
|
|
|
|
*)
|
|
|
|
usage; exit 0;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
# see http://mywiki.wooledge.org/BashFAQ/020
|
|
|
|
while IFS= read -u 3 -r -d '' pacfile; do
|
|
|
|
file="${pacfile%.pac*}"
|
|
|
|
echo "File: $file"
|
|
|
|
if [ ! -f "$file" ]; then
|
|
|
|
echo " $file does not exist"
|
|
|
|
rm -i "$pacfile"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
check="$(cmp "$pacfile" "$file")"
|
|
|
|
if [ -z "${check}" ]; then
|
|
|
|
echo " Files are identical, removing..."
|
|
|
|
rm "$pacfile"
|
|
|
|
else
|
|
|
|
echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] "
|
|
|
|
while read c; do
|
|
|
|
case $c in
|
|
|
|
r|R) rm "$pacfile"; break ;;
|
|
|
|
v|V)
|
|
|
|
$diffprog "$pacfile" "$file"
|
|
|
|
rm -i "$pacfile"; break ;;
|
|
|
|
s|S) break ;;
|
|
|
|
*) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done 3< <(cmd)
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 noet:
|