From 5e69b33c9e2cc711314057385777b93fbaf4d52f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 01:10:47 -0400 Subject: ob_match_arch(): Replace generated ERE with native SCL --- diff --git a/lib/metadata.sh b/lib/metadata.sh index 8ce838d..c2aec99 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -188,7 +188,10 @@ ob_match_arch() local arch= local arch_field= local a= - local a_ere= + local match_arch_rest= + local field_arch_rest= + local match_arch_part= + local field_arch_part= if [ ${#} -eq 2 ]; then arch="${1}" @@ -213,14 +216,23 @@ ob_match_arch() return 0 fi - # Generate an ERE to match hyphenated architectures. - a_ere="$(echo "${a}" | \ - sed 's/^any-/[^-]+-/;s/-any-/-[^-]+-/g;s/-any$/-[^-]+/g')" - # "foo-bar-baz" == "foo-any-any" - if echo "${arch}" | grep -E "${a_ere}" >/dev/null 2>&1; then - return 0 - fi + match_arch_rest="${arch}" + field_arch_rest="${a}" + while [ -n "${match_arch_rest}" ] && [ -n "${field_arch_rest}" ] + do + IFS='-' read match_arch_part match_arch_rest <<-EOF + ${match_arch_rest} + EOF + IFS='-' read field_arch_part field_arch_rest <<-EOF + ${field_arch_rest} + EOF + case "${field_arch_part}" in + "${match_arch_part}" | 'any') ;; + *) continue 2;; # Failed match, go to next arch + esac + done + return 0 done -- cgit v0.9.1