index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Andrew Fyfe <andrew@neptune-one.net> | 2007-06-02 18:04:41 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-06-03 22:19:51 -0400 |
commit | 2fb2613ec1106f055776b3173a4e65a3b73a6ae6 (patch) | |
tree | 0d3b733d03fa886f4034a86b813d96c40c8bf5c1 | |
parent | 3b1e67628ec963b4336620699509e706524c3948 (diff) |
-rw-r--r-- | scripts/makepkg.in | 128 |
diff --git a/scripts/makepkg.in b/scripts/makepkg.in index f4f18108..32bf2ad8 100644 --- a/scripts/makepkg.in +++ b/scripts/makepkg.in @@ -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 - fi - done - # 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" + echo 'y' # Enabled return fi done - echo "$(gettext "unknown")" - return + # END DEPRECATED + + # fall back to makepkg.conf options + 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() { |