updating FreeBSD packages -- just an alias

I made two aliases in my /root/.cshrc to make updating all software easy:
Code:
alias update    'pkg upgrade -y && pkg autoremove -y && pkg clean -y'
alias uquit     'pkg upgrade -y && pkg autoremove -y && pkg clean -y && shutdown -p now'
pkg(8) updates the repository, upgrades all packages, removes no longer needed dependencies and cleans the local cache. the second alias does the same and shuts down the box.
 
Personally, I'd strongly advocate against practices like this. Eventually, this is just asking for trouble.

When package options and dependencies change, it can happen that conflicts occur which are resolved by removing some existing packages. Using auto-accept ( -y) will essentially prevent you from reviewing those changes to ensure that everything is working as per your expectation.

Furthermore, you're essentially gonna miss out on the package info which might instruct you to perform some action(s) manually. These too can change on port version or revision updates or conflicts that need to be resolved somehow.

There are plenty of other scenarios where stuff won't just run smoothly this way. Others are probably able to provide better information & scenarios on this than I am.
It also happened more than once that I was glad that I still had packages in the cache so I tend not to clear that except during situations where I know that it's all good.

I used to do something very similar on VMs which are part of CI/CD pipelines where one might argue that this is the decent thing to do. However, over the years I learned not to do that anymore to avoid problems such as the ones outlined above. Instead, I update the master VM image manually and then have my CI/CD build agent VMs clone off of that.

At the very least, I'd recommend using a boot environment so you can at least roll back easily if you have to.
 
with 'autoremove -y && clean -y' you can easily nuke your setup beyond repair. I'd ALWAYS monitor what 'autoremove' wants to delete as sometimes e.g. version mismatches lead to pkg removing a library and dragging tons of dependencies down with it.
By cleaning out your package cache you also give up any chance in restoring the previous pkg-versions and getting back to a usable state. The most recent example would be firefox/thunderbird which was broken in pkg for a few days - re-installing the previous version from the pkg cache had one back to a working state within a minute.

Of course you still have ZFS snapshots you could roll back - but oftentimes it's faster/easier to just re-install that one package manually from /var/cache/db.
 
Back
Top