summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-08-18 10:35:19 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-08-18 10:35:19 (EDT)
commit2522d85a380ce6671c51504cfc7872f8d9b35a50 (patch)
treecd03ed3097488d2b60b4e009f453257fcdbceb44
parent76fd977633b076daf79960a1346ab7bfdd013ef0 (diff)
lib/deps.sh: Remove _ob_local.
-rw-r--r--lib/deps.sh243
1 files changed, 125 insertions, 118 deletions
diff --git a/lib/deps.sh b/lib/deps.sh
index e38680a..8ac3133 100644
--- a/lib/deps.sh
+++ b/lib/deps.sh
@@ -24,73 +24,80 @@ ob_use metadata
ob_parse_dep()
{
- _ob_local _obpd_opt _obpd_pkg_var _obpd_archqual_var _obpd_rel_var \
- _obpd_ver_var _obpd_arches_var _obpd_plats_var \
- _obpd_host_arch _obpd_host_plat _obpd_dep \
- _obpd_pkgarchqual _obpd_pkg _obpd_archqual \
- _obpd_relver _obpd_rel _obpd_ver _obpd_arches _obpd_plats \
- _obpd_comp _obpd_comp_var
-
- while getopts 'p:q:r:v:A:l:a:P:' _obpd_opt; do
- case "${_obpd_opt}" in
+ local opt=
+ local pkg_var=
+ local archqual_var=
+ local rel_var=
+ local ver_var=
+ local arches_var=
+ local plats_var=
+ local host_arch=
+ local host_plat=
+ local dep=
+ local pkgarchqual=
+ local pkg=
+ local archqual=
+ local relver=
+ local rel=
+ local ver=
+ local arches=
+ local plats=
+ local comp=
+ local comp_var=
+
+ while getopts 'p:q:r:v:A:l:a:P:' opt; do
+ case "${opt}" in
p)
- _obpd_pkg_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_pkg_var}"; then
- _ob_return 125
- return ${?}
+ pkg_var="${OPTARG}"
+ if ! _ob_validate_var_name "${pkg_var}"; then
+ return 125
fi
;;
q)
- _obpd_archqual_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_archqual_var}"; then
- _ob_return 125
- return ${?}
+ archqual_var="${OPTARG}"
+ if ! _ob_validate_var_name "${archqual_var}"; then
+ return 125
fi
;;
r)
- _obpd_rel_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_rel_var}"; then
- _ob_return 125
- return ${?}
+ rel_var="${OPTARG}"
+ if ! _ob_validate_var_name "${rel_var}"; then
+ return 125
fi
;;
v)
- _obpd_ver_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_ver_var}"; then
- _ob_return 125
- return ${?}
+ ver_var="${OPTARG}"
+ if ! _ob_validate_var_name "${ver_var}"; then
+ return 125
fi
;;
A)
- _obpd_arches_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_arches_var}"; then
- _ob_return 125
- return ${?}
+ arches_var="${OPTARG}"
+ if ! _ob_validate_var_name "${arches_var}"; then
+ return 125
fi
;;
l)
- _obpd_plats_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpd_plats_var}"; then
- _ob_return 125
- return ${?}
+ plats_var="${OPTARG}"
+ if ! _ob_validate_var_name "${plats_var}"; then
+ return 125
fi
;;
a)
- _obpd_host_arch="${OPTARG}"
+ host_arch="${OPTARG}"
;;
P)
- _obpd_host_plat="${OPTARG}"
+ host_plat="${OPTARG}"
;;
?)
- _ob_return 125
- return ${?}
+ return 125
;;
esac
done
shift $(($OPTIND - 1))
if [ ${#} -eq 1 ]; then
- _obpd_dep="$(printf '%s\n' "${1}" | sed -n '
+ dep="$(printf '%s\n' "${1}" | sed -n '
H; # Store each input line in the hold space.
${
g; # Restore everything to the pattern space.
@@ -107,141 +114,141 @@ ob_parse_dep()
};
')"
else
- _ob_return 125
- return ${?}
+ return 125
fi
# pkg[:archqual] [(rel ver)] [\[arches\]] [<plats>]
- _obpd_pkgarchqual="${_obpd_dep%% *}"
- _obpd_dep=" ${_obpd_dep#* }"
- _obpd_pkg="${_obpd_pkgarchqual%:*}"
- if [ "${_obpd_pkg}" != "${_obpd_pkgarchqual}" ]; then
- _obpd_archqual="${_obpd_pkgarchqual##*:}"
+ pkgarchqual="${dep%% *}"
+ dep=" ${dep#* }"
+ pkg="${pkgarchqual%:*}"
+ if [ "${pkg}" != "${pkgarchqual}" ]; then
+ archqual="${pkgarchqual##*:}"
fi
- if [ "${_obpd_dep# (*)}" != "${_obpd_dep}" ]; then
- _obpd_relver="${_obpd_dep# (}"
- _obpd_relver="${_obpd_relver%%)*}"
- _obpd_dep="${_obpd_dep# (*)}"
- _obpd_rel="${_obpd_relver% *}"
- _obpd_ver="${_obpd_relver##* }"
+ if [ "${dep# (*)}" != "${dep}" ]; then
+ relver="${dep# (}"
+ relver="${relver%%)*}"
+ dep="${dep# (*)}"
+ rel="${relver% *}"
+ ver="${relver##* }"
fi
- if [ "${_obpd_dep# \[*\]}" != "${_obpd_dep}" ]; then
- _obpd_arches="${_obpd_dep# \[}"
- _obpd_arches="${_obpd_arches%%\]*}"
- _obpd_dep="${_obpd_dep# \[*\]}"
+ if [ "${dep# \[*\]}" != "${dep}" ]; then
+ arches="${dep# \[}"
+ arches="${arches%%\]*}"
+ dep="${dep# \[*\]}"
fi
- if [ "${_obpd_dep# <*>}" != "${_obpd_dep}" ]; then
- _obpd_plats="${_obpd_dep# <}"
- _obpd_plats="${_obpd_plats%%>*}"
- _obpd_dep="${_obpd_dep# <*>}"
+ if [ "${dep# <*>}" != "${dep}" ]; then
+ plats="${dep# <}"
+ plats="${plats%%>*}"
+ dep="${dep# <*>}"
fi
# Set the specified variables.
- for _obpd_comp in pkg archqual rel ver arches plats; do
- _obpd_comp_var="$(eval echo \"\$\{_obpd_${_obpd_comp}_var\}\")"
- [ -z "${_obpd_comp_var}" ] && continue
- eval ${_obpd_comp_var}=\"\$\{_obpd_${_obpd_comp}\}\"
+ for comp in pkg archqual rel ver arches plats; do
+ comp_var="$(eval echo \"\$\{${comp}_var\}\")"
+ [ -z "${comp_var}" ] && continue
+ eval ${comp_var}=\"\$\{${comp}\}\"
done
- if [ -n "${_obpd_host_arch}" ] && ! ob_arch_is_concerned \
- "${_obpd_host_arch}" "${_obpd_arches}"; then
- _ob_return 0
- return ${?}
+ if [ -n "${host_arch}" ] && ! ob_arch_is_concerned \
+ "${host_arch}" "${arches}"; then
+ return 0
fi
- if [ -n "${_obpd_host_plat}" ] && ! ob_plat_is_concerned \
- "${_obpd_host_plat}" "${_obpd_plats}"; then
- _ob_return 0
- return ${?}
+ if [ -n "${host_plat}" ] && ! ob_plat_is_concerned \
+ "${host_plat}" "${plats}"; then
+ return 0
fi
- printf '%s' "${_obpd_pkg}"
- [ -n "${_obpd_archqual}" ] && printf ':%s' "${_obpd_archqual}"
- [ -n "${_obpd_ver}" ] && printf ' (%s %s)' "${_obpd_rel}" "${_obpd_ver}"
- [ -z "${_obpd_host_arch}" -a -n "${_obpd_arches}" ] && \
- printf ' [%s]' "${_obpd_arches}"
- [ -z "${_obpd_host_plat}" -a -n "${_obpd_plats}" ] && \
- printf ' [%s]' "${_obpd_plats}"
+ printf '%s' "${pkg}"
+ [ -n "${archqual}" ] && printf ':%s' "${archqual}"
+ [ -n "${ver}" ] && printf ' (%s %s)' "${rel}" "${ver}"
+ [ -z "${host_arch}" -a -n "${arches}" ] && \
+ printf ' [%s]' "${arches}"
+ [ -z "${host_plat}" -a -n "${plats}" ] && \
+ printf ' [%s]' "${plats}"
printf '\n'
- _ob_return 0
- return ${?}
+ return 0
}
ob_reduce_deps()
{
- _ob_local _obrd_opt _obrd_host_arch _obrd_host_plat _obrd_deps \
- _obrd_dep_and _obrd_dep_or _obrd_dep_list _obrd_dep_or_list _obrd_dep
-
- _obrd_union='false'
-
- while getopts 'a:P:u' _obrd_opt; do
- case "${_obrd_opt}" in
+ local opt=
+ local host_arch=
+ local host_plat=
+ local deps=
+ local dep_and=
+ local dep_or=
+ local dep_list=
+ local dep_or_list=
+ local dep=
+
+ union='false'
+
+ while getopts 'a:P:u' opt; do
+ case "${opt}" in
a)
- _obrd_host_arch="${OPTARG}"
+ host_arch="${OPTARG}"
;;
P)
- _obrd_host_plat="${OPTARG}"
+ host_plat="${OPTARG}"
;;
u)
- _obrd_union='true'
+ union='true'
;;
?)
- _ob_return 125
- return ${?}
+ return 125
;;
esac
done
shift $(($OPTIND - 1))
if [ ${#} -eq 1 ]; then
- _obrd_deps="${1}"
+ deps="${1}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
IFS=','
- for _obrd_dep_and in ${_obrd_deps}; do
+ for dep_and in ${deps}; do
unset IFS
- if ! ${_obrd_union}; then
+ if ! ${union}; then
IFS='|'
- _obrd_dep_or_list=
- for _obrd_dep_or in ${_obrd_dep_and}; do
+ dep_or_list=
+ for dep_or in ${dep_and}; do
unset IFS
- _obrd_dep="$(ob_parse_dep -a "${_obrd_host_arch}" \
- -P "${_obrd_host_plat}" "${_obrd_dep_or}")"
- if [ -n "${_obrd_dep}" ]; then
- if [ -n "${_obrd_dep_or_list}" ]; then
- _obrd_dep_or_list="${_obrd_dep_or_list} | "
+ dep="$(ob_parse_dep -a "${host_arch}" \
+ -P "${host_plat}" "${dep_or}")"
+ if [ -n "${dep}" ]; then
+ if [ -n "${dep_or_list}" ]; then
+ dep_or_list="${dep_or_list} | "
fi
- _obrd_dep_or_list="${_obrd_dep_or_list}${_obrd_dep}"
+ dep_or_list="${dep_or_list}${dep}"
fi
done
- if [ -n "${_obrd_dep_or_list}" ]; then
- if [ -n "${_obrd_dep_list}" ]; then
- _obrd_dep_list="${_obrd_dep_list}, "
+ if [ -n "${dep_or_list}" ]; then
+ if [ -n "${dep_list}" ]; then
+ dep_list="${dep_list}, "
fi
- _obrd_dep_list="${_obrd_dep_list}${_obrd_dep_or_list}"
+ dep_list="${dep_list}${dep_or_list}"
fi
else
- _obrd_dep="$(ob_parse_dep -a "${_obrd_host_arch}" \
- -P "${_obrd_host_plat}" "${_obrd_dep_and}")"
- if [ -n "${_obrd_dep}" ]; then
- if [ -n "${_obrd_dep_list}" ]; then
- _obrd_dep_list="${_obrd_dep_list}, "
+ dep="$(ob_parse_dep -a "${host_arch}" \
+ -P "${host_plat}" "${dep_and}")"
+ if [ -n "${dep}" ]; then
+ if [ -n "${dep_list}" ]; then
+ dep_list="${dep_list}, "
fi
- _obrd_dep_list="${_obrd_dep_list}${_obrd_dep}"
+ dep_list="${dep_list}${dep}"
fi
fi
done
unset IFS
- echo "${_obrd_dep_list}"
+ echo "${dep_list}"
- _ob_return 0
- return ${?}
+ return 0
}