[pacman-dev] [PATCH v2 1/9] pacdiff: Search and give warnings for older pacsave.[0-9]* files
Signed-off-by: Jonathan Frazier
Clean up and reword --help
get rid of all the echos to make it easier to read in source.
Signed-off-by: Jonathan Frazier
loop over arguments, this will allow adding options such as --nocolor
Signed-off-by: Jonathan Frazier
Allow colors to be disabled for use on broken/serial terminals.
Signed-off-by: Jonathan Frazier
change cmd tests to if (( FIND ))... as it is cleaner. All search cmds
have an option and a variable initialized to zero. the active option
should be set to 1. Add a switch to exclude multiple search options.
set the default when all are equal to zero.
Signed-off-by: Jonathan Frazier
On 23/07/13 11:22, Jonathan Frazier wrote:
change cmd tests to if (( FIND ))... as it is cleaner. All search cmds have an option and a variable initialized to zero. the active option should be set to 1. Add a switch to exclude multiple search options. set the default when all are equal to zero.
Signed-off-by: Jonathan Frazier
--- contrib/pacdiff.sh.in | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index b42f68c..f106c17 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -23,9 +23,9 @@ declare -r myver='@PACKAGE_VERSION@'
diffprog=${DIFFPROG:-vimdiff} diffsearchpath=${DIFFSEARCHPATH:-/etc} -locate=0 USE_COLOR='y' declare -a oldsaves +declare -i FIND=0 LOCATE=0
I changed these on my working branch to USE_FIND and USE_LOCATE as that is less likely to clash with environmental variables.
m4_include(../scripts/library/output_format.sh)
@@ -33,10 +33,13 @@ usage() { cat <
-Usage: $myname [-l] +Usage: $myname [-l | -f] [--nocolor]
-Options: - -l/--locate scan using locate (default: find) +Search Options: select one, default: find + -l/--locate scan using locate + -f/--find scan using find + +General Options: --nocolor remove colors from output
Enviroment Variables: @@ -56,9 +59,9 @@ version() { }
cmd() { - if [ $locate -eq 1 ]; then + if (( LOCATE )); then locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave '*.pacsave.[0-9]*' - else + elif (( FIND )); then find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0 fi } @@ -66,21 +69,29 @@ cmd() { while [[ -n "$1" ]]; do case "$1" in -l|--locate) - locate=1;; + LOCATE=1;; + -f|--find) + FIND=1;; --nocolor) - USE_COLOR='n' ;; + USE_COLOR='n' ;; -V|--version) - version; exit 0;; + version; exit 0;; -h|--help) - usage; exit 0;; + usage; exit 0;; *) - usage; exit 1;; + usage; exit 1;; esac shift done
m4_include(../scripts/library/term_colors.sh)
+case $(( FIND+LOCATE )) in + 0) FIND=1;; # set the default search option + [^1]) error "Only one search option may be used at a time" + usage; exit 1;; +esac + # see http://mywiki.wooledge.org/BashFAQ/020 while IFS= read -u 3 -r -d '' pacfile; do file="${pacfile%.pac*}"
On Tue, Jul 23, 2013 at 9:27 AM, Allan McRae
I changed these on my working branch to USE_FIND and USE_LOCATE as that is less likely to clash with environmental variables.
the tenor among bash coders was that application layer variables should be lowercase in general. So, you say you went too far down the other road? cheers! mar77i
This is a new search type, using -p or --pacmandb options. It reads
config file locations directly from the local pacman db. It will find
active configs anywhere they are defined in installed packages. It is
not dependant on outside configs such as updatedb.conf or scanning a
large set of directories for find.
This will find more pacnews than find when searching with the current
default of /etc, and it is faster than both find and updatedb when
searching the entire fs. When run directly after an update, the local db
is more likely to be cached than all files in /etc or / as other methods
read. This will increase performance further post upgrade.
After a package is removed and a pacsave is created, this method will
not find these pacsaves until the base config is added to the local db
again. These files have no influence in a working system and only take
up a few blocks of disk space.
Active configs need to be dealt with immediately to keep a system
working. pacsaves related to removed configs can remain for weeks or
months without problems. I would recommend occasionally running other
methods such as --locate to remove them.
Signed-off-by: Jonathan Frazier
Signed-off-by: Jonathan Frazier
On 23/07/13 11:22, Jonathan Frazier wrote:
Signed-off-by: Jonathan Frazier
--- contrib/pacdiff.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index 8f1a0e7..e76ad4b 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -113,7 +113,7 @@ done m4_include(../scripts/library/term_colors.sh)
case $(( FIND+LOCATE+PACDB )) in - 0) FIND=1;; # set the default search option + 0) PACDB=1;; # set the default search option [^1]) error "Only one search option may be used at a time" usage; exit 1;; esac
You did not update the --help output to reflect this. Done on my working branch. Allan
This is an option to just echo's the pacnews/pacsaves instead of merging
or removing them. This can be used to check the config status such as in
a cron job without modifying the system.
Signed-off-by: Jonathan Frazier
Signed-off-by: Jonathan Frazier
On Mon, Jul 22, 2013 at 09:23:00PM -0400, Jonathan Frazier wrote:
Signed-off-by: Jonathan Frazier
--- contrib/pacdiff.sh.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index 6b5edb9..349f6b9 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -28,6 +28,7 @@ diffsearchpath=${DIFFSEARCHPATH:-/etc} USE_COLOR='y' declare -a oldsaves declare -i FIND=0 LOCATE=0 PACDB=0 OUTPUTONLY=0 +declare -i UPDATEDB=0
m4_include(../scripts/library/output_format.sh)
@@ -122,6 +123,20 @@ case $(( FIND+LOCATE+PACDB )) in usage; exit 1;; esac
+if (( LOCATE )) && (( ! OUTPUTONLY )); then + ask "Run updatedb? [y/n] " + while read c; do + case $c in + Y|y) UPDATEDB=1; break;; #&& (error "updatedb failed"; exit 1);;
I'm guessing you commented this out and added the "workaround" below because you didn't understand why the 'exit 1' didn't do anything. You've created a subshell, so calling exit will just exit from the subshell. You can use { ... ; } instead which groups commands without creating a subshell. Better yet, just inline the updatedb call if you really want to go that route. I don't see why the indirection is needed/wanted.
+ N|n) break;; + *) ask "Invalid answer. Try again: [y/n] "; continue ;; + esac + done +fi +if (( UPDATEDB )); then + updatedb || error "updatedb failed"
If you're going to throw an error, you should probably exit. Otherwise, throw a warning instead and point out that results may not be accurate. All that said, I don't really care for this feature.
+fi + if (( PACDB )); then if [[ ! -r @sysconfdir@/pacman.conf ]]; then error "unable to read @sysconfdir@/pacman.conf" -- 1.8.3.2
participants (4)
-
Allan McRae
-
Dave Reisner
-
Jonathan Frazier
-
Martti Kühne