From 4f4e162feb5644eb3acc8dc8fb04138b850a6d5d Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 18 Aug 2013 10:57:11 -0400 Subject: lib/package.sh: Remove _ob_local. --- diff --git a/lib/package.sh b/lib/package.sh index 4b5ce6a..4d040ab 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -30,16 +30,16 @@ _OB_BINARY_PARAMETERS= ob_init_package() { - _ob_local _obip_dir _obip_orig_text_domain + local dir= + local orig_text_domain= if [ ${#} -eq 1 ]; then - _obip_dir="${1}" + dir="${1}" else - _ob_return 125 - return ${?} + return 125 fi - _OB_PACKAGE_DIR="$(cd "${_obip_dir}" && pwd)" + _OB_PACKAGE_DIR="$(cd "${dir}" && pwd)" if [ -r "${_OB_PACKAGE_DIR}/format" ]; then case "$(cat "${_OB_PACKAGE_DIR}/format")" in @@ -50,110 +50,111 @@ ob_init_package() fi if [ -z "${_OB_PACKAGE_FORMAT}" ]; then - _obip_orig_text_domain="$(ob_get_text_domain)" + orig_text_domain="$(ob_get_text_domain)" ob_set_text_domain "${_OB_INTERNAL_TEXT_DOMAIN}" ob_warn "$(ob_get_msg 'unable_to_detect_package_format')" - ob_set_text_domain "${_obip_orig_text_domain}" - _ob_return 1 - return ${?} + ob_set_text_domain "${orig_text_domain}" + return 1 fi ob_use "package/${_OB_PACKAGE_FORMAT}" _OB_BINARY_PACKAGES= - _ob_return 0 - return ${?} + return 0 } ob_parse_package_metadata() { - _ob_local _obppm_opt _obppm_cache_file _obppm_pkg _obppm_pkg_clean \ - _obppm_param_name _obppm_param_value - - while getopts 'c:' _obppm_opt; do - case "${_obppm_opt}" in + local opt= + local cache_file= + local pkg= + local pkg_clean= + local param_name= + local param_value= + + while getopts 'c:' opt; do + case "${opt}" in c) - _obppm_cache_file="${OPTARG}" + cache_file="${OPTARG}" ;; ?) - _ob_return 125 - return ${?} + return 125 ;; esac done shift $(($OPTIND - 1)) if [ ${#} -gt 0 ]; then - _ob_return 125 - return ${?} + return 125 fi # Load a previously saved cache file, if any. - if [ -n "${_obppm_cache_file}" -a -r "${_obppm_cache_file}" ]; then - if [ "${_obppm_cache_file#*/}" != "${_obppm_cache_file}" ]; then - . "${_obppm_cache_file}" + if [ -n "${cache_file}" -a -r "${cache_file}" ]; then + if [ "${cache_file#*/}" != "${cache_file}" ]; then + . "${cache_file}" else - . "./${_obppm_cache_file}" + . "./${cache_file}" fi - _ob_return 0 - return ${?} + return 0 fi _ob_package_do 'parse_package_metadata' - if [ -n "${_obppm_cache_file}" ]; then - >"${_obppm_cache_file}" - for _obppm_param_name in ${_OB_SOURCE_PARAMETERS}; do - _obppm_param_value="$(ob_get_source_parameter \ - "${_obppm_param_name}" | sed "s/'/'\\\\''/g")" + if [ -n "${cache_file}" ]; then + >"${cache_file}" + for param_name in ${_OB_SOURCE_PARAMETERS}; do + param_value="$(ob_get_source_parameter \ + "${param_name}" | sed "s/'/'\\\\''/g")" printf "%s='%s'\n" \ - "_OB_SRCFIELD_${_obppm_param_name}" "${_obppm_param_value}" \ - >>"${_obppm_cache_file}" + "_OB_SRCFIELD_${param_name}" "${param_value}" \ + >>"${cache_file}" done - for _obppm_pkg in $(ob_get_binary_packages); do - _obppm_pkg_clean="$(echo "${_obppm_pkg}" | tr 'a-z' 'A-Z' | \ + for pkg in $(ob_get_binary_packages); do + pkg_clean="$(echo "${pkg}" | tr 'a-z' 'A-Z' | \ tr -dC 'A-Z0-9')" - for _obppm_param_name in ${_OB_BINARY_PARAMETERS}; do - _obppm_param_value="$(ob_get_binary_parameter "${_obppm_pkg}" \ - "${_obppm_param_name}" | sed "s/'/'\\\\''/g")" + for param_name in ${_OB_BINARY_PARAMETERS}; do + param_value="$(ob_get_binary_parameter "${pkg}" \ + "${param_name}" | sed "s/'/'\\\\''/g")" printf "%s='%s'\n" \ - "_OB_BINFIELD_${_obppm_pkg_clean}_${_obppm_param_name}" \ - "${_obppm_param_value}" \ - >>"${_obppm_cache_file}" + "_OB_BINFIELD_${pkg_clean}_${param_name}" \ + "${param_value}" \ + >>"${cache_file}" done done fi - _ob_return 0 - return ${?} + return 0 } ob_get_binary_packages() { - _ob_local _obgbpk_opt _obgbpk_host_arch _obgbpk_host_plat \ - _obgbpk_pkgs _obgbpk_pkg \ - _obgbpk_pkgs_clean _obgbpk_pkg_clean _obgbpk_orig_text_domain - - while getopts 'a:P:' _obgbpk_opt; do - case "${_obgbpk_opt}" in + local opt= + local host_arch= + local host_plat= + local pkgs= + local pkg= + local pkgs_clean= + local pkg_clean= + local orig_text_domain= + + while getopts 'a:P:' opt; do + case "${opt}" in a) - _obgbpk_host_arch="${OPTARG}" + host_arch="${OPTARG}" ;; P) - _obgbpk_host_plat="${OPTARG}" + host_plat="${OPTARG}" ;; ?) - _ob_return 125 - return ${?} + return 125 ;; esac done shift $(($OPTIND - 1)) if [ ${#} -gt 0 ]; then - _ob_return 125 - return ${?} + return 125 fi # NB: If a source package lists no binary packages, this will be true each @@ -162,293 +163,267 @@ ob_get_binary_packages() _ob_package_do 'get_binary_packages' - _obgbpk_orig_text_domain="$(ob_get_text_domain)" + orig_text_domain="$(ob_get_text_domain)" ob_set_text_domain "${_OB_INTERNAL_TEXT_DOMAIN}" - _obgbpk_pkgs_clean=' ' + pkgs_clean=' ' - for _obgbpk_pkg in ${_OB_BINARY_PACKAGES}; do + for pkg in ${_OB_BINARY_PACKAGES}; do # Validate the name. - if ! ob_validate_binary_name "${_obgbpk_pkg}"; then - ob_warn "$(ob_get_msg 'bad_binary_name')" "${_obgbpk_pkg}" + if ! ob_validate_binary_name "${pkg}"; then + ob_warn "$(ob_get_msg 'bad_binary_name')" "${pkg}" continue fi # Make sure the "clean" name is unique. - _obgbpk_pkg_clean=" $(echo "${_obgbpk_pkg}" | tr 'a-z' 'A-Z' | \ + pkg_clean=" $(echo "${pkg}" | tr 'a-z' 'A-Z' | \ tr -dC 'A-Z0-9') " - if echo "${_obgbpk_pkgs_clean}" | grep "${_obgbpk_pkg_clean}" \ + if echo "${pkgs_clean}" | grep "${pkg_clean}" \ >/dev/null 2>&1; then ob_warn "$(ob_get_msg 'duplicate_clean_binary_name')" \ - "${_obgbpk_pkg_clean}" + "${pkg_clean}" continue else - _obgbpk_pkgs_clean="${_obgbpk_pkgs_clean}${_obgbpk_pkg_clean} " + pkgs_clean="${pkgs_clean}${pkg_clean} " fi - _obgbpk_pkgs="${_obgbpk_pkgs} ${_obgbpk_pkg}" + pkgs="${pkgs} ${pkg}" done - _OB_BINARY_PACKAGES="$(IFS=' ' echo ${_obgbpk_pkgs})" + _OB_BINARY_PACKAGES="$(IFS=' ' echo ${pkgs})" - ob_set_text_domain "${_obgbpk_orig_text_domain}" + ob_set_text_domain "${orig_text_domain}" fi - _obgbpk_pkgs='' + pkgs='' - for _obgbpk_pkg in ${_OB_BINARY_PACKAGES}; do - if [ -n "${_obgbpk_host_arch}" ] && ! ob_arch_is_concerned \ - "${_obgbpk_host_arch}" "$(ob_get_binary_parameter \ - "${_obgbpk_pkg}" 'Architecture')"; then + for pkg in ${_OB_BINARY_PACKAGES}; do + if [ -n "${host_arch}" ] && ! ob_arch_is_concerned \ + "${host_arch}" "$(ob_get_binary_parameter \ + "${pkg}" 'Architecture')"; then continue fi - if [ -n "${_obgbpk_host_plat}" ] && ! ob_plat_is_concerned \ - "${_obgbpk_host_plat}" "$(ob_get_binary_parameter \ - "${_obgbpk_pkg}" 'Platform')"; then + if [ -n "${host_plat}" ] && ! ob_plat_is_concerned \ + "${host_plat}" "$(ob_get_binary_parameter \ + "${pkg}" 'Platform')"; then continue fi - _obgbpk_pkgs="${_obgbpk_pkgs} ${_obgbpk_pkg}" + pkgs="${pkgs} ${pkg}" done - IFS=' ' echo ${_obgbpk_pkgs} + IFS=' ' echo ${pkgs} - _ob_return 0 - return ${?} + return 0 } ob_get_source_parameter() { - _ob_local _obgsp_name + local name= if [ ${#} -eq 1 ]; then - _obgsp_name="${1}" + name="${1}" else - _ob_return 125 - return ${?} + return 125 fi # Convert field name to uppercase and validate. - _obgsp_name="$(echo "${_obgsp_name}" | tr 'a-z-' 'A-Z_')" - case "${_obgsp_name:- }" in + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" + case "${name:- }" in *[!A-Z0-9_]*) - _ob_return 125 - return ${?} + return 125 ;; esac - eval echo \"\$\{"_OB_SRCFIELD_${_obgsp_name}"\}\" + eval echo \"\$\{"_OB_SRCFIELD_${name}"\}\" - _ob_return 0 - return ${?} + return 0 } ob_get_binary_parameter() { - _ob_local _obgbp_package _obgbp_name + local package= + local name= if [ ${#} -eq 2 ]; then - _obgbp_package="${1}" - _obgbp_name="${2}" + package="${1}" + name="${2}" else - _ob_return 125 - return ${?} + return 125 fi - if ! ob_validate_binary_name "${_obgbp_package}"; then - _ob_return 125 - return ${?} + if ! ob_validate_binary_name "${package}"; then + return 125 fi # Convert package name to its uppercase "clean" form. - _obgbp_package="$(echo "${_obgbp_package}" | tr 'a-z' 'A-Z' | \ + package="$(echo "${package}" | tr 'a-z' 'A-Z' | \ tr -dC 'A-Z0-9')" # Convert field name to uppercase and validate. - _obgbp_name="$(echo "${_obgbp_name}" | tr 'a-z-' 'A-Z_')" - case "${_obgbp_name:- }" in + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" + case "${name:- }" in *[!A-Z0-9_]*) - _ob_return 125 - return ${?} + return 125 ;; esac - eval echo \"\$\{"_OB_BINFIELD_${_obgbp_package}_${_obgbp_name}"\}\" + eval echo \"\$\{"_OB_BINFIELD_${package}_${name}"\}\" - _ob_return 0 - return ${?} + return 0 } ob_get_doc_package() { - _ob_local - if [ ${#} -gt 0 ]; then - _ob_return 125 - return ${?} + return 125 fi _ob_package_do 'get_doc_package' - _ob_return ${?} return ${?} } ob_get_doc_files() { - _ob_local _obgdf_arch _obgdf_plat + local arch= + local plat= if [ ${#} -eq 2 ]; then - _obgdf_arch="${1}" - _obgdf_plat="${2}" + arch="${1}" + plat="${2}" else - _ob_return 125 - return ${?} + return 125 fi - _ob_package_do 'get_doc_files' "${_obgdf_arch}" "${_obgdf_plat}" + _ob_package_do 'get_doc_files' "${arch}" "${plat}" - _ob_return ${?} return ${?} } ob_summarize_package_arch() { - _ob_local - if [ ${#} -gt 0 ]; then - _ob_return 125 - return ${?} + return 125 fi # XXX: Stub. - _ob_return 0 - return ${?} + return 0 } ob_summarize_package_plat() { - _ob_local - if [ ${#} -gt 0 ]; then - _ob_return 125 - return ${?} + return 125 fi # XXX: Stub. - _ob_return 0 - return ${?} + return 0 } ob_set_package_substvars() { - _ob_local _obspsv_pkg + local pkg= if [ ${#} -eq 1 ]; then - _obspsv_pkg="${1}" + pkg="${1}" else - _ob_return 125 - return ${?} + return 125 fi - _ob_package_do 'set_package_substvars' "${_obspsv_pkg}" + _ob_package_do 'set_package_substvars' "${pkg}" - _ob_return ${?} return ${?} } _ob_package_do() { - _ob_local _obpd_func + local func= - _obpd_func="${1}" + func="${1}" shift 1 - "_ob_${_obpd_func}_${_OB_PACKAGE_FORMAT}" "${@}" + "_ob_${func}_${_OB_PACKAGE_FORMAT}" "${@}" - _ob_return ${?} return ${?} } _ob_set_binary_packages() { - _ob_local _obsbpk_packages + local packages= - _obsbpk_packages="${1}" + packages="${1}" - _OB_BINARY_PACKAGES="${_obsbpk_packages}" + _OB_BINARY_PACKAGES="${packages}" - _ob_return 0 - return ${?} + return 0 } _ob_set_source_parameter() { - _ob_local _obssp_name _obssp_value + local name= + local value= - _obssp_name="${1}" - _obssp_value="${2}" + name="${1}" + value="${2}" # Convert field name to uppercase and validate. - _obssp_name="$(echo "${_obssp_name}" | tr 'a-z-' 'A-Z_')" - case "${_obssp_name:- }" in + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" + case "${name:- }" in *[!A-Z0-9_]*) - _ob_return 125 - return ${?} + return 125 ;; esac - _OB_SOURCE_PARAMETERS="${_OB_SOURCE_PARAMETERS} ${_obssp_name}" + _OB_SOURCE_PARAMETERS="${_OB_SOURCE_PARAMETERS} ${name}" # Escape the value. - _obssp_value="$(echo "${_obssp_value}" | sed "s/'/'\\\\''/g")" + value="$(echo "${value}" | sed "s/'/'\\\\''/g")" - eval "_OB_SRCFIELD_${_obssp_name}='${_obssp_value}'" + eval "_OB_SRCFIELD_${name}='${value}'" - _ob_return 0 - return ${?} + return 0 } _ob_set_binary_parameter() { - _ob_local _obsbp_package _obsbp_name _obsbp_value + local package= + local name= + local value= - _obsbp_package="${1}" - _obsbp_name="${2}" - _obsbp_value="${3}" + package="${1}" + name="${2}" + value="${3}" - if ! ob_validate_binary_name "${_obsbp_package}"; then - _ob_return 125 - return ${?} + if ! ob_validate_binary_name "${package}"; then + return 125 fi # Convert package name to its uppercase "clean" form. - _obsbp_package="$(echo "${_obsbp_package}" | tr 'a-z' 'A-Z' | \ + package="$(echo "${package}" | tr 'a-z' 'A-Z' | \ tr -dC 'A-Z0-9')" # Convert field name to uppercase and validate. - _obsbp_name="$(echo "${_obsbp_name}" | tr 'a-z-' 'A-Z_')" - case "${_obsbp_name:- }" in + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" + case "${name:- }" in *[!A-Z0-9_]*) - _ob_return 125 - return ${?} + return 125 ;; esac - if ! echo " ${_OB_BINARY_PARAMETERS} " | grep " ${_obsbp_name} " \ + if ! echo " ${_OB_BINARY_PARAMETERS} " | grep " ${name} " \ >/dev/null 2>&1; then - _OB_BINARY_PARAMETERS="${_OB_BINARY_PARAMETERS} ${_obsbp_name}" + _OB_BINARY_PARAMETERS="${_OB_BINARY_PARAMETERS} ${name}" fi # Escape the value. - _obsbp_value="$(echo "${_obsbp_value}" | sed "s/'/'\\\\''/g")" + value="$(echo "${value}" | sed "s/'/'\\\\''/g")" - eval "_OB_BINFIELD_${_obsbp_package}_${_obsbp_name}='${_obsbp_value}'" + eval "_OB_BINFIELD_${package}_${name}='${value}'" - _ob_return 0 - return ${?} + return 0 } -- cgit v0.9.1