Date: Mon, 25 Nov 2013 13:40:52 GMT From: Daniel Shahaf <d.s@daniel.shahaf.name> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/184282: [patch] freebsd-update: allow opting-out of emails about specific target releases Message-ID: <201311251340.rAPDeqB2084207@oldred.freebsd.org> Resent-Message-ID: <201311251350.rAPDo0KI029555@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 184282 >Category: ports >Synopsis: [patch] freebsd-update: allow opting-out of emails about specific target releases >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Nov 25 13:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Daniel Shahaf >Release: 9.1-RELEASE-p6 >Organization: >Environment: FreeBSD $hostname 9.1-RELEASE-p6 FreeBSD 9.1-RELEASE-p6 #0: Wed Aug 21 20:40:52 UTC 2013 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 >Description: http://thread.gmane.org/gmane.os.freebsd.devel.hackers/51852 I run 'freebsd-update cron' nightly. Each time it runs it emails root@ with a notification that 9.1-RELEASE-p8 is available. I know that it is available and I chose not to update to it (I don't need it in my environment; I'll just update directly to -p9 when that is released), so I'd like to have a way to stop freebsd-update from emailing me about -p8, without stopping it from emailing me about subsequent releases. >How-To-Repeat: On a releng/9.1 system of a revision older than HEAD, run 'freebsd-update cron' and observe that it emails root@ about 9.1-RELEASE-p8; and that there is no way to disable that (short of removing the cron job altogether, which would also disable -p9 emails). >Fix: Attached. Patch attached with submission follows: 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 >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311251340.rAPDeqB2084207>