37 lines
841 B
Bash
Executable File
37 lines
841 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Find which port options appear the most in ports.
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
: ${PORTSDIR:="/usr/ports"}
|
|
|
|
function main {
|
|
if [ "$#" -ne 0 ]; then
|
|
(>&2 echo "This script takes no positional parameters.")
|
|
exit 1
|
|
fi
|
|
local folder
|
|
find_port_folders | while read folder; do
|
|
set +e
|
|
dump_port_options "$folder"
|
|
set -e
|
|
done | sort | uniq -c | sort -nr
|
|
}
|
|
|
|
function find_port_folders {
|
|
local mf
|
|
find "$PORTSDIR" -type f -name Makefile -mindepth 3 -maxdepth 3 | sort | while read mf; do
|
|
dirname "$mf"
|
|
done
|
|
}
|
|
|
|
function dump_port_options {
|
|
local folder="$1"
|
|
local portopts=$(make -C "$folder" -V OPTIONS_DEFINE)
|
|
echo "$portopts" | grep -oE --line-buffered '[^ ]*'
|
|
}
|
|
|
|
main "${@}"
|