mirror of
https://github.com/envmodules/modules.git
synced 2026-06-18 00:06:53 +08:00
install: add check_and_get_package_value in configure
This commit is contained in:
65
configure
vendored
65
configure
vendored
@@ -88,6 +88,7 @@ RMDIR_IGN_NON_EMPTY='rmdir'
|
||||
SED_ERE='sed -E'
|
||||
VERSION=
|
||||
RELEASE=
|
||||
# shellcheck disable=SC2034
|
||||
initconfin=etcdir
|
||||
loggedevents=
|
||||
logger='logger'
|
||||
@@ -563,6 +564,21 @@ get_package_value() {
|
||||
fi
|
||||
}
|
||||
|
||||
check_and_get_package_value() {
|
||||
typeset value_raw="$2"
|
||||
typeset option="$3"
|
||||
typeset allowed_values="$4"
|
||||
typeset val_if_unset="$5"
|
||||
|
||||
value=$(get_package_value "$value_raw" "$val_if_unset")
|
||||
if [ "${allowed_values// $value /}" = "$allowed_values" ]; then
|
||||
echo_error "Bad value for option \`$option'"\
|
||||
"Allowed values are:$allowed_values"
|
||||
fi
|
||||
|
||||
typeset -g "$1"="$value"
|
||||
}
|
||||
|
||||
check_and_get_package_value_list() {
|
||||
typeset value_raw="$2"
|
||||
typeset option="$3"
|
||||
@@ -732,12 +748,9 @@ for arg in "$@"; do
|
||||
--with-moduleshome=*|--without-moduleshome)
|
||||
moduleshome=$(get_package_value "$arg") ;;
|
||||
--with-initconf-in=*|--without-initconf-in)
|
||||
initconfin=$(get_package_value "$arg") ;
|
||||
allowedval=" initdir etcdir " ;
|
||||
if [ "${allowedval// $initconfin /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-initconf-in'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "initconfin" "$arg" "--with-initconf-in"\
|
||||
"$allowedval" ;;
|
||||
--with-tclsh=*|--without-tclsh)
|
||||
tclshbin=$(get_package_value "$arg") ;;
|
||||
--with-logger=*|--without-logger)
|
||||
@@ -755,12 +768,9 @@ for arg in "$@"; do
|
||||
pageropts=$(get_package_value "$arg")
|
||||
defpageropts=0 ;;
|
||||
--with-verbosity=*|--without-verbosity)
|
||||
verbosity=$(get_package_value "$arg")
|
||||
allowedval=" silent concise normal verbose trace debug debug2 " ;
|
||||
if [ "${allowedval// $verbosity /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-verbosity'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "verbosity" "$arg" "--with-verbosity"\
|
||||
"$allowedval" ;;
|
||||
--enable-color*|--disable-color)
|
||||
# shellcheck disable=SC2034
|
||||
color=$(get_feature_value "$arg") ;;
|
||||
@@ -774,12 +784,9 @@ for arg in "$@"; do
|
||||
--with-light-background-colors=*|--without-light-background-colors)
|
||||
lightbgcolors=$(get_package_value "$arg") ;;
|
||||
--with-terminal-background=*|--without-terminal-background)
|
||||
termbg=$(get_package_value "$arg") ;
|
||||
allowedval=" dark light " ;
|
||||
if [ "${allowedval// $termbg /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-terminal-background'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "termbg" "$arg"\
|
||||
"--with-terminal-background" "$allowedval" ;;
|
||||
--with-locked-configs*|--disable-locked-configs)
|
||||
lockedconfigs=$(get_package_value "$arg") ;
|
||||
allowedval=" extra_siteconfig implicit_default logged_events logger " ;
|
||||
@@ -790,26 +797,17 @@ for arg in "$@"; do
|
||||
fi ;
|
||||
done ;;
|
||||
--with-unload-match-order*|--without-unload-match-order)
|
||||
unloadmatchorder=$(get_package_value "$arg") ;
|
||||
allowedval=" returnlast returnfirst " ;
|
||||
if [ "${allowedval// $unloadmatchorder /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-unload-match-order'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "unloadmatchorder" "$arg"\
|
||||
"--with-unload-match-order" "$allowedval" ;;
|
||||
--with-search-match*|--without-search-match)
|
||||
searchmatch=$(get_package_value "$arg") ;
|
||||
allowedval=" starts_with contains " ;
|
||||
if [ "${allowedval// $searchmatch /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-search-match'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "searchmatch" "$arg" "--with-search-match"\
|
||||
"$allowedval" ;;
|
||||
--with-icase*|--without-icase)
|
||||
icase=$(get_package_value "$arg") ;
|
||||
allowedval=" never search always " ;
|
||||
if [ "${allowedval// $icase /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-icase'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "icase" "$arg" "--with-icase"\
|
||||
"$allowedval" ;;
|
||||
--with-nearly-forbidden-days*|--without-nearly-forbidden-days)
|
||||
nearlyforbiddendays=$(get_package_value "$arg") ;
|
||||
if [ -z "$nearlyforbiddendays" ] || ! [ "$nearlyforbiddendays" -eq "$nearlyforbiddendays" ] 2>/dev/null\
|
||||
@@ -822,12 +820,9 @@ for arg in "$@"; do
|
||||
--with-tag-color-name*|--without-tag-color-name)
|
||||
tagcolorname=$(get_package_value "$arg") ;;
|
||||
--with-sticky-purge*|--without-sticky-purge)
|
||||
stickypurge=$(get_package_value "$arg" "error") ;
|
||||
allowedval=" error warning silent " ;
|
||||
if [ "${allowedval// $stickypurge /}" = "$allowedval" ]; then
|
||||
echo_error "Bad value for option \`--with-sticky-purge'"\
|
||||
"Allowed values are:$allowedval"
|
||||
fi ;;
|
||||
check_and_get_package_value "stickypurge" "$arg" "--with-sticky-purge"\
|
||||
"$allowedval" "error" ;;
|
||||
--with-abort-on-error*|--without-abort-on-error)
|
||||
allowedval=" load ml mod-to-sh purge reload switch switch_unload try-load unload " ;
|
||||
check_and_get_package_value_list "abortonerror" "$arg"\
|
||||
|
||||
Reference in New Issue
Block a user