From 2701571da61ab0ee690b6e17e26bbc99f271b3b9 Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Tue, 5 Dec 2023 18:36:12 +0800 Subject: fsl-u-boot-localversion.bbclass: fix SRCREV_machine and AUTOREV use cases Use the same logic as fsl-kernel-localversion.bbclass: commit 16a356ef0d5d62090e84530e125ea6952994aaeb Signed-off-by: Jun Zhu (cherry picked from commit d7e13f19fbf93cb0bd87c29b44c5012e2e0e4393) --- classes/fsl-u-boot-localversion.bbclass | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/classes/fsl-u-boot-localversion.bbclass b/classes/fsl-u-boot-localversion.bbclass index d160ca98..94b30c04 100644 --- a/classes/fsl-u-boot-localversion.bbclass +++ b/classes/fsl-u-boot-localversion.bbclass @@ -17,11 +17,21 @@ UBOOT_LOCALVERSION = "${LOCALVERSION}" do_compile:prepend() { if [ "${SCMVERSION}" = "y" ]; then # Add GIT revision to the local version - head=`cd ${S} ; git rev-parse --verify --short ${SRCREV} 2> /dev/null` - patches=`cd ${S} ; git rev-list --count ${SRCREV}..HEAD 2> /dev/null` - printf "%s%s%s%s%s" "${UBOOT_LOCALVERSION}" +g $head +p $patches > ${S}/.scmversion - printf "%s%s%s%s%s" "${UBOOT_LOCALVERSION}" +g $head +p $patches > ${B}/.scmversion - else + if [ "${SRCREV}" = "INVALID" ]; then + hash=${SRCREV_machine} + else + hash=${SRCREV} + fi + if [ "$hash" = "AUTOINC" ]; then + branch=`git --git-dir=${S}/.git symbolic-ref --short -q HEAD` + head=`git --git-dir=${S}/.git rev-parse --verify --short origin/${branch} 2> /dev/null` + else + head=`git --git-dir=${S}/.git rev-parse --verify --short $hash 2> /dev/null` + fi + patches=`git --git-dir=${S}/.git rev-list --count $head..HEAD 2> /dev/null` + printf "%s%s%s%s" +g $head +p $patches > ${S}/.scmversion + printf "%s%s%s%s" +g $head +p $patches > ${B}/.scmversion + else printf "%s" "${UBOOT_LOCALVERSION}" > ${S}/.scmversion printf "%s" "${UBOOT_LOCALVERSION}" > ${B}/.scmversion fi -- cgit v1.2.3-54-g00ecf