diff options
author | marino <marino@FreeBSD.org> | 2016-02-14 17:59:08 +0800 |
---|---|---|
committer | marino <marino@FreeBSD.org> | 2016-02-14 17:59:08 +0800 |
commit | 859652c49d89ccb5405f28b4a6f21086c7e817d1 (patch) | |
tree | b410f9c5277b3a7e57566c9c22488d9ba73e0966 /Tools/scripts | |
parent | 3888866ac9652aa3d710eee2edd182bf434b5aba (diff) | |
download | freebsd-ports-gnome-859652c49d89ccb5405f28b4a6f21086c7e817d1.tar.gz freebsd-ports-gnome-859652c49d89ccb5405f28b4a6f21086c7e817d1.tar.zst freebsd-ports-gnome-859652c49d89ccb5405f28b4a6f21086c7e817d1.zip |
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.
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/redundant-opt-files.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Tools/scripts/redundant-opt-files.sh b/Tools/scripts/redundant-opt-files.sh new file mode 100755 index 000000000000..a86efb7e477c --- /dev/null +++ b/Tools/scripts/redundant-opt-files.sh @@ -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 |