makepkg: run tidy_install with no package() function
[pacman-ng.git] / contrib / pacdiff
blob5138d91c5d857db0c2d402a4bfc80ec6964fd8e1
1 #!/bin/bash
2 # pacdiff : a simple pacnew/pacorig/pacsave updater
4 # Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 diffprog=${DIFFPROG:-vimdiff}
21 locate=0
23 usage() {
24 echo "pacdiff : a simple pacnew/pacorig/pacsave updater"
25 echo "Usage : pacdiff [-l]"
26 echo "The -l/--locate flag makes pacdiff use locate rather than find"
29 cmd() {
30 if [ $locate -eq 1 ]; then
31 locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave
32 else
33 find /etc/ \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \) -print0
37 if [ $# -gt 0 ]; then
38 case $1 in
39 -l|--locate)
40 locate=1;;
42 usage; exit 0;;
43 esac
46 # see http://mywiki.wooledge.org/BashFAQ/020
47 while IFS= read -u 3 -r -d '' pacfile; do
48 file="${pacfile%.pac*}"
49 echo "File: $file"
50 if [ ! -f "$file" ]; then
51 echo " $file does not exist"
52 rm -i "$pacfile"
53 continue
55 check="$(cmp "$pacfile" "$file")"
56 if [ -z "${check}" ]; then
57 echo " Files are identical, removing..."
58 rm "$pacfile"
59 else
60 echo -n " File differences found. (V)iew, (S)kip, (R)emove: [v/s/r] "
61 while read c; do
62 case $c in
63 r|R) rm "$pacfile"; break ;;
64 v|V)
65 $diffprog "$pacfile" "$file"
66 rm -i "$pacfile"; break ;;
67 s|S) break ;;
68 *) echo -n " Invalid answer. Try again: [v/s/r] "; continue ;;
69 esac
70 done
72 done 3< <(cmd)
74 exit 0
76 # vim: set ts=2 sw=2 noet: