Add some scripts for investigating the ports tree options.

This commit is contained in:
Tom Alexander 2023-09-01 12:34:55 -04:00
parent 5e81006208
commit a6af4eee2f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 114 additions and 3 deletions

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# List installed packages that install a kernel module.
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 module
doas find / -type f -name '*.ko' | sort | while read module; do
local provides=$(pkg provides "$module")
if [ -n "$provides" ]; then
package_name=$(grep 'Name : ' <<<"$provides" | sed 's/Name : //g')
# module_file=$(grep 'Filename: ' <<<"$provides" | sed 's/Filename: //g')
echo "$package_name"
fi
done
}
main "${@}"

View File

@ -0,0 +1,36 @@
#!/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 "${@}"

View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
#
# List ports containing an option matching the first parameter to the script.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${PORTSDIR:="/usr/ports"}
function main {
if [ "$#" -ne 1 ]; then
(>&2 echo "Pass exactly 1 option name to this script.")
exit 1
fi
local find_option_name=$1
local folder
find_port_folders | while read folder; do
set +e
dump_port_options "$folder" | grep -qE "^${find_option_name}$"
has_opt=$?;
set -e
if [ $has_opt -eq 0 ]; then
echo "$folder"
fi
done
}
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 "${@}"

View File

@ -92,3 +92,9 @@
dest: /usr/local/bin/freebsd_update_step1
- src: freebsd_update_step2
dest: /usr/local/bin/freebsd_update_step2
- src: find_popular_ports_options.bash
dest: /usr/local/bin/find_popular_ports_options
- src: find_ports_containing_option.bash
dest: /usr/local/bin/find_ports_containing_option
- src: find_packages_that_installed_kernel_modules.bash
dest: /usr/local/bin/find_packages_that_installed_kernel_modules

View File

@ -7,9 +7,7 @@
CPUTYPE?=tigerlake
# CPUTYPE?=x86-64-v4
.endif
OPTIMIZED_CFLAGS=YES
BUILD_OPTIMIZED=YES
WITH_CPUFLAGS=YES
# Disable static for subversion because /usr/local/lib/libutf8proc.a not found despite utf8proc being installed
#
# Disable static for netpbm because "ld: error: undefined symbol: libdeflate_free_compressor" which is "referenced by tif_zip.o:(ZIPVSetField) in archive /usr/local/lib/libtiff.a"
@ -22,3 +20,7 @@ WITH_CPUFLAGS=YES
.if ${.CURDIR:N*/devel/subversion*} && ${.CURDIR:N*/graphics/netpbm*} && ${.CURDIR:N*/audio/libsndfile*} && ${.CURDIR:N*/www/firefox*} && ${.CURDIR:N*/shells/zsh*}
OPTIONS_SET+=STATIC LTO
.endif
OPTIONS_SET+=OPTIMIZED_CFLAGS
# qemu uses STATIC_LINK instead of the more standard flag of STATIC
OPTIONS_SET+=STATIC_LINK