summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/metadata.sh53
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