From owner-freebsd-hackers@FreeBSD.ORG Fri Nov 22 18:11:24 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C806BB25 for ; Fri, 22 Nov 2013 18:11:24 +0000 (UTC) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 814372508 for ; Fri, 22 Nov 2013 18:11:24 +0000 (UTC) Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 4285B21362; Fri, 22 Nov 2013 13:11:21 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 22 Nov 2013 13:11:21 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id :mime-version:content-type; s=mesmtp; bh=M56sLF09ustEm9n5OiQUYQ4 jFAA=; b=uogmQmjyoxFNCltHWwy4QXbWx3k65BDisfxEf0ijYnGZ0WqYfeHzbCC 9XxeC33H6JP/CNwi9QNzxQ+rNeCUsM6kyHgg9WTudBT872+A3zE+X65D4LcCn0vS UJ52hMRkJlXpKFlStTtVsXb2GdLJJGhF3w+jY7VlyvdVBZDjnP2c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :mime-version:content-type; s=smtpout; bh=M56sLF09ustEm9n5OiQUYQ 4jFAA=; b=fBSU18CeSvt9OJWjJxjpj06Kp6wRcdexrGFXj2MWrW26o5oShawyQu X4VSp4igFSJHi0R0AoXlI0KgK1kaufHxrpEws1+D7+5/GQuYOXjHyGxD9ccIRg8j nELa8pDPH+dU5jdR4PABYWFfGUYbHPFnBjOho2SpUw+bMiMj9AgEs= X-Sasl-enc: dq1Pj/X6+MljBSKBTaqnXWESxretVpGdzg2YJ3eP8NVP 1385143880 Received: from tarsus.local2 (unknown [46.19.33.46]) by mail.messagingengine.com (Postfix) with ESMTPA id 6C2C5C00E83; Fri, 22 Nov 2013 13:11:20 -0500 (EST) Date: Fri, 22 Nov 2013 20:11:10 +0200 From: Daniel Shahaf To: freebsd-hackers@freebsd.org Subject: 'freebsd-update cron' repeatedly announcing 9.1-RELEASE-p8 Message-ID: <20131122181110.GA29056@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2013 18:11:24 -0000 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