A few bash one-liners that I found helpful when dealing with mismatched package versions:

I developed these while tracking down inconsistencies due to a partially backed out pkg upgrade. Someone else may find them useful. And I will be able to recover them from here when I forget how to do this:

List all installed packages against repository packages (check version consistency):
Code:
for P in $(pkg info | cut -w -f 1); \
    do echo "$P  $(pkg search $(echo $P  | sed 's/+/[+]/g' ) | cut -w -f 1)" ; done

List all installed packages that do not match the repository version:
Code:
for P in $(pkg info | cut -w -f 1); \
  do echo "$P  $(pkg search $(echo $P  | sed 's/+/[+]/g' ) | cut -w -f 1)" ; \
  done | awk 'NF==1{printf "%s\n", $0}' - | sort # <== '-' use standard in to awk

List all installed packages by install date (yyyy mmm dd):
Code:
for P in $(pkg info | cut -w -f 1); \
    do pkg info $P | grep -i 'name \|version \|installed ' | \
    sed -n 1,4p | paste -s -d':' - | tr ":" " " | cut -w -f2,4,8,9,13 ; done | \
    awk '{printf "%s %s %s  %s-%s\n", $5,$3,$4,$1,$2}' | sort -k1nr -k2Mr -k3nr

List all installed packages that match the repository versions
Code:
for P in $(pkg info | cut -w -f 1); \
    do echo "$P  $(pkg search $(echo $P  | sed 's/+/[+]/g' ) | cut -w -f 1)" ; \
    done |  sort | awk '{if($1!=$2)print $1 $2}'

Note: the construct: $(echo $P | sed 's/+/[+]/g' ) is used to avoid the error: pkg: sqlite error while executing iterator in file pkgdb_iterator.c:1080: Invalid regex encountered when searching for package names and versions containing the character +.

For Example:

Code:
pkg search 'libsigc++-2.10.2'
pkg: sqlite error while executing iterator in file pkgdb_iterator.c:1080: Invalid regex

pkg search $(echo libsigc++-2.10.2 | sed 's/+/[+]/g')
libsigc++-2.10.2               Callback Framework for C++
 
Back
Top