fsl-kernel-localversion: fix SRCREV_machine and AUTOREV use cases

Depending on how one uses the Yocto kernel classes the kernels hash
is defined in either "SRCREV_machine" or "SRCREV". If "SRCREV_machine"
is in use, "SRCREV" stays at its bitbake default "INVALID".

If the "SRCREV_machine" or "SRCREV" is set to "AUTOREV" that value is
replaced by "AUTOINC".

If using "SRCREV_machine" and/or "AUTOREV" do_kernel_localversion fails

| run.do_kernel_localversion:158 exit 128 from 'head=`git --git-dir=.../.git rev-parse --verify --short INVALID 2> /dev/null`'

Cope with both use cases.

Fixes: 41537394 ("classes: make localversion classes deterministic")
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
This commit is contained in:
Max Krummenacher 2023-12-03 12:10:39 +01:00
parent 0fc1504fb3
commit 16a356ef0d

View File

@ -25,8 +25,18 @@ do_kernel_localversion() {
if [ "${SCMVERSION}" = "y" ]; then
# Add GIT revision to the local version
head=`git --git-dir=${S}/.git rev-parse --verify --short ${SRCREV} 2> /dev/null`
patches=`git --git-dir=${S}/.git rev-list --count ${SRCREV}..HEAD 2> /dev/null`
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
sed -i -e "/CONFIG_LOCALVERSION_AUTO[ =]/d" ${B}/.config