meta-freescale/classes/fsl-kernel-localversion.bbclass
Tom Hochstein e6a138da45 fsl-kernel-localversion: Fix duplicate LOCALVERSION
The kernel version contains LOCALVERSION twice. For example, for
LOCALVERSION=nxp-next:
```
$ cat tmp/work/imx95evk-poky-linux/linux-imx/6.18.y+git/build/include/generated/utsrelease.h
#define UTS_RELEASE "6.18.0-nxp-next-nxp-next-06195-gb61baedaf5d5"
```

The problem is kernel-yocto.bbclass adds LOCALVERSION via .config if
LINUX_VERSION_EXTENSION is not empty, and the build itself adds it
because fsl-kernel-localversion.bbclass sets CONFIG_LOCALVERSION_AUTO=y
whenever SCMVERSION is enabled.

Fix by clearing LINUX_VERSION_EXTENSION if SCMVERSION is enabled.

Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
2025-12-15 12:38:03 -06:00

49 lines
1.6 KiB
Plaintext

# Freescale Kernel LOCALVERSION extension
#
# This allow to easy reuse of code between different kernel recipes
#
# The following options are supported:
#
# SCMVERSION Puts the Git hash in kernel local version
# LOCALVERSION Value used in LOCALVERSION (default to '+fslc')
#
# Copyright 2014, 2015 (C) O.S. Systems Software LTDA.
SCMVERSION ??= "y"
LOCALVERSION ??= "+fslc"
# LINUX_VERSION_EXTENSION is used as CONFIG_LOCALVERSION by kernel-yocto class
LINUX_VERSION_EXTENSION ?= \
"${@bb.utils.contains('SCMVERSION', 'y', '', '${LOCALVERSION}', d)}"
do_kernel_localversion[dirs] += "${S} ${B}"
do_kernel_localversion() {
# Fallback for recipes not able to use LINUX_VERSION_EXTENSION
if [ "${@bb.data.inherits_class('kernel-yocto', d)}" = "False" ]; then
echo 'CONFIG_LOCALVERSION="${LOCALVERSION}"' >> ${B}/.config
fi
if [ "${SCMVERSION}" = "y" ]; then
# Add GIT revision to the local version
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
echo "CONFIG_LOCALVERSION_AUTO=y" >> ${B}/.config
fi
}
addtask kernel_localversion before do_configure after do_patch do_kernel_configme