diff options
author | P. J. McDermott <pjm@nac.net> | 2012-10-25 18:23:47 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-10-25 18:23:47 (EDT) |
commit | 48518a660369997ec0d92f4520a89c343258664f (patch) | |
tree | 7417c488244a064d46e48d611f63476c9204e027 /lib | |
parent | 58ac6317842e2f113912e60b895fdb722302e4b8 (diff) | |
parent | e83b58d51eca2bf082cea326e712570aa51c4ad1 (diff) |
Merge branch 'feature/reduce-plat-in-deps'.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/deps.sh | 100 |
1 files changed, 80 insertions, 20 deletions
diff --git a/lib/deps.sh b/lib/deps.sh index 03f0685..5584e65 100644 --- a/lib/deps.sh +++ b/lib/deps.sh @@ -25,12 +25,13 @@ 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_host_arch _obpd_dep \ + _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_relver _obpd_rel _obpd_ver _obpd_arches _obpd_plats \ _obpd_comp _obpd_comp_var - while getopts 'p:q:r:v:A:a:' _obpd_opt; do + while getopts 'p:q:r:v:A:l:a:P:' _obpd_opt; do case "${_obpd_opt}" in p) _obpd_pkg_var="${OPTARG}" @@ -67,9 +68,19 @@ ob_parse_dep() return ${?} fi ;; + l) + _obpd_plats_var="${OPTARG}" + if ! _ob_validate_var_name "${_obpd_plats_var}"; then + _ob_return 125 + return ${?} + fi + ;; a) _obpd_host_arch="${OPTARG}" ;; + P) + _obpd_host_plat="${OPTARG}" + ;; ?) _ob_return 125 return ${?} @@ -90,7 +101,7 @@ ob_parse_dep() return ${?} fi - # <pkg>[:<archqual>] [(<rel> <ver>)] [\[<arches>\]] + # <pkg>[:<archqual>] [(<rel> <ver>)] [\[<arches>\]] [\<<plats>\>] _obpd_pkgarchqual="${_obpd_dep%% *}" _obpd_dep=" ${_obpd_dep#* }" @@ -110,45 +121,62 @@ ob_parse_dep() if [ "${_obpd_dep# \[*\]}" != "${_obpd_dep}" ]; then _obpd_arches="${_obpd_dep# \[}" _obpd_arches="${_obpd_arches%%\]*}" + _obpd_dep="${_obpd_dep# \[*\]}" + fi + + if [ "${_obpd_dep# <*>}" != "${_obpd_dep}" ]; then + _obpd_plats="${_obpd_dep# <}" + _obpd_plats="${_obpd_arches%%>*}" + _obpd_dep="${_obpd_dep# <*>}" fi # Set the specified variables. - for _obpd_comp in pkg archqual rel ver arches; do + 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}\}\" done - if [ -z "${_obpd_host_arch}" ]; then - printf '%s' "${_obpd_pkg}" - [ -n "${_obpd_archqual}" ] && printf ':%s' "${_obpd_archqual}" - [ -n "${_obpd_ver}" ] && printf ' (%s %s)' "${_obpd_rel}" "${_obpd_ver}" - [ -n "${_obpd_arches}" ] && printf ' [%s]' "${_obpd_arches}" - printf '\n' - elif _ob_dep_arch_is_concerned "${_obpd_host_arch}" "${_obpd_arches}"; then - printf '%s' "${_obpd_pkg}" - [ -n "${_obpd_archqual}" ] && printf ':%s' "${_obpd_archqual}" - [ -n "${_obpd_ver}" ] && printf ' (%s %s)' "${_obpd_rel}" "${_obpd_ver}" - printf '\n' + if [ -n "${_obpd_host_arch}" ] && ! _ob_dep_arch_is_concerned \ + "${_obpd_host_arch}" "${_obpd_arches}"; then + _ob_return 0 + return ${?} + fi + if [ -n "${_obpd_host_plat}" ] && ! _ob_dep_plat_is_concerned \ + "${_obpd_host_plat}" "${_obpd_plats}"; then + _ob_return 0 + return ${?} 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 '\n' + _ob_return 0 return ${?} } ob_reduce_deps() { - _ob_local _obrd_opt _obrd_host_arch _obrd_deps \ + _ob_local _obrd_opt _obrd_host_arch _obrd_host_plat _obrd_deps \ _obrd_orig_ifs _obrd_dep_and _obrd_dep_or \ _obrd_dep_list _obrd_dep_or_list _obrd_dep _obrd_union='false' - while getopts 'a:u' _obrd_opt; do + while getopts 'a:P:u' _obrd_opt; do case "${_obrd_opt}" in a) _obrd_host_arch="${OPTARG}" ;; + P) + _obrd_host_plat="${OPTARG}" + ;; u) _obrd_union='true' ;; @@ -177,7 +205,7 @@ ob_reduce_deps() for _obrd_dep_or in ${_obrd_dep_and}; do IFS="${_obrd_orig_ifs}" _obrd_dep="$(ob_parse_dep -a "${_obrd_host_arch}" \ - "${_obrd_dep_or}")" + -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} | " @@ -193,7 +221,7 @@ ob_reduce_deps() fi else _obrd_dep="$(ob_parse_dep -a "${_obrd_host_arch}" \ - "${_obrd_dep_and}")" + -P "${_obrd_host_plat}" "${_obrd_dep_and}")" if [ -n "${_obrd_dep}" ]; then if [ -n "${_obrd_dep_list}" ]; then _obrd_dep_list="${_obrd_dep_list}, " @@ -240,3 +268,35 @@ _ob_dep_arch_is_concerned() _ob_return ${_obdaic_seen_arch} return ${?} } + +_ob_dep_plat_is_concerned() +{ + _ob_local _obdpic_host_plat _obdpic_plats \ + _obdpic_plat _obdpic_not_plat _obdpic_seen_plat + + _obdpic_host_plat="${1}" + _obdpic_plats="${2}" + _obdpic_seen_plat=1 + + if [ -z "${_obdpic_plats}" ]; then + _obdpic_seen_plat=0 + fi + + for _obdpic_plat in ${_obdpic_plats}; do + _obdpic_not_plat="${_obdpic_plat#!}" + if [ "${_obdpic_not_plat}" != "${_obdpic_plat}" ]; then + if ob_match_plat "${_obdpic_host_plat}" "${_obdpic_not_plat}"; then + _obdpic_seen_plat=1 + break + else + _obdpic_seen_plat=0 + fi + elif ob_match_plat "${_obdpic_host_plat}" "${_obdpic_plat}"; then + _obdpic_seen_plat=0 + break + fi + done + + _ob_return ${_obdpic_seen_plat} + return ${?} +} |