Skip to content

Instantly share code, notes, and snippets.

@jurajlutter
Created February 10, 2024 18:48
Show Gist options
  • Save jurajlutter/116a742cbc1cba6b1ebcb5b13edf57c2 to your computer and use it in GitHub Desktop.
Save jurajlutter/116a742cbc1cba6b1ebcb5b13edf57c2 to your computer and use it in GitHub Desktop.
A script to convert FreeBSD ports config directory to make.conf directives
#!/bin/sh
# Convert port's options directory to make.conf directives
# Mostly to be used with poudriere
#
# Written by Juraj Lutter <otis@FreeBSD.org>
#
set -euo pipefail
if [ $# -lt 1 ]; then
echo "Usage: $0 <optionsdir>"
exit 1
fi
# options directory
od=$1
# Change to ports options directory
cd $od
# Process only directories that are highly possible to be a
# port's options directory
for d in $(ls -1d *_*); do
[ -f ${d}/options ] && (
# Port name, essentially a dir name with
# first _ replaced with /
pn=$(echo "${d}" | sed 's,_,/,1')
# Write a port name, options and a newline
sed -n -e '
1 { i\
# '${pn}'
}
s,^OPTIONS_FILE,'${d}',gp
$ i\
' ${d}/options
)
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment