summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/metadata.sh243
1 files changed, 111 insertions, 132 deletions
diff --git a/lib/metadata.sh b/lib/metadata.sh
index c2ad84a..e25abd5 100644
--- a/lib/metadata.sh
+++ b/lib/metadata.sh
@@ -24,301 +24,280 @@ ob_use 'metadata/@@METADATA@@'
ob_validate_source_name()
{
- _ob_local _obvsn_name
+ local name=
if [ ${#} -eq 1 ]; then
- _obvsn_name="${1}"
+ name="${1}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- _ob_metadata_do 'validate_source_name' "${_obvsn_name}"
+ _ob_metadata_do 'validate_source_name' "${name}"
- _ob_return ${?}
return ${?}
}
ob_validate_binary_name()
{
- _ob_local _obvbn_name
+ local name=
if [ ${#} -eq 1 ]; then
- _obvbn_name="${1}"
+ name="${1}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- _ob_metadata_do 'validate_binary_name' "${_obvbn_name}"
+ _ob_metadata_do 'validate_binary_name' "${name}"
- _ob_return ${?}
return ${?}
}
ob_parse_version()
{
- _ob_local _obpv_opt _obpv_upstreamver_var _obpv_distrev_var _obpv_version
+ local opt=
+ local upstreamver_var=
+ local distrev_var=
+ local version=
- while getopts 'u:d:' _obpv_opt; do
- case "${_obpv_opt}" in
+ while getopts 'u:d:' opt; do
+ case "${opt}" in
u)
- _obpv_upstreamver_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpv_upstreamver_var}"; then
- _ob_return 125
- return ${?}
+ upstreamver_var="${OPTARG}"
+ if ! _ob_validate_var_name "${upstreamver_var}"; then
+ return 125
fi
;;
d)
- _obpv_distrev_var="${OPTARG}"
- if ! _ob_validate_var_name "${_obpv_distrev_var}"; then
- _ob_return 125
- return ${?}
+ distrev_var="${OPTARG}"
+ if ! _ob_validate_var_name "${distrev_var}"; then
+ return 125
fi
;;
?)
- _ob_return 125
- return ${?}
+ return 125
;;
esac
done
shift $(($OPTIND - 1))
if [ ${#} -eq 1 ]; then
- _obpv_version="${1}"
+ version="${1}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- if ! _ob_metadata_do 'validate_version' "${_obpv_version}"; then
- _ob_return 1
- return ${?}
+ if ! _ob_metadata_do 'validate_version' "${version}"; then
+ return 1
fi
- if [ -n "${_obpv_upstreamver_var}" ]; then
- eval ${_obpv_upstreamver_var}="$(_ob_metadata_do 'get_upstreamver' \
- "${_obpv_version}")"
+ if [ -n "${upstreamver_var}" ]; then
+ eval ${upstreamver_var}="$(_ob_metadata_do 'get_upstreamver' \
+ "${version}")"
fi
- if [ -n "${_obpv_distrev_var}" ]; then
- eval ${_obpv_distrev_var}="$(_ob_metadata_do 'get_distrev' \
- "${_obpv_version}")"
+ if [ -n "${distrev_var}" ]; then
+ eval ${distrev_var}="$(_ob_metadata_do 'get_distrev' \
+ "${version}")"
fi
- _ob_return 0
- return ${?}
+ return 0
}
ob_get_system_arch()
{
- _ob_local
-
if [ ${#} -gt 0 ]; then
- _ob_return 125
- return ${?}
+ return 125
fi
_ob_metadata_do 'get_system_arch'
- _ob_return ${?}
return ${?}
}
ob_get_system_plat()
{
- _ob_local
-
if [ ${#} -gt 0 ]; then
- _ob_return 125
- return ${?}
+ return 125
fi
_ob_metadata_do 'get_system_plat'
- _ob_return ${?}
return ${?}
}
ob_match_arch()
{
- _ob_local _obma_arch _obma_arch_field _obma_a \
- _obma_a_pat_norm _obma_a_pat_hyph
+ local arch=
+ local arch_field=
+ local a=
+ local a_ere=
if [ ${#} -eq 2 ]; then
- _obma_arch="${1}"
- _obma_arch_field="${2}"
+ arch="${1}"
+ arch_field="${2}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- for _obma_a in ${_obma_arch_field}; do
+ for a in ${arch_field}; do
# "all" == "all"
- if [ "${_obma_arch}" = 'all' ]; then
- if [ "${_obma_a}" = 'all' ]; then
- _ob_return 0
- return ${?}
+ if [ "${arch}" = 'all' ]; then
+ if [ "${a}" = 'all' ]; then
+ return 0
else
continue
fi
fi
# "foo-bar-baz" == "any"
- if [ "${_obma_a}" = 'any' ]; then
- _ob_return 0
- return ${?}
+ if [ "${a}" = 'any' ]; then
+ return 0
fi
# Generate an ERE to match hyphenated architectures.
- _obma_a_ere="$(echo "${_obma_a}" | \
+ a_ere="$(echo "${a}" | \
sed 's/^any-/[^-]+-/;s/-any-/-[^-]+-/g;s/-any$/-[^-]+/g')"
# "foo-bar-baz" == "foo-any-any"
- if echo "${_obma_arch}" | grep -E "${_obma_a_ere}" >/dev/null 2>&1; then
- _ob_return 0
- return ${?}
+ if echo "${arch}" | grep -E "${a_ere}" >/dev/null 2>&1; then
+ return 0
fi
done
# Nothing matched.
- _ob_return 1
- return ${?}
+ return 1
}
ob_match_plat()
{
- _ob_local _obmp_plat _obmp_plat_field _obmp_p
+ local plat=
+ local plat_field=
+ local p=
if [ ${#} -eq 2 ]; then
- _obmp_plat="${1}"
- _obmp_plat_field="${2}"
+ plat="${1}"
+ plat_field="${2}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- for _obmp_p in ${_obmp_plat_field}; do
- if [ "${_obmp_plat}" = 'all' ]; then
- if [ "${_obmp_p}" = 'all' ]; then
- _ob_return 0
- return ${?}
+ for p in ${plat_field}; do
+ if [ "${plat}" = 'all' ]; then
+ if [ "${p}" = 'all' ]; then
+ return 0
else
continue
fi
fi
- if [ "${_obmp_p}" = 'any' ]; then
- _ob_return 0
- return ${?}
+ if [ "${p}" = 'any' ]; then
+ return 0
fi
done
- _ob_return 1
- return ${?}
+ return 1
}
ob_arch_is_concerned()
{
- _ob_local _obaic_host_arch _obaic_arches \
- _obaic_arch _obaic_not_arch _obaic_seen_arch
+ local host_arch=
+ local arches=
+ local arch=
+ local not_arch=
+ local seen_arch=
if [ ${#} -eq 2 ]; then
- _obaic_host_arch="${1}"
- _obaic_arches="${2}"
+ host_arch="${1}"
+ arches="${2}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- _obaic_seen_arch=1
- if [ -z "${_obaic_arches}" ]; then
- _obaic_seen_arch=0
+ seen_arch=1
+ if [ -z "${arches}" ]; then
+ seen_arch=0
fi
- for _obaic_arch in ${_obaic_arches}; do
- _obaic_not_arch="${_obaic_arch#!}"
- if [ "${_obaic_not_arch}" != "${_obaic_arch}" ]; then
- if ob_match_arch "${_obaic_host_arch}" "${_obaic_not_arch}"; then
- _obaic_seen_arch=1
+ for arch in ${arches}; do
+ not_arch="${arch#!}"
+ if [ "${not_arch}" != "${arch}" ]; then
+ if ob_match_arch "${host_arch}" "${not_arch}"; then
+ seen_arch=1
break
else
- _obaic_seen_arch=0
+ seen_arch=0
fi
- elif ob_match_arch "${_obaic_host_arch}" "${_obaic_arch}"; then
- _obaic_seen_arch=0
+ elif ob_match_arch "${host_arch}" "${arch}"; then
+ seen_arch=0
break
fi
done
- _ob_return ${_obaic_seen_arch}
- return ${?}
+ return ${seen_arch}
}
ob_plat_is_concerned()
{
- _ob_local _obpic_host_plat _obpic_plats \
- _obpic_plat _obpic_not_plat _obpic_seen_plat
+ local host_plat=
+ local plats=
+ local plat=
+ local not_plat=
+ local seen_plat=
if [ ${#} -eq 2 ]; then
- _obpic_host_plat="${1}"
- _obpic_plats="${2}"
+ host_plat="${1}"
+ plats="${2}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
- _obpic_seen_plat=1
- if [ -z "${_obpic_plats}" ]; then
- _obpic_seen_plat=0
+ seen_plat=1
+ if [ -z "${plats}" ]; then
+ seen_plat=0
fi
- for _obpic_plat in ${_obpic_plats}; do
- _obpic_not_plat="${_obpic_plat#!}"
- if [ "${_obpic_not_plat}" != "${_obpic_plat}" ]; then
- if ob_match_plat "${_obpic_host_plat}" "${_obpic_not_plat}"; then
- _obpic_seen_plat=1
+ for plat in ${plats}; do
+ not_plat="${plat#!}"
+ if [ "${not_plat}" != "${plat}" ]; then
+ if ob_match_plat "${host_plat}" "${not_plat}"; then
+ seen_plat=1
break
else
- _obpic_seen_plat=0
+ seen_plat=0
fi
- elif ob_match_plat "${_obpic_host_plat}" "${_obpic_plat}"; then
- _obpic_seen_plat=0
+ elif ob_match_plat "${host_plat}" "${plat}"; then
+ seen_plat=0
break
fi
done
- _ob_return ${_obpic_seen_plat}
- return ${?}
+ return ${seen_plat}
}
ob_get_system_path()
{
- _ob_local _obgsp_path_id
+ local path_id=
if [ ${#} -ge 1 ]; then
- _obgsp_path_id="${1}"
+ path_id="${1}"
shift 1
else
- _ob_return 125
- return ${?}
+ return 125
fi
- _ob_metadata_do 'get_system_path' "${_obgsp_path_id}" "${@}"
+ _ob_metadata_do 'get_system_path' "${path_id}" "${@}"
- _ob_return ${?}
return ${?}
}
_ob_metadata_do()
{
- _ob_local _obmd_func
+ local func=
- _obmd_func="${1}"
+ func="${1}"
shift 1
- "_ob_${_obmd_func}_@@METADATA@@" "${@}"
+ "_ob_${func}_@@METADATA@@" "${@}"
- _ob_return ${?}
return ${?}
}