From a6af4eee2f014cf8e9348f08aa7e93e463317150 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 1 Sep 2023 12:34:55 -0400 Subject: [PATCH] Add some scripts for investigating the ports tree options. --- ...ackages_that_installed_kernel_modules.bash | 26 ++++++++++++ .../files/find_popular_ports_options.bash | 36 ++++++++++++++++ .../files/find_ports_containing_option.bash | 41 +++++++++++++++++++ ansible/roles/build/tasks/freebsd.yaml | 6 +++ .../13amd64-default-framework-make.conf | 8 ++-- 5 files changed, 114 insertions(+), 3 deletions(-) create mode 100755 ansible/roles/build/files/find_packages_that_installed_kernel_modules.bash create mode 100755 ansible/roles/build/files/find_popular_ports_options.bash create mode 100755 ansible/roles/build/files/find_ports_containing_option.bash diff --git a/ansible/roles/build/files/find_packages_that_installed_kernel_modules.bash b/ansible/roles/build/files/find_packages_that_installed_kernel_modules.bash new file mode 100755 index 0000000..7e5d5ea --- /dev/null +++ b/ansible/roles/build/files/find_packages_that_installed_kernel_modules.bash @@ -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 "${@}" diff --git a/ansible/roles/build/files/find_popular_ports_options.bash b/ansible/roles/build/files/find_popular_ports_options.bash new file mode 100755 index 0000000..900df32 --- /dev/null +++ b/ansible/roles/build/files/find_popular_ports_options.bash @@ -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 "${@}" diff --git a/ansible/roles/build/files/find_ports_containing_option.bash b/ansible/roles/build/files/find_ports_containing_option.bash new file mode 100755 index 0000000..c2ccd3a --- /dev/null +++ b/ansible/roles/build/files/find_ports_containing_option.bash @@ -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 "${@}" diff --git a/ansible/roles/build/tasks/freebsd.yaml b/ansible/roles/build/tasks/freebsd.yaml index 277e579..c167ab8 100644 --- a/ansible/roles/build/tasks/freebsd.yaml +++ b/ansible/roles/build/tasks/freebsd.yaml @@ -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 diff --git a/ansible/roles/poudriere/files/poudriere.d/13amd64-default-framework-make.conf b/ansible/roles/poudriere/files/poudriere.d/13amd64-default-framework-make.conf index d4b9a21..ccea36a 100644 --- a/ansible/roles/poudriere/files/poudriere.d/13amd64-default-framework-make.conf +++ b/ansible/roles/poudriere/files/poudriere.d/13amd64-default-framework-make.conf @@ -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