]>
wolfpit.net Git - tool/Arch-pacman/.git/blob - contrib/pacdiff.sh.in
2 # pacdiff : a simple pacnew/pacorig/pacsave updater
4 # Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
5 # Copyright (c) 2013 Pacman Development Team <pacman-dev@archlinux.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 declare -r myname
='pacdiff'
22 declare -r myver
='@PACKAGE_VERSION@'
24 diffprog
=${DIFFPROG:-vimdiff}
25 diffsearchpath
=${DIFFSEARCHPATH:-/etc}
30 m4_include
(..
/scripts
/library
/output_format.sh
)
32 m4_include
(..
/scripts
/library
/term_colors.sh
)
36 $myname is a simple pacnew/pacorig/pacsave updater.
41 -l/--locate scan using locate (default: find)
44 DIFFPROG override the merge program: (default: vimdiff)
45 DIFFSEARCHPATH override the search path. (only when using find)
48 Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname
54 printf "%s %s\n" "$myname" "$myver"
55 echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
56 echo 'Copyright (C) 2013 Pacman Development Team <pacman-dev@archlinux.org>'
60 if [ $locate -eq 1 ]; then
61 locate -0 -e -b \
*.pacnew \
*.pacorig \
*.pacsave
'*.pacsave.[0-9]*'
63 find $diffsearchpath \
( -name \
*.pacnew
-o -name \
*.pacorig
-o -name \
*.pacsave
-o -name '*.pacsave.[0-9]*' \
) -print0
67 while [[ -n "$1" ]]; do
81 # see http://mywiki.wooledge.org/BashFAQ/020
82 while IFS
= read -u 3 -r -d '' pacfile
; do
83 file="${pacfile%.pac*}"
84 file_type
="pac${pacfile##*.pac}"
86 # add matches for pacsave.N to oldsaves array, do not prompt
87 if [[ $file_type = pacsave.
+([0-9]) ]]; then
88 oldsaves
+=("$pacfile")
92 msg
"%s file found for %s" "$file_type" "$file"
93 if [ ! -f "$file" ]; then
94 warning
"$file does not exist"
99 if cmp -s "$pacfile" "$file"; then
100 msg2
"Files are identical, removing..."
103 ask
"(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
107 r
|R
) rm -v "$pacfile"; break ;;
108 o
|O
) mv -v "$pacfile" "$file"; break ;;
110 $diffprog "$pacfile" "$file"
111 rm -iv "$pacfile"; break ;;
113 *) ask
"Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
119 (( ${#oldsaves[@]} )) && warning
"Ignoring %s" "${oldsaves[@]}"
123 # vim: set ts=2 sw=2 noet: