From a0699c1a9fedf8d682dd1371c85b73488416b1e3 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 29 Sep 2012 02:12:51 -0400 Subject: Implement ob_parse_version(). --- diff --git a/lib/metadata.sh b/lib/metadata.sh index fb13916..1ed700f 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -56,6 +56,59 @@ ob_validate_binary_name() return ${?} } +ob_parse_version() +{ + _ob_local _obpv_opt _obpv_upstreamver_var _obpv_distrev_var _obpv_version + + while getopts 'u:d:' _obpv_opt; do + case "${_obpv_opt}" in + u) + _obpv_upstreamver_var="${OPTARG}" + if ! _ob_validate_var_name "${_obpv_upstreamver_var}"; then + _ob_return 125 + return ${?} + fi + ;; + d) + _obpv_distrev_var="${OPTARG}" + if ! _ob_validate_var_name "${_obpv_distrev_var}"; then + _ob_return 125 + return ${?} + fi + ;; + ?) + _ob_return 125 + return ${?} + ;; + esac + done + shift $(($OPTIND - 1)) + + if [ ${#} -eq 1 ]; then + _obpv_version="${1}" + else + _ob_return 125 + return ${?} + fi + + if ! _ob_metadata_do 'validate_version' "${_obpv_version}"; then + _ob_return 1 + return ${?} + fi + + if [ -n "${_obpv_upstreamver_var}" ]; then + eval ${_obpv_upstreamver_var}="$(_ob_metadata_do 'get_upstreamver' \ + "${_obpv_version}")" + fi + if [ -n "${_obpv_distrev_var}" ]; then + eval ${_obpv_distrev_var}="$(_ob_metadata_do 'get_distrev' \ + "${_obpv_version}")" + fi + + _ob_return 0 + return ${?} +} + _ob_metadata_do() { _ob_local _obmd_func -- cgit v0.9.1