summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-03 17:53:17 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-03 17:53:17 (EDT)
commitacbff35a80d06c20286efa586fbc8b674c6b5b4d (patch)
tree21b61df3aceb120e9c82d936ef61da8902bb4dc7
parentdd4179fa34847edea7b3b8e527ae9a6dbfee64d6 (diff)
ob-checkbuilddeps: Support compare-versions change in opkg-lede
-rw-r--r--NEWS9
-rw-r--r--src/ob-checkbuilddeps.sh30
2 files changed, 36 insertions, 3 deletions
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