'freebsd-update cron' repeatedly announcing 9.1-RELEASE-p8

Daniel Shahaf d.s at daniel.shahaf.name
Fri Nov 22 18:11:24 UTC 2013


This cron job:
0 3 * * * /usr/sbin/freebsd-update cron
emails me nightly with a request to update to 9.1-RELEASE-p8.

But I don't need the -p8 fixes in my environment, so that nightly mail
is just clutter in my inbox, and would make it harder for me to notice
-p9 when that is announced.

So I added a freebsd-update.conf(5) knob to allow suppressing the email
if it's for a given release.  See attachment.  The intended use is to
set the knob to "9.1-RELEASE-p8" and then, when I start getting mails
about -p9, either install -p9 or update the knob's value to -p9.

Daniel

Index: etc/freebsd-update.conf
===================================================================
--- etc/freebsd-update.conf	(revision 258471)
+++ etc/freebsd-update.conf	(working copy)
@@ -74,3 +74,7 @@ MergeChanges /etc/ /boot/device.hints
 
 # When backing up a kernel also back up debug symbol files?
 # BackupKernelSymbolFiles no
+
+# If the new release is the specified value, don't emit an email announcing
+# it.  (Default: unspecified)
+# IgnoreReleases 9.1-RELEASE-p8
Index: share/man/man5/freebsd-update.conf.5
===================================================================
--- share/man/man5/freebsd-update.conf.5	(revision 258471)
+++ share/man/man5/freebsd-update.conf.5	(working copy)
@@ -218,6 +218,13 @@ backup kernel, the
 .Cm freebsd-update
 rollback command will recreate the symbol files along with the old
 kernel.
+.It Cm IgnoreReleases
+The parameters following this keyword are regular expressions;
+if the new release matches one of them, it will be ignored by
+.Cm cron .
+.Pp
+This option can be specified multiple times, and the parameters
+accumulate.
 .El
 .Sh FILES
 .Bl -tag -width "/etc/freebsd-update.conf"
Index: usr.sbin/freebsd-update/freebsd-update.sh
===================================================================
--- usr.sbin/freebsd-update/freebsd-update.sh	(revision 258471)
+++ usr.sbin/freebsd-update/freebsd-update.sh	(working copy)
@@ -88,6 +88,7 @@ EOF
 CONFIGOPTIONS="KEYPRINT WORKDIR SERVERNAME MAILTO ALLOWADD ALLOWDELETE
     KEEPMODIFIEDMETADATA COMPONENTS IGNOREPATHS UPDATEIFUNMODIFIED
     BASEDIR VERBOSELEVEL TARGETRELEASE STRICTCOMPONENTS MERGECHANGES
+    IGNORERELEASE
     IDSIGNOREPATHS BACKUPKERNEL BACKUPKERNELDIR BACKUPKERNELSYMBOLFILES"
 
 # Set all the configuration options to "".
@@ -217,6 +218,13 @@ config_Components () {
 	done
 }
 
+# Add to the list of releases updates to will be ignored.
+config_IgnoreReleases () {
+	for C in $@; do
+		IGNORERELEASE="${IGNORERELEASE} ${C}"
+	done
+}
+
 # Add to the list of paths under which updates will be ignored.
 config_IgnorePaths () {
 	for C in $@; do
@@ -2086,6 +2094,21 @@ fetch_run () {
 	fetch_warn_eol || return 1
 }
 
+# If the available release is in IgnoreReleases, return true.
+# Else, return false.
+cron_suppress_mail() {
+	TMPFILE=$1
+	if grep -q "No updates needed" ${TMPFILE}; then
+		return 0
+	fi
+	for X in ${IGNORERELEASE}; do
+		if echo "${RELNUM}-p${RELPATCHNUM}" | grep -q "${X}"; then
+			return 0
+		fi
+	done
+	return 1
+}
+
 # If StrictComponents is not "yes", generate a new components list
 # with only the components which appear to be installed.
 upgrade_guess_components () {
@@ -3199,7 +3222,7 @@ cmd_cron () {
 
 	TMPFILE=`mktemp /tmp/freebsd-update.XXXXXX` || exit 1
 	if ! fetch_run >> ${TMPFILE} ||
-	    ! grep -q "No updates needed" ${TMPFILE} ||
+	    ! cron_suppress_mail ${TMPFILE} ||
 	    [ ${VERBOSELEVEL} = "debug" ]; then
 		mail -s "`hostname` security updates" ${MAILTO} < ${TMPFILE}
 	fi


More information about the freebsd-hackers mailing list