diff --git a/qb/qb.init.sh b/qb/qb.init.sh index 405340e25c..e883248f66 100644 --- a/qb/qb.init.sh +++ b/qb/qb.init.sh @@ -41,3 +41,19 @@ exists() done return $v } + +# match: +# Compares a variable against a list of variables +# $1 = variable +# $@ = list of variables +match() +{ + var="$1" + shift + for string do + case "$string" in + "$var" ) return 0 ;; + esac + done + return 1 +} diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 74c193a92c..9f5135f8ec 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -82,30 +82,45 @@ check_enabled() } # check_platform: -# $1 = OS +# $1 = OS ['OS' or 'OS OS2 OS3', $1 = name] # $2 = HAVE_$2 # $3 = feature -# $4 = enable feature when true [checked only if non-empty] +# $4 = enable feature when 'true', disable errors with 'user' [checked only if non-empty] check_platform() { tmpval="$(eval "printf %s \"\$HAVE_$2\"")" [ "$tmpval" = 'no' ] && return 0 + error= + newval= setval="$(eval "printf %s \"\$USER_$2\"")" - if [ "$setval" = 'yes' ]; then - if { [ "$1" != "$OS" ] && [ "${4:-}" = 'true' ]; } || - { [ "$1" = "$OS" ] && - [ "${4:-}" != 'true' ]; }; then - die 1 "Error: $3 not supported for $OS." + for platform in $(printf %s "$1"); do + if [ "$setval" = 'yes' ]; then + if [ "$error" != 'no' ] && [ "${4:-}" != 'user' ] && + { { [ "$platform" != "$OS" ] && + match "${4:-}" true user; } || + { [ "$platform" = "$OS" ] && + ! match "${4:-}" true user; }; }; then + error='yes' + elif match "${4:-}" true user; then + error='no' + fi + elif [ "$platform" = "$OS" ]; then + if match "${4:-}" true user; then + newval=yes + break + else + newval=no + fi + elif match "${4:-}" true user; then + newval=auto fi - elif [ "$1" = "$OS" ]; then - if [ "${4:-}" = 'true' ]; then - eval "HAVE_$2=yes" - else - eval "HAVE_$2=no" - fi - elif [ "${4:-}" = 'true' ]; then - eval "HAVE_$2=" + done + + if [ "${error}" = 'yes' ]; then + die 1 "Error: $3 not supported for $OS." + else + eval "HAVE_$2=\"${newval:-$tmpval}\"" fi }