[pacman-dev] [PATCH] libmakepkg: Add check_buildoption for distcc and ccache

Allan McRae allan at archlinux.org
Tue Sep 22 14:24:51 UTC 2015


On 20/09/15 06:01, Jan Alexander Steffens (heftig) wrote:
> This reduces code duplication a bit. It also highlights how these
> options are checked.
> 
> v2: makepkg used to check OPTIONS too, which could override BUILDENV.
> Fix the implementation to avoid this.
> 
> Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens at gmail.com>
> ---

Put "v2" nots below here so they do not get included in the commit message.

>  scripts/libmakepkg/util/option.sh | 30 ++++++++++++++++++++++++++++++
>  scripts/makepkg.sh.in             |  8 ++++----
>  2 files changed, 34 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh
> index 1b2d94d..4ef8766 100644
> --- a/scripts/libmakepkg/util/option.sh
> +++ b/scripts/libmakepkg/util/option.sh
> @@ -106,3 +106,33 @@ check_buildenv() {
>  	# not found
>  	return 127
>  }
> +
> +##
> +# Check if option is present in BUILDENV and not inverted in options
> +#
> +#  usage : check_buildoption( $option, $expected_val )
> +# return : 0   - matches expected
> +#          1   - does not match expected
> +#          127 - not found
> +##
> +check_buildoption() {
> +	in_opt_array "$1" ${BUILDENV[@]}
> +	case $? in
> +		0) # assert enabled
> +			[[ $2 = y ]] || return 1 ;;
> +		1) # assert disabled
> +			[[ $2 = n ]] || return 1 ;;
> +		*) # not found
> +			return 127 ;;
> +	esac
> +
> +	in_opt_array "$1" ${options[@]}
> +	case $? in
> +		0) # assert enabled
> +			[[ $2 = y ]] || return 1 ;;
> +		1) # assert disabled
> +			[[ $2 = n ]] || return 1 ;;
> +	esac
> +
> +	return 0
> +}

The "options" array from the PKGBUILD should take preference.  Also,
follow the style of the other functions in that file in terms of the
return.  So it should essentially be check_options but with OPTIONS
replaced by BUILDENV.

A


More information about the pacman-dev mailing list