1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

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) <jan.steffens@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Jan Alexander Steffens (heftig) 2015-10-19 03:33:24 +02:00 committed by Allan McRae
parent 5d4a3f101c
commit 70e6875ad9
2 changed files with 38 additions and 4 deletions

View File

@ -106,3 +106,37 @@ check_buildenv() {
# not found # not found
return 127 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
}

View File

@ -852,13 +852,13 @@ run_prepare() {
run_build() { run_build() {
# use distcc if it is requested (check buildenv and PKGBUILD opts) # use distcc if it is requested (check buildenv and PKGBUILD opts)
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then if check_buildoption "distcc" "y"; then
[[ -d /usr/lib/distcc/bin ]] && export PATH="/usr/lib/distcc/bin:$PATH" [[ -d /usr/lib/distcc/bin ]] && export PATH="/usr/lib/distcc/bin:$PATH"
export DISTCC_HOSTS export DISTCC_HOSTS
fi fi
# use ccache if it is requested (check buildenv and PKGBUILD opts) # use ccache if it is requested (check buildenv and PKGBUILD opts)
if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then if check_buildoption "ccache" "y"; then
[[ -d /usr/lib/ccache/bin ]] && export PATH="/usr/lib/ccache/bin:$PATH" [[ -d /usr/lib/ccache/bin ]] && export PATH="/usr/lib/ccache/bin:$PATH"
fi fi
@ -1557,7 +1557,7 @@ check_software() {
fi fi
# distcc - compilation with distcc # distcc - compilation with distcc
if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then if check_buildoption "distcc" "y"; then
if ! type -p distcc >/dev/null; then if ! type -p distcc >/dev/null; then
error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
ret=1 ret=1
@ -1565,7 +1565,7 @@ check_software() {
fi fi
# ccache - compilation with ccache # ccache - compilation with ccache
if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then if check_buildoption "ccache" "y"; then
if ! type -p ccache >/dev/null; then if ! type -p ccache >/dev/null; then
error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
ret=1 ret=1