From owner-freebsd-current@freebsd.org Tue Apr 5 23:32:20 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C1ADB046BA for ; Tue, 5 Apr 2016 23:32:20 +0000 (UTC) (envelope-from megas@alum.rpi.edu) Received: from tmde01oc.mail2world.com (tmde01oc.mail2world.com [209.67.128.209]) by mx1.freebsd.org (Postfix) with ESMTP id 029AB1C0B for ; Tue, 5 Apr 2016 23:32:19 +0000 (UTC) (envelope-from megas@alum.rpi.edu) Received: from mail pickup service by tmde01oc.mail2world.com with Microsoft SMTPSVC; Tue, 5 Apr 2016 16:32:09 -0700 X-CTCH-Spam: Unknown auth-sender: megas@alum.rpi.edu Received: from 10.1.106.119 unverified ([10.1.106.119]) by mwsmtp02oc.mail2world.com with Mail2World SMTP Server; Tue, 05 Apr 2016 16:32:07 -0700 MIME-Version: 1.0 From: Alexis Megas To: freebsd-current@freebsd.org Date: Tue, 05 Apr 2016 16:32:07 -0700 Subject: freebsd-update Message-Id: <6KIQMAN4VXT4.V3ETS7TFGAJL3@emweb04oc> X-Mailer: Microsoft CDO for Exchange 2000 X-OriginalArrivalTime: 05 Apr 2016 23:32:09.0648 (UTC) FILETIME=[5F8CC300:01D18F93] Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Apr 2016 23:32:20 -0000 Hello. Please consider a new clean command in the freebsd-update script. The modified manual and script are located at https://github.com/textbrowser/freebsd-update. Included are two diffs. Sorry for the long e-mail. --- /usr/src/usr.sbin/freebsd-update/freebsd-update.8    2015-08-12 10:21:35.000000000 -0400 +++ ./freebsd-update.8    2016-04-02 15:16:47.780095000 -0400 @@ -119,6 +119,12 @@  .Cm command  can be any one of the following:  .Bl -tag -width "rollback" +.It Cm clean +Remove the contents of +.Ar workdir . +(default: +.Ar /var/db/freebsd-update/ +).  .It Cm fetch  Based on the currently installed world and the configuration  options set, fetch all available binary updates. --- /usr/src/usr.sbin/freebsd-update/freebsd-update.sh    2015-08-12 10:21:35.000000000 -0400 +++ ./freebsd-update.sh    2016-04-02 15:26:57.990003000 -0400 @@ -53,6 +53,7 @@    --not-running-from-cron                 -- Run without a tty, for use by automated tools  Commands: +  clean        -- Clean workdir    fetch        -- Fetch updates from server    cron         -- Sleep rand(3600) seconds, fetch updates, and send an                    email if updates were found @@ -474,7 +475,7 @@              ;;            # Commands -        cron | fetch | upgrade | install | rollback | IDS) +        clean | cron | fetch | upgrade | install | rollback | IDS)              COMMANDS="${COMMANDS} $1"              ;;   @@ -559,6 +560,25 @@      mergeconfig  }   +# Perform sanity checks in preparation of cleaning workdir. +clean_check_params () { +    # Check that we are root.  All sorts of things won't work otherwise. +    if [ `id -u` != 0 ]; then +        echo "You must be root to run this." +        exit 1 +    fi + +    # Check that we have a working directory. +    _WORKDIR_bad="Directory does not exist or is not writable: " +    if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then +        echo -n "`basename $0`: " +        echo -n "${_WORKDIR_bad}" +        echo ${WORKDIR} +        exit 1 +    fi +    cd ${WORKDIR} || exit 1 +} +  # Set utility output filtering options, based on ${VERBOSELEVEL}  fetch_setup_verboselevel () {      case ${VERBOSELEVEL} in @@ -2047,6 +2067,11 @@      echo ${NOWTIME} > lasteolwarn  }   +# Clean workdir. +clean_run() { +        rm -fr * +} +  # Do the actual work involved in "fetch" / "cron".  fetch_run () {      workdir_init || return 1 @@ -3225,6 +3250,12 @@      default_params  }   +# Clean command. Allow non-interactive use. +cmd_clean () { +        clean_check_params +    clean_run || exit 1 +} +  # Fetch command.  Make sure that we're being called  # interactively, then run fetch_check_params and fetch_run  cmd_fetch () {