Solved Showing only (outdated) top packages, not dependencies

This might be useful to someone.

When you run pkg upgrade, you get a plethora of packages, a list of both top level packages and their dependencies. But you want only the top packages, you often don't care about dependencies.

pkg query -e '%a=0' '%n-%v' - only shows top level packages. You can then peruse that list, prune it, or do as you wish.
 
pkg query -e '%a=0' '%n-%v' shows all top level packages, even if there are no upgrades to those packages available.

If you want to see which top level packages have updates, you need to run this:

Code:
for pkgname in $(pkg query -e '%a=0' %n); do
  curver=$(pkg query '%v' "$pkgname")
  newver=$(pkg rquery '%v' "$pkgname" 2>/dev/null)
  if [ -n "$newver" ]; then
    if [ "$curver" != "$newver" ]; then
      echo "$pkgname: $curver → $newver"
    fi
  fi
done
 
Useful queries such as this are already listed as predefined via pkg alias; This one is pkg noauto.
Is there a description of pkg alias queries? Manpages don't have any descriptions, so you'd have to manually decipher each query one by one to know what each does.
 
Is there a description of pkg alias queries? Manpages don't have any descriptions
The manpages of pkg commands (like "install", "info", "remove" etc.) are always man pkg-command (take a look at the bottom of pkg's manpage), so f.e. in this case: man pkg-alias; But you can also just execute pkg alias ;)
 
Back
Top