Skip to contentSkip to conversation

kbuild: get rid of unwanted "+" when CONFIG_LOCALVERSION is set

PATCH In review Alexey Kardashevskiy 2 participants 6 messages Sep 20, 2023 – Sep 22, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: get rid of unwanted "+" when CONFIG_LOCALVERSION is set

The scripts/setlocalversion script correctly tries not adding "+" when CONFIG_LOCALVERSION is defined. 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.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 57698d048e2c..fc45bed69790 100644
@@ -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
 
Signature · 1 line
2.41.0
#1 lore raw
Quoted 3 lines · Alexey Kardashevskiy

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.

Quoted 8 lines

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.

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.

Quoted 20 lines
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -2
index 57698d048e2c..fc45bed69790 100644
@@ -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

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 6 lines · Masahiro Yamada
Quoted 3 lines · Alexey Kardashevskiy

The scripts/setlocalversion script correctly tries not adding "+" when CONFIG_LOCALVERSION is defined.

I am afraid you are misunderstanding the script.

Possibly :) I should have read of "+set"... sorry :-/ Thanks for spending time looking at this.

Quoted 1 line

CONFIG_LOCALVERSION and the "+" sign is unrelated.

How come?

scripts/setlocalversion -> if [ "${LOCALVERSION+set}" != "set" ] -> scm_version --short -> echo "+".

Where is that LOCALVERSION supposed to come from, and when? Is not LOCALVERSION related to CONFIG_LOCALVERSION?

Quoted 16 lines
Quoted 8 lines

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.

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.

Quoted 7 lines

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

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

Of course, that is wrong and unacceptable.

Ok. What is the right way of getting rid of the "+"? Thanks,

Quoted 29 lines
Quoted 27 lines






---
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -2
index 57698d048e2c..fc45bed69790 100644
@@ -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

#3 lore raw
Quoted 38 lines · Alexey Kardashevskiy
Quoted 6 lines · Masahiro Yamada
Quoted 3 lines · Alexey Kardashevskiy

The scripts/setlocalversion script correctly tries not adding "+" when CONFIG_LOCALVERSION is defined.

I am afraid you are misunderstanding the script.

Possibly :) I should have read of "+set"... sorry :-/ Thanks for spending time looking at this.

Quoted 1 line

CONFIG_LOCALVERSION and the "+" sign is unrelated.

How come?

scripts/setlocalversion -> if [ "${LOCALVERSION+set}" != "set" ] -> scm_version --short -> echo "+".

Where is that LOCALVERSION supposed to come from, and when? Is not LOCALVERSION related to CONFIG_LOCALVERSION?

Quoted 19 lines
Quoted 8 lines

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.

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

Quoted 6 lines
Quoted 4 lines

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

Of course, that is wrong and unacceptable.

Ok. What is the right way of getting rid of the "+"? Thanks,

make LOCALVERSION="" ...
seems to be the only way, is that right? I thought CONFIG_LOCALVERSION is good enough for not having "+", hmm.

Signature · 1 line
Alexey
#5 lore raw
In reply to Alexey Kardashevskiy
Quoted 15 lines · Alexey Kardashevskiy
Quoted 6 lines · Masahiro Yamada
Quoted 3 lines · Alexey Kardashevskiy

The scripts/setlocalversion script correctly tries not adding "+" when CONFIG_LOCALVERSION is defined.

I am afraid you are misunderstanding the script.

Possibly :) I should have read of "+set"... sorry :-/ Thanks for spending time looking at this.

Quoted 1 line

CONFIG_LOCALVERSION and the "+" sign is unrelated.

Quoted 7 lines

How come?

scripts/setlocalversion -> if [ "${LOCALVERSION+set}" != "set" ] -> scm_version --short -> echo "+".

Where is that LOCALVERSION supposed to come from, and when? Is not LOCALVERSION related to CONFIG_LOCALVERSION?

1) LOCALVERSION is an environment variable.

  $ LOCALVERSION=-foo make
           or
  $ make LOCALVERSION=-foo

2) CONFIG_LOCALVERSION is a CONFIG option

  $ make menuconfig

and set the value.

1) and 2) are orthogonal.
If you set both, you can get both of them.

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

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.

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

Quoted 6 lines
Quoted 4 lines

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

Of course, that is wrong and unacceptable.

Ok. What is the right way of getting rid of the "+"? Thanks,

--
Best Regards
Masahiro Yamada

#4 lore raw
In reply to Alexey Kardashevskiy
Quoted 49 lines · Alexey Kardashevskiy
Quoted 46 lines · Alexey Kardashevskiy
Quoted 7 lines · Masahiro Yamada
Quoted 3 lines · Alexey Kardashevskiy

The scripts/setlocalversion script correctly tries not adding "+" when CONFIG_LOCALVERSION is defined.

I am afraid you are misunderstanding the script.

Possibly :) I should have read of "+set"... sorry :-/ Thanks for spending time looking at this.

Quoted 1 line

CONFIG_LOCALVERSION and the "+" sign is unrelated.

How come?

scripts/setlocalversion -> if [ "${LOCALVERSION+set}" != "set" ] -> scm_version --short -> echo "+".

Where is that LOCALVERSION supposed to come from, and when? Is not LOCALVERSION related to CONFIG_LOCALVERSION?

Quoted 23 lines
Quoted 9 lines

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.

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.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Of course, that is wrong and unacceptable.

Ok. What is the right way of getting rid of the "+"? Thanks,

make LOCALVERSION="" ...
seems to be the only way, is that right? I thought CONFIG_LOCALVERSION is good enough for not having "+", hmm.

Correct.

Reading the commit description of
5df99bec210a2cf89dd91e52f0d0a714bf4cd96a
makes it clearer.

Best Regards
Masahiro Yamada