From owner-svn-src-all@FreeBSD.ORG Wed Mar 4 04:47:59 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 00E68416; Wed, 4 Mar 2015 04:47:58 +0000 (UTC) Received: from mail-la0-x22d.google.com (mail-la0-x22d.google.com [IPv6:2a00:1450:4010:c03::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5CB4B14E; Wed, 4 Mar 2015 04:47:58 +0000 (UTC) Received: by lams18 with SMTP id s18so42046077lam.13; Tue, 03 Mar 2015 20:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=7H9qCsZ7e3gEputJrJW+vPgjqrkEDftVwOyI0/o/3M0=; b=mNg4zamfx4DAVSrWPXX/cWb8dEOc+giiIQ952aW6PBVfpRHD+0UkVZQVvxTMU6BgLy quZb9XKA9vqpZH0Imnv+D5E1BmeSOdtEb5Da7zQJwJ210F0tAZY7l5G7K0dEpAb+qkd2 WRfUdAioeentSDy5WxLrvbnG3QKvTufrZEN7O3XgZt6FMxE92vr9oVqIRE0Jn7uNssTu mjc/eNmX5YBekb2ja7R0kWvShRpSgxiaD3/eFBKGPzFV85AjE4WG1Vwa5+ytf8ax8C3q ZlX6a6Y4+pF2fDWT6DOPW8idiyD47sGC1pm5zWbbUNYvj5/Kf5Mqw5JvBlGJlYqR7VHW Cecg== MIME-Version: 1.0 X-Received: by 10.152.1.170 with SMTP id 10mr1658892lan.89.1425444476253; Tue, 03 Mar 2015 20:47:56 -0800 (PST) Sender: crodr001@gmail.com Received: by 10.112.82.164 with HTTP; Tue, 3 Mar 2015 20:47:56 -0800 (PST) In-Reply-To: <201503032320.t23NKJjC059788@svn.freebsd.org> References: <201503032320.t23NKJjC059788@svn.freebsd.org> Date: Tue, 3 Mar 2015 20:47:56 -0800 X-Google-Sender-Auth: sqNXMrKYThe63f33vc-dU0owgzk Message-ID: Subject: Re: svn commit: r279571 - head/usr.sbin/freebsd-update From: Craig Rodrigues To: Allan Jude , Ahmed Kamal Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 04:47:59 -0000 Allan, Ahmed Kamal is working on helping with devops automation of some of the config management associated with the jenkins.freebsd.org cluster. Ahmed pointed out to me that this enhancement to freebsd-update would facilitate using freebsd-update in an automation environment. Allan, thanks for working on this and taking it to completion! Ahmed, thanks for working on this stuff and pointing out where FreeBSD can be improved to help in automation environments! -- Craig On Tue, Mar 3, 2015 at 3:20 PM, Allan Jude wrote: > Author: allanjude (doc committer) > Date: Tue Mar 3 23:20:18 2015 > New Revision: 279571 > URL: https://svnweb.freebsd.org/changeset/base/279571 > > Log: > Add a new safetly belt to freebsd-update to prevent a user doing a minor > update (-pX) while having an unfinished major upgrade (9.x to 9.y) > Safetly belt can be disabled with the -F flag > > Additionally, add the --not-running-from-cron flag they bypasses the TTY > requirement, and allows freebsd-update to be invoked by orchestration > frameworks, scripts, or otherwise. > > PR: 196760 > Differential Revision: https://reviews.freebsd.org/D1550 > Reviewed by: cperciva, delphij > Approved by: bcr (mentor), rodrigc (src) > MFC after: 1 month > Relnotes: yes > Sponsored by: ScaleEngine Inc. > > Modified: > head/usr.sbin/freebsd-update/freebsd-update.8 > head/usr.sbin/freebsd-update/freebsd-update.sh > > Modified: head/usr.sbin/freebsd-update/freebsd-update.8 > > ============================================================================== > --- head/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 3 > 22:49:07 2015 (r279570) > +++ head/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 3 > 23:20:18 2015 (r279571) > @@ -25,7 +25,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd July 14, 2010 > +.Dd March 2, 2015 > .Dt FREEBSD-UPDATE 8 > .Os FreeBSD > .Sh NAME > @@ -36,10 +36,12 @@ > .Op Fl b Ar basedir > .Op Fl d Ar workdir > .Op Fl f Ar conffile > +.Op Fl F > .Op Fl k Ar KEY > .Op Fl r Ar newrelease > .Op Fl s Ar server > .Op Fl t Ar address > +.Op Fl -not-running-from-cron > .Cm command ... > .Sh DESCRIPTION > The > @@ -54,16 +56,16 @@ by the > .Fx > Release Engineering Team, e.g., > .Fx > -7.3-RELEASE and > +9.3-RELEASE and > .Fx > -8.0-RELEASE, but not > +10.1-RELEASE, but not > .Fx > -6.3-STABLE or > +9.3-STABLE or > .Fx > -9.0-CURRENT. > +11-CURRENT. > .Sh OPTIONS > The following options are supported: > -.Bl -tag -width "-f conffile" > +.Bl -tag -width "-r newrelease" > .It Fl b Ar basedir > Operate on a system mounted at > .Ar basedir . > @@ -81,6 +83,10 @@ Read configuration options from > .Ar conffile . > (default: > .Pa /etc/freebsd-update.conf ) > +.It Fl F > +Force > +.Nm Cm fetch > +to proceed where it normally would not, such as an unfinished upgrade > .It Fl k Ar KEY > Trust an RSA key with SHA256 of > .Ar KEY . > @@ -98,12 +104,21 @@ Mail output of > command, if any, to > .Ar address . > (default: root, or as given in the configuration file.) > +.It Fl -not-running-from-cron > +Force > +.Nm Cm fetch > +to proceed when there is no controlling tty. > +This is for use by automated scripts and orchestration tools. > +Please do not run > +.Nm Cm fetch > +from crontab or similar using this flag, see: > +.Nm Cm cron > .El > .Sh COMMANDS > The > .Cm command > can be any one of the following: > -.Bl -tag -width "-f conffile" > +.Bl -tag -width "rollback" > .It Cm fetch > Based on the currently installed world and the configuration > options set, fetch all available binary updates. > > Modified: head/usr.sbin/freebsd-update/freebsd-update.sh > > ============================================================================== > --- head/usr.sbin/freebsd-update/freebsd-update.sh Tue Mar 3 > 22:49:07 2015 (r279570) > +++ head/usr.sbin/freebsd-update/freebsd-update.sh Tue Mar 3 > 23:20:18 2015 (r279571) > @@ -43,12 +43,15 @@ Options: > (default: /var/db/freebsd-update/) > -f conffile -- Read configuration options from conffile > (default: /etc/freebsd-update.conf) > + -F -- Force a fetch operation to proceed > -k KEY -- Trust an RSA key with SHA256 hash of KEY > -r release -- Target for upgrade (e.g., 6.2-RELEASE) > -s server -- Server from which to fetch updates > (default: update.FreeBSD.org) > -t address -- Mail output of cron command, if any, to address > (default: root) > + --not-running-from-cron > + -- Run without a tty, for use by automated tools > Commands: > fetch -- Fetch updates from server > cron -- Sleep rand(3600) seconds, fetch updates, and send an > @@ -399,6 +402,12 @@ init_params () { > > # No commands specified yet > COMMANDS="" > + > + # Force fetch to proceed > + FORCEFETCH=0 > + > + # Run without a TTY > + NOTTYOK=0 > } > > # Parse the command line > @@ -411,6 +420,12 @@ parse_cmdline () { > if [ ! -z "${CONFFILE}" ]; then usage; fi > shift; CONFFILE="$1" > ;; > + -F) > + FORCEFETCH=1 > + ;; > + --not-running-from-cron) > + NOTTYOK=1 > + ;; > > # Configuration file equivalents > -b) > @@ -673,6 +688,14 @@ fetch_check_params () { > echo "(Did you mean 'upgrade' instead?)" > exit 1 > fi > + > + # Check that we have updates ready to install > + if [ -f ${BDHASH}-install/kerneldone && $FORCEFETCH -eq 0 ]; then > + echo "You have a partially completed upgrade pending" > + echo "Run '$0 install' first." > + echo "Run '$0 fetch -F' to proceed anyway." > + exit 1 > + fi > } > > # Perform sanity checks etc. before fetching upgrades. > @@ -3197,7 +3220,7 @@ get_params () { > # Fetch command. Make sure that we're being called > # interactively, then run fetch_check_params and fetch_run > cmd_fetch () { > - if [ ! -t 0 ]; then > + if [ ! -t 0 && $NOTTYOK -eq 0 ]; then > echo -n "`basename $0` fetch should not " > echo "be run non-interactively." > echo "Run `basename $0` cron instead." > >