From acbff35a80d06c20286efa586fbc8b674c6b5b4d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 03 Apr 2019 17:53:17 -0400 Subject: ob-checkbuilddeps: Support compare-versions change in opkg-lede --- diff --git a/NEWS b/NEWS index 9f6f533..007648c 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,15 @@ opkbuild version 4.0.1+dev Released: ????-??-?? +The "bug fixes break my workflow" release. + +Bug fixes and minor changes: + + * opkg-lede commit 93de62b reversed the exit status of the + check-versions subcommand. ob-checkbuilddeps now detects whether + the exit status is reversed, to support build dependency version + comparisons with either "classic" (now Yocto) opkg or opkg-lede. + opkbuild version 4.0.1 ---------------------- diff --git a/src/ob-checkbuilddeps.sh b/src/ob-checkbuilddeps.sh index 39d7e60..1bfbe7f 100644 --- a/src/ob-checkbuilddeps.sh +++ b/src/ob-checkbuilddeps.sh @@ -19,6 +19,26 @@ set -eu +opkg_compare_versions_reference_status= + +compare_versions() +{ + local pkg_ver="${1}" + local dep_rel="${2}" + local dep_ver="${3}" + shift 3 + + # "Classic" (now Yocto) opkg returns 1 on a true comparison and 0 on a + # false comparison. opkg-lede reversed this in commit 93de62b. Compare + # the compare-versions exit status with a reference exit status from a + # true statement (1 << 2). + ! "${OPKG}" compare-versions "${pkg_ver}" "${dep_rel}" "${dep_ver}" + # The "-e" setting is ignored while executing anything, including + # commands in a function, within the context of the condition of an "if" + # statement. + [ ${?} -eq ${opkg_compare_versions_reference_status} ] +} + check_dep() { local dep="${1}" @@ -39,9 +59,8 @@ check_dep() if [ "x${dep_rel}" != 'x' ]; then pkg_ver="$(printf '%s\n' "${status}" | \ sed -n 's/^Version: //p')" - # opkg returns 1 on a true comparison, 0 on a false comparison. - if "${OPKG}" compare-versions \ - "${pkg_ver}" "${dep_rel}" "${dep_ver}"; then + if ! compare_versions "${pkg_ver}" "${dep_rel}" "${dep_ver}" + then return 1 fi fi @@ -92,6 +111,11 @@ main() ob_init_package '..' || return 1 ob_set_package_substvars '' + # See compare_versions() above. + # The "-e" setting is ignored for pipelines beginning with "!". + ! "${OPKG}" compare-versions 1 '>>' 2 + opkg_compare_versions_reference_status=${?} + check_build_deps || return ${?} return 0 -- cgit v0.9.1