From owner-svn-ports-all@freebsd.org Sun Feb 14 09:59:10 2016 Return-Path: Delivered-To: svn-ports-all@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 5012FAA872F; Sun, 14 Feb 2016 09:59:10 +0000 (UTC) (envelope-from marino@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0F0BA1C47; Sun, 14 Feb 2016 09:59:09 +0000 (UTC) (envelope-from marino@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1E9x9ME086455; Sun, 14 Feb 2016 09:59:09 GMT (envelope-from marino@FreeBSD.org) Received: (from marino@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1E9x9a6086453; Sun, 14 Feb 2016 09:59:09 GMT (envelope-from marino@FreeBSD.org) Message-Id: <201602140959.u1E9x9a6086453@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marino set sender to marino@FreeBSD.org using -f From: John Marino Date: Sun, 14 Feb 2016 09:59:09 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r408849 - head/Tools/scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2016 09:59:10 -0000 Author: marino Date: Sun Feb 14 09:59:08 2016 New Revision: 408849 URL: https://svnweb.freebsd.org/changeset/ports/408849 Log: Add new tool script: redundant-opt-files.sh I got a request to make Synth identify "redundant" cached option files, where "redundant" means the saved port options are identical to the default options. For Synth (and portmaster?) which use the port's cache options, these redundant files are somewhat of a liability. At best they do nothing (Synth assumes default options) and at worst they will cause a future build to stop if the maintainer changes the port options later. This situation is avoidable. Rather than build detection into Synth, I decided to write a generic shell script for ports. When run, it will display the full path to the port's options directory if the cached options are the same as the defaults. This output is suitable to pipe to "xargs rm -rf" to remove all the redundant options in a single command. Added: head/Tools/scripts/redundant-opt-files.sh (contents, props changed) Added: head/Tools/scripts/redundant-opt-files.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Tools/scripts/redundant-opt-files.sh Sun Feb 14 09:59:08 2016 (r408849) @@ -0,0 +1,51 @@ +#!/bin/sh +# redundant-opt-files.sh +# Written by John Marino (marino@FreeBSD.org) +# +# This script checks every option file against the default options of +# its port. If they are identical, it writes the full path of the ports +# option directory (typically in /var/db/ports) to stdout. +# It is typically used by Synth users to identify options files that can +# deleted in order to prevent future configuration check failures. + +portsdir=${PORTSDIR:-/usr/ports} +db_dir=$(/usr/bin/make -C ${portsdir}/devel/gmake -V PORT_DBDIR 2>/dev/null) + +if [ ! -d "${db_dir}" ]; then + echo "The ${db_dir} ports option directory does not exist" + echo "There is nothing more to do." + exit +fi + +catport() { + local category + local port + local workstr=${1#${db_dir}/} + local words=$(echo ${workstr} | /usr/bin/tr "_" " "); + for word in ${words}; do + category=${word} + break; + done + port=${workstr#${category}_} + echo ${portsdir}/$category/$port +} + +identical_options() { + local origin=$(catport $1) + local selected_pristine=$(/usr/bin/make -C ${origin} \ + -V SELECTED_OPTIONS PORT_DBDIR=/dev/null) + local selected_now=$(/usr/bin/make -C ${origin} -V SELECTED_OPTIONS) + local deselected_pristine=$(/usr/bin/make -C ${origin} \ + -V DESELECTED_OPTIONS PORT_DBDIR=/dev/null) + local deselected_now=$(/usr/bin/make -C ${origin} -V DESELECTED_OPTIONS) + if [ "${selected_pristine}" = "${selected_now}" -a \ + "${deselected_pristine}" = "${deselected_now}" ]; then + echo $1 + fi; +} + +optdirs=$(/usr/bin/find -s "${db_dir}" -type d -depth 1) + +for dossier in ${optdirs}; do + identical_options ${dossier} +done