xbps-src: simplify set_build_options

This commit is contained in:
Duncaen 2019-06-12 23:52:24 +02:00 committed by Juan RP
parent dd9c7a967e
commit 0639ff03da
No known key found for this signature in database
GPG key ID: AF19F6CB482F9368

View file

@ -154,7 +154,7 @@ msg_normal_append() {
} }
set_build_options() { set_build_options() {
local f j opt optval _optsset pkgopts _pkgname local f j pkgopts _pkgname
local -A options local -A options
if [ -z "$build_options" ]; then if [ -z "$build_options" ]; then
@ -170,30 +170,21 @@ set_build_options() {
fi fi
OIFS="$IFS"; IFS=',' OIFS="$IFS"; IFS=','
for j in ${pkgopts}; do for j in ${pkgopts}; do
opt=${j#\~} case "$j" in
opt_disabled=${j:0:1} "$f") options[$j]=1 ;;
if [ "$opt" = "$f" ]; then "~$f") options[${j#\~}]=0 ;;
if [ "$opt_disabled" != "~" ]; then esac
eval options[$opt]=1
else
eval options[$opt]=0
fi
fi
done done
IFS="$OIFS" IFS="$OIFS"
done done
for f in ${build_options_default}; do for f in ${build_options_default}; do
optval=${options[$f]} [[ -z "${options[$f]}" ]] && options[$f]=1
if [[ -z "$optval" ]] || [[ $optval -eq 1 ]]; then
options[$f]=1
fi
done done
# Prepare final options. # Prepare final options.
for f in ${!options[@]}; do for f in ${!options[@]}; do
optval=${options[$f]} if [[ ${options[$f]} -eq 1 ]]; then
if [[ $optval -eq 1 ]]; then
eval export build_option_${f}=1 eval export build_option_${f}=1
else else
eval unset build_option_${f} eval unset build_option_${f}
@ -210,25 +201,13 @@ set_build_options() {
return 0 return 0
fi fi
for f in ${build_options}; do
eval optval=${options[$f]}
if [[ $optval -eq 1 ]]; then
_optsset+=" ${f}"
else
_optsset+=" ~${f}"
fi
done
for f in ${_optsset}; do
if [ -z "$PKG_BUILD_OPTIONS" ]; then
PKG_BUILD_OPTIONS="$f"
else
PKG_BUILD_OPTIONS+=" $f"
fi
done
# Sort pkg build options alphabetically. # Sort pkg build options alphabetically.
export PKG_BUILD_OPTIONS="$(echo "$PKG_BUILD_OPTIONS"|tr ' ' '\n'|sort|tr '\n' ' ')" export PKG_BUILD_OPTIONS=$(
for f in ${build_options}; do
[[ "${options[$f]}" -eq 1 ]] || printf '~'
printf '%s\n' "$f"
done | sort
)
} }
source_file() { source_file() {