diff options
Diffstat (limited to 'lib/metadata.sh')
-rw-r--r-- | lib/metadata.sh | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/lib/metadata.sh b/lib/metadata.sh index 28a984b..687d96a 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -139,6 +139,95 @@ ob_get_system_plat() return ${?} } +ob_match_arch() +{ + _ob_local _obma_arch _obma_arch_field _obma_a \ + _obma_a_pat_norm _obma_a_pat_hyph + + if [ ${#} -eq 2 ]; then + _obma_arch="${1}" + _obma_arch_field="${2}" + else + _ob_return 125 + return ${?} + fi + + for _obma_a in ${_obma_arch_field}; do + + # "all" == "all" + if [ "${_obma_arch}" = 'all' ]; then + if [ "${_obma_a}" = 'all' ]; then + _ob_return 0 + return ${?} + else + continue + fi + fi + + # "foo-bar-baz" == "any" + if [ "${_obma_a}" = 'any' ]; then + _ob_return 0 + return ${?} + fi + + # Compile patterns to match hyphenated architectures. + _obma_a_pat_norm="$(echo "${_obma_a}" | \ + sed 's/^any-/*-/;s/-any-/-*-/g;s/-any$/-*/g')" + _obma_a_pat_hyph="$(echo "${_obma_a}" | \ + sed 's/^any-/*-*-/;s/-any-/-*-*-/g;s/-any$/-*-*/g')" + + # "foo-bar-baz" == "foo-any-any" + case "${_obma_arch}" in + ${_obma_a_pat_hyph}) + continue + ;; + ${_obma_a_pat_norm}) + _ob_return 0 + return ${?} + ;; + *) + continue + ;; + esac + + done + + # Nothing matched. + _ob_return 1 + return ${?} +} + +ob_match_plat() +{ + _ob_local _obmp_plat _obmp_plat_field _obmp_p + + if [ ${#} -eq 2 ]; then + _obmp_plat="${1}" + _obmp_plat_field="${2}" + else + _ob_return 125 + return ${?} + fi + + for _obmp_p in ${_obmp_plat_field}; do + if [ "${_obmp_plat}" = 'all' ]; then + if [ "${_obmp_p}" = 'all' ]; then + _ob_return 0 + return ${?} + else + continue + fi + fi + if [ "${_obmp_p}" = 'any' ]; then + _ob_return 0 + return ${?} + fi + done + + _ob_return 1 + return ${?} +} + _ob_metadata_do() { _ob_local _obmd_func |