From 857be2dd719fe037eabbe3e68647fca430213fd3 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 25 Mar 2026 09:12:03 -0400 Subject: [PATCH] MT#55283 improve version handling Change-Id: I8ff496f8460c5c5e0bee6b6bb6f3d2245291c597 (cherry picked from commit 7e6c2c30a43ddd5ca51125022e289c4154027bee) --- kernel-module/gen-rtpengine-kmod-flags | 27 +++++++++++++------- utils/gen-common-flags | 34 ++++++++++++++------------ 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/kernel-module/gen-rtpengine-kmod-flags b/kernel-module/gen-rtpengine-kmod-flags index e7e903f57..dc4c1653f 100755 --- a/kernel-module/gen-rtpengine-kmod-flags +++ b/kernel-module/gen-rtpengine-kmod-flags @@ -4,8 +4,12 @@ if [ -z "${M}" ]; then M=$(pwd) fi -if [ -z "${RTPENGINE_VERSION}" ] && [ -f .release-version ]; then - RTPENGINE_VERSION=$(<.release-version) +if [ -z "${RTPENGINE_VERSION}" ]; then + if [ -f .release-version ]; then + RTPENGINE_VERSION=$(<.release-version) + elif [ -f ../.release-version ]; then + RTPENGINE_VERSION=$(<../.release-version) + fi fi if [ -z "${RTPENGINE_VERSION}" ]; then @@ -20,18 +24,23 @@ if [ -z "${RTPENGINE_VERSION}" ]; then fi if [ "${have_dpkg_parsechangelog}" = yes ]; then deb_version="$(dpkg-parsechangelog -l"${deb_changelog}" | awk '/^Version: / {print $2}')" + RTPENGINE_VERSION="${deb_version}" fi + git_br_commit="git-$(cd "${M}" && git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(cd "${M}" && git rev-parse --short HEAD 2> /dev/null)" - if [ "${have_dpkg_parsechangelog}" = yes ]; then - RTPENGINE_VERSION+=" ${deb_version}" - fi if [ "${git_br_commit}" != "git--" ]; then - RTPENGINE_VERSION+=" ${git_br_commit}" + if [ -n "${RTPENGINE_VERSION}" ]; then + RTPENGINE_VERSION+=" " + fi + RTPENGINE_VERSION+="${git_br_commit}" fi +fi - if [ -z "${RTPENGINE_VERSION}" ]; then - RTPENGINE_VERSION="undefined" - fi +if [ -z "${RTPENGINE_VERSION}" ]; then + RTPENGINE_VERSION="undefined" +fi + +if [ -n "${RTPENGINE_VERSION}" ]; then echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}" fi diff --git a/utils/gen-common-flags b/utils/gen-common-flags index 2593031f9..f9ac26172 100755 --- a/utils/gen-common-flags +++ b/utils/gen-common-flags @@ -19,33 +19,37 @@ if [ -z "${top_srcdir}" ]; then top_srcdir=. fi -have_dpkg_parsechangelog=no -if command -v dpkg-parsechangelog >/dev/null; then - have_dpkg_parsechangelog=yes -fi - -if [ -z "${RTPENGINE_VERSION}" ] && [ -f .release-version ]; then - RTPENGINE_VERSION=$(<.release-version) +if [ -z "${RTPENGINE_VERSION}" ] && [ -f "${top_srcdir}"/.release-version ]; then + RTPENGINE_VERSION=$(<"${top_srcdir}"/.release-version) fi if [ -z "${RTPENGINE_VERSION}" ]; then + have_dpkg_parsechangelog=no + if command -v dpkg-parsechangelog >/dev/null; then + have_dpkg_parsechangelog=yes + fi if [ "${have_dpkg_parsechangelog}" = yes ]; then deb_version="$(dpkg-parsechangelog -l"${top_srcdir}"/debian/changelog | awk '/^Version: / { print $2 }')" + RTPENGINE_VERSION="${deb_version}" fi + git_br_commit="git-$(git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(git rev-parse --short HEAD 2> /dev/null)" - if [ "${have_dpkg_parsechangelog}" = yes ]; then - RTPENGINE_VERSION+=" ${deb_version}" - fi if [ "${git_br_commit}" != "git--" ]; then - RTPENGINE_VERSION+=" ${git_br_commit}" + if [ -n "${RTPENGINE_VERSION}" ]; then + RTPENGINE_VERSION+=" " + fi + RTPENGINE_VERSION+="${git_br_commit}" fi +fi - if [ -z "${RTPENGINE_VERSION}" ]; then - RTPENGINE_VERSION=" undefined" - fi +if [ -z "${RTPENGINE_VERSION}" ]; then + RTPENGINE_VERSION=" undefined" +fi + +if [ -n "${RTPENGINE_VERSION}" ]; then + echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}" fi -echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}" CFLAGS_DEFAULT= CPPFLAGS_DEFAULT=