You are not logged in.
Motivation: I built some packages myself by copying the directory from /var/abs/* to /var/abs/local and using makepkg.
I updated abs with the abs command, but I have no way of telling if a package I built and installed has an update.
Goal: This script compares all the PKGBUILD files under /var/abs/local to the PKGBUILD for the same package under /var/abs/* and reports differences which would indicate that the package was updated.
In order not to report differences caused by tweaked configure options, the script only looks up to the 'build()' line in the PKGBUILD file.
I don't have many local packages, so this was not tested extensively or against many cases.
Comments, feedback, requests and all the rest would be appreciated.
#!/bin/bash
# Retrieve a list of man pages from pacman for a package
manpages () {
# Query pacman
pacman -Ql "$1" | \
grep $'/usr/share/man/.\n/usr/man/.' | \
while IFS=' ' read _ file ; do
# Strip the path to a num and man page name
file="${file#/usr}"
file="${file#/share}"
file="${file#/man/man}"
num="${file%%/*}"
file="${file#*/}"
file="${file%%.*}"
[[ $file ]] || continue
echo "$num $file"
done
}
(( $# == 0 )) && echo "Usage: "$(basename "$0")" package [more_packages...]"
for arg ; do
# Get the list of man number and names
IFS=$'\n' list=( $(manpages "$arg" 2>&1) )
# Check if any found
if ! [[ "$list" ]] ; then
echo "$arg has no man pages."
continue
fi
p='error: package * not found'
if [[ "${list[0]}" == $p ]] ; then
list="${list[0]}"
echo "${list#error: }"
continue
fi
# Only show prompt for more than one man page
prompt=0
if (( ${#list[@]} > 1 )) ; then
echo "$arg has ${#list[@]} man pages."
prompt=1
fi
for pair in "${list[@]}" ; do
IFS=' ' read num name <<< "$pair"
if (( prompt )) ; then
# If prompting, ask and allow user to selectively skip pages
read -p "Show man $pair? [Y/n] " -n 1
[[ $REPLY == [nN] ]] && { echo ; continue ; }
fi
man "$num" "$name"
done
done
Last edited by yitzle (2009-10-06 04:31:46)
Offline
When you use -z, or any test in [, make sure to quote the variable. comm might also be handy.
[git] | [AURpkgs] | [arch-games]
Offline
Daenyth, thanks for the reply.
When using the bash [[ ]] builtins, quoting is not needed, which is one way they improve on the [ ] tests.
I'll play around with comm and possibly update the above code.
Offline