]>
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
)
34 $myname is a simple pacnew/pacorig/pacsave updater.
39 -l/--locate scan using locate (default: find)
40 --nocolor remove colors from output
43 DIFFPROG override the merge program: (default: vimdiff)
44 DIFFSEARCHPATH override the search path. (only when using find)
47 Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname
53 printf "%s %s\n" "$myname" "$myver"
54 echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
55 echo 'Copyright (C) 2013 Pacman Development Team <pacman-dev@archlinux.org>'
59 if [ $locate -eq 1 ]; then
60 locate -0 -e -b \
*.pacnew \
*.pacorig \
*.pacsave
'*.pacsave.[0-9]*'
62 find $diffsearchpath \
( -name \
*.pacnew
-o -name \
*.pacorig
-o -name \
*.pacsave
-o -name '*.pacsave.[0-9]*' \
) -print0
66 while [[ -n "$1" ]]; do
82 m4_include
(..
/scripts
/library
/term_colors.sh
)
84 # see http://mywiki.wooledge.org/BashFAQ/020
85 while IFS
= read -u 3 -r -d '' pacfile
; do
86 file="${pacfile%.pac*}"
87 file_type
="pac${pacfile##*.pac}"
89 # add matches for pacsave.N to oldsaves array, do not prompt
90 if [[ $file_type = pacsave.
+([0-9]) ]]; then
91 oldsaves
+=("$pacfile")
95 msg
"%s file found for %s" "$file_type" "$file"
96 if [ ! -f "$file" ]; then
97 warning
"$file does not exist"
102 if cmp -s "$pacfile" "$file"; then
103 msg2
"Files are identical, removing..."
106 ask
"(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
110 r
|R
) rm -v "$pacfile"; break ;;
111 o
|O
) mv -v "$pacfile" "$file"; break ;;
113 $diffprog "$pacfile" "$file"
114 rm -iv "$pacfile"; break ;;
116 *) ask
"Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
122 (( ${#oldsaves[@]} )) && warning
"Ignoring %s" "${oldsaves[@]}"
126 # vim: set ts=2 sw=2 noet: