From 888b97fbda8aa867816770fb495dad105411a3eb Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 25 Dec 2018 16:11:38 -0500 Subject: ob-*: Move function definitions before points of use --- (limited to 'src/ob-checkbuilddeps.sh') diff --git a/src/ob-checkbuilddeps.sh b/src/ob-checkbuilddeps.sh index 51264fe..fd1f10b 100644 --- a/src/ob-checkbuilddeps.sh +++ b/src/ob-checkbuilddeps.sh @@ -19,16 +19,32 @@ . "${LIBDATADIR}/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" -main() +check_dep() { - ob_set_text_domain 'opkbuild' + local dep="${1}" + local dep_pkg= + local dep_rel= + local dep_ver= + local status= + local pkg_ver= - ob_init_package '..' || exit 1 - ob_parse_package_metadata -c '.opkbuild.cache' || exit 1 - ob_set_package_substvars '' + ob_parse_dep -p dep_pkg -r dep_rel -v dep_ver "${dep}" + status="$("${OPKG}" status "${dep_pkg}")" - check_build_deps - return ${?} + if ! printf '%s\n' "${status}" | grep '^Status: .* .* installed$' \ + >/dev/null 2>&1; then + return 1 + fi + if [ "x${dep_rel}" != 'x' ]; then + pkg_ver="$(printf '%s\n' "${status}" | \ + sed -n 's/^Version: //p')" + if "${OPKG}" compare-versions \ + "${pkg_ver}" "${dep_rel}" "${dep_ver}"; then + return 1 + fi + fi + + return 0 } check_build_deps() @@ -62,32 +78,16 @@ check_build_deps() return 0 } -check_dep() +main() { - local dep="${1}" - local dep_pkg= - local dep_rel= - local dep_ver= - local status= - local pkg_ver= - - ob_parse_dep -p dep_pkg -r dep_rel -v dep_ver "${dep}" - status="$("${OPKG}" status "${dep_pkg}")" + ob_set_text_domain 'opkbuild' - if ! printf '%s\n' "${status}" | grep '^Status: .* .* installed$' \ - >/dev/null 2>&1; then - return 1 - fi - if [ "x${dep_rel}" != 'x' ]; then - pkg_ver="$(printf '%s\n' "${status}" | \ - sed -n 's/^Version: //p')" - if "${OPKG}" compare-versions \ - "${pkg_ver}" "${dep_rel}" "${dep_ver}"; then - return 1 - fi - fi + ob_init_package '..' || exit 1 + ob_parse_package_metadata -c '.opkbuild.cache' || exit 1 + ob_set_package_substvars '' - return 0 + check_build_deps + return ${?} } main "${@}" -- cgit v0.9.1