scripts/makepkg.in: Rewrite check_{options,buildenv} to tidy them up.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
This commit is contained in:
parent
3b1e67628e
commit
2fb2613ec1
|
@ -107,74 +107,104 @@ strip_url() {
|
|||
echo "$1" | sed 's|^.*://.*/||g'
|
||||
}
|
||||
|
||||
# checks to see if options are present in makepkg.conf or PKGBUILD;
|
||||
# PKGBUILD options always take precedence
|
||||
|
||||
##
|
||||
# Checks to see if options are present in makepkg.conf or PKGBUILD;
|
||||
# PKGBUILD options always take precedence.
|
||||
#
|
||||
# usage : check_option( $option )
|
||||
# return : y - enabled
|
||||
# n - disabled
|
||||
# ? - not found
|
||||
##
|
||||
check_option() {
|
||||
local ret=$(in_opt_array "$1" ${options[@]})
|
||||
if [ "$ret" != '?' ]; then
|
||||
echo $ret
|
||||
return
|
||||
fi
|
||||
|
||||
# BEGIN DEPRECATED
|
||||
# TODO: This code should be removed in the next release of makepkg.
|
||||
local needle=$(echo $1 | tr [:upper:] [:lower:])
|
||||
local i
|
||||
# loop PKGBUILD opts first so it overrides makepkg.conf
|
||||
for i in ${options[@]}; do
|
||||
local lc=$(echo $i | tr [:upper:] [:lower:])
|
||||
if [ "$lc" = "$needle" ]; then
|
||||
echo "y"
|
||||
return
|
||||
elif [ "$lc" = "!$needle" ]; then
|
||||
echo "n"
|
||||
return
|
||||
# START DEPRECATED
|
||||
# TODO This code should be removed in the next release of makepkg
|
||||
elif [ "$lc" = "no$needle" ]; then
|
||||
local opt
|
||||
for opt in ${options[@]}; do
|
||||
opt=$(echo $opt | tr [:upper:] [:lower:])
|
||||
if [ "$opt" = "no$needle" ]; then
|
||||
warning "$(gettext "Options beginning with 'no' will be deprecated in the next version of makepkg!")"
|
||||
plain "$(gettext "Please replace 'no' with '!': no%s -> !%s.")" "$needle" "$needle"
|
||||
echo "n"
|
||||
plain "$(gettext "Please replace 'no' with '!': %s -> %s.")" "no$needle" "!$needle"
|
||||
echo 'n' # Disabled
|
||||
return
|
||||
elif [ "$lc" = "keepdocs" -a "$needle" = "docs" ]; then
|
||||
elif [ "$opt" = "keepdocs" -a "$needle" = "docs" ]; then
|
||||
warning "$(gettext "Option 'keepdocs' may not work as intended. Please replace with 'docs'.")"
|
||||
# END DEPRECATED
|
||||
echo 'y' # Enabled
|
||||
return
|
||||
fi
|
||||
done
|
||||
# END DEPRECATED
|
||||
|
||||
# fall back to makepkg.conf options
|
||||
for i in ${OPTIONS[@]}; do
|
||||
local lc=$(echo $i | tr [:upper:] [:lower:])
|
||||
if [ "$lc" = "$needle" ]; then
|
||||
echo "y"
|
||||
return
|
||||
elif [ "$lc" = "!$needle" ]; then
|
||||
echo "n"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "$(gettext "unknown")"
|
||||
return
|
||||
ret=$(in_opt_array "$1" ${OPTIONS[@]})
|
||||
if [ "$ret" != '?' ]; then
|
||||
echo $ret
|
||||
return
|
||||
fi
|
||||
|
||||
echo '?' # Not Found
|
||||
}
|
||||
|
||||
# check if option is present in BUILDENV
|
||||
|
||||
##
|
||||
# Check if option is present in BUILDENV
|
||||
#
|
||||
# usage : check_buildenv( $option )
|
||||
# return : y - enabled
|
||||
# n - disabled
|
||||
# ? - not found
|
||||
##
|
||||
check_buildenv() {
|
||||
local needle=$(echo $1 | tr [:upper:] [:lower:])
|
||||
local i
|
||||
# use options from makepkg.conf
|
||||
for i in ${BUILDENV[@]}; do
|
||||
local lc=$(echo $i | tr [:upper:] [:lower:])
|
||||
if [ "$lc" = "$needle" ]; then
|
||||
echo "y"
|
||||
echo $(in_opt_array "$1" ${BUILDENV[@]})
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# usage : in_opt_array( $needle, $haystack )
|
||||
# return : y - enabled
|
||||
# n - disabled
|
||||
# ? - not found
|
||||
##
|
||||
in_opt_array() {
|
||||
local needle=$(echo $1 | tr [:upper:] [:lower:]); shift
|
||||
|
||||
local opt
|
||||
for opt in "$@"; do
|
||||
opt=$(echo $opt | tr [:upper:] [:lower:])
|
||||
if [ "$opt" = "$needle" ]; then
|
||||
echo 'y' # Enabled
|
||||
return
|
||||
elif [ "$lc" = "!$needle" ]; then
|
||||
echo "n"
|
||||
elif [ "$opt" = "!$needle" ]; then
|
||||
echo 'n' # Disabled
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "$(gettext "unknown")"
|
||||
return
|
||||
|
||||
echo '?' # Not Found
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# usage : in_array( $needle, $haystack )
|
||||
# return : 0 - found
|
||||
# 1 - not found
|
||||
##
|
||||
in_array() {
|
||||
local needle=$1
|
||||
shift 1
|
||||
[ -z "$1" ] && return 1
|
||||
for i in $*; do
|
||||
[ "$i" = "$needle" ] && return 0
|
||||
local needle=$1; shift
|
||||
[ -z "$1" ] && return 1 # Not Found
|
||||
local item
|
||||
for item in "$@"; do
|
||||
[ "$item" = "$needle" ] && return 0 # Found
|
||||
done
|
||||
return 1
|
||||
return 1 # Not Found
|
||||
}
|
||||
|
||||
get_downloadclient() {
|
||||
|
|
Loading…
Reference in New Issue