From 70e6875ad9afd6ee0e26c7fbe283466f7a6767e5 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Mon, 19 Oct 2015 03:33:24 +0200 Subject: libmakepkg: Add check_buildoption for distcc and ccache makepkg used to check OPTIONS too, which could override BUILDENV. Implement a new function that handles these options more like OPTIONS. This also reduces code duplication a bit. Signed-off-by: Jan Alexander Steffens (heftig) Signed-off-by: Allan McRae --- scripts/libmakepkg/util/option.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'scripts/libmakepkg/util') diff --git a/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh index 1b2d94dc..41c7fd3a 100644 --- a/scripts/libmakepkg/util/option.sh +++ b/scripts/libmakepkg/util/option.sh @@ -106,3 +106,37 @@ check_buildenv() { # not found return 127 } + +## +# Checks to see if options are present in BUILDENV or PKGBUILD; +# PKGBUILD options always take precedence. +# +# usage : check_buildoption( $option, $expected_val ) +# return : 0 - matches expected +# 1 - does not match expected +# 127 - not found +## +check_buildoption() { + in_opt_array "$1" ${options[@]} + case $? in + 0) # assert enabled + [[ $2 = y ]] + return ;; + 1) # assert disabled + [[ $2 = n ]] + return + esac + + in_opt_array "$1" ${BUILDENV[@]} + case $? in + 0) # assert enabled + [[ $2 = y ]] + return ;; + 1) # assert disabled + [[ $2 = n ]] + return + esac + + # not found + return 127 +} -- cgit v1.2.3-70-g09d2