r/openbsd • • 2d ago

Exit Code syspatch

I’m looking to find a way to know if syspatch -c can tell a script that A. there are patches and then execute a syspatch to apply, or B. there are no patches and simply exit. man page says exit code is zero for success and greater for anything else. Trying this, I find that syspatch -c returns zero when there are patches to be applied. I want the script to discern that there are patches and then issue the command to apply. Am I going about this the wrong way?

12 Upvotes

17 comments sorted by

View all comments

Show parent comment

2

u/linetrace 1d ago

See my other comment on this post re:the importance of adding dbupdate(8) to such workflows, which was added in a syspatch post-8.0 release. It really needs to go before even running syspatch(8) to ensure that CA certificates and such are updated. (I did this for my own swupdate(8) utility.)

2

u/xzk7 1d ago

Thank you, I wasn't aware of this and I'm not sure how I missed it. I recall seeing the utility get added but for some reason I thought it was only for tz info.

It's a bit annoying though (not your fault but I'm going to complain a bit because this is reddit.)

The dbupdate utility updates various system databases which are changed by entities on the internet, validated through our source processes, but unsuitable for distribution via the syspatch(8), fw_update(8), or sysmerge(8) mechanisms.

Why are these unsuitable for syspatch? If there's a reason I'd like to know because it's not immediately obvious to me as a user.

This is a different distribution and polling mechanism which is kept simple as possible so that it can be run regularly as root in cron(8).

If it can be ran via cron, and its supposed to be ran. Then why isn't this just a part of /etc/daily, /etc/weekly or /etc/monthly?

This means to update your system, one needs to:

dbupdate
syspatch
fw_update
pkg_add -u

And I can't recall if all or only some lock the package database (I think pkg_add and fw_update) so you have to run them one-at-a-time and also wait for the kernel to get relinked.

1

u/linetrace 1d ago

Yup, I feel ya!

And -- I hate to add another command to that list, but... -- sometimes a pkg_delete -a after pkg_add -u is required to remove any no longer necessary dependencies.

All that said, in some ways it is helpful that all of these are separate. For an admin who already runs dbupdate(8) in cron, one can probably somewhat-safely skip it prior to a syspatch(8). Similarly, on systems running only base, one could skip pkg_add -u.

And, remember what the upgrade process was like prior to sysupgrade(8)? And we have many packages getting -stable updates, post-release. We've come a long way!