Re: [PATCH kernel] kbuild: get rid of unwanted "+" when CONFIG_LOCALVERSION is set

From: Masahiro Yamada
Date: Wed Sep 20 2023 - 08:00:35 EST


On Wed, Sep 20, 2023 at 10:56 AM Alexey Kardashevskiy <aik@xxxxxxx> wrote:
>
> The scripts/setlocalversion script correctly tries not adding "+" when
> CONFIG_LOCALVERSION is defined.

I am afraid you are misunderstanding the script.

CONFIG_LOCALVERSION and the "+" sign is unrelated.


> However, instead of grepping for it
> (as it is done for CONFIG_LOCALVERSION_AUTO=y), it relies on LOCALVERSION
> set in the shell which is not.
>
> Export LOCALVERSION so scripts/setlocalversion could see it and not add
> unwanted "+" at the end of the kernelrelease.
>
> Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxx>


So, scripts/setlocalversion will always see
defined LOCALVERSION.

With your patch, LOCALVERSION would be set to an empty value,
which would make the following condition always false.

elif [ "${LOCALVERSION+set}" != "set" ]; then


Your patch is equivalent to deleting
line 175-183 of scripts/setlocalversion.

Of course, that is wrong and unacceptable.







> ---
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 57698d048e2c..fc45bed69790 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -368,7 +368,7 @@ include $(srctree)/scripts/Kbuild.include
> # Read KERNELRELEASE from include/config/kernel.release (if it exists)
> KERNELRELEASE = $(call read-file, include/config/kernel.release)
> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
> -export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
> +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION LOCALVERSION
>
> include $(srctree)/scripts/subarch.include
>
> --
> 2.41.0
>


--
Best Regards
Masahiro Yamada