Shami's Blog

Sysadmin, Because Even Developers Need Heroes

Recursively Upgrade Package Dependencies With pkgng

2014-11-11

Update: I now just use pkg upgrade since I have better control over my package repo and it is a much better way to upgrade.

I’ve been hosting my own pkgng repository for a few months and loving it. One thing I’ve had problems with was upgrading package dependencies. For example, I would find myself upgrading Salt without upgrading ZMQ which led to lots of issues.

To upgrade a package and all its dependencies, run the following command

pkg info -d PKG_TO_UPGRADE | awk -F'-' '{for (i=1;i<NF-1;i++) { printf $i FS } print $i NL }' | xargs pkg install -y

What this does is get a list of package dependencies from pkgng, run them through awk to remove version numbers, then xargs runs the pkg install command on all packages.

About Me

Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.

twitter linkedin