diff options
author | P. J. McDermott <pjm@nac.net> | 2012-09-29 02:12:51 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-09-29 02:12:51 (EDT) |
commit | a0699c1a9fedf8d682dd1371c85b73488416b1e3 (patch) | |
tree | 250a889d11174563d01045247036ea9d230a0f05 /lib | |
parent | 9cee0dbd39c165cb573bc090a05e36efdabcfdf7 (diff) |
Implement ob_parse_version().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/metadata.sh | 53 |
1 files changed, 53 insertions, 0 deletions
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 |