[v2,2/2] linux-custom: Add a provision to support CONFIG_LOCALVERSION_AUTO

Message ID 20241023125307.1402533-2-srinuvasan.a@siemens.com
State Superseded, archived
Headers show
Series [v2,1/2] add new machine qemuamd64-cip and corresponding mc | expand

Commit Message

srinuvasan.a Oct. 23, 2024, 12:53 p.m. UTC
From: srinuvasan <srinuvasan.a@siemens.com>

This change might be useful for downstream layers to set the CONFIG_LOCALVERSION_AUTO
in their base defconfig to append the version automatically to kernel release.

Presently ISAR doesn't have this support, hence add this provision.

Here we try to find the CONFIG_LOCALVERSION_AUTO availability and .git present during
build the kernel package, unfortunately we are not getting the .git directory in the dpkg_build stage
even if we are fetching the git repo, this is due to sbuild always uses the sources (dsc) file
to build the package, when we generate the dsc file it create the tar ball without .git, hence
during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"

To solve this issue we have base .config and .git available in the do_dpkg_source stage, here we try to find the
latest commit and write them into .scmversion file, later during the kernel build package stage
we are calling the kernelrelease target to set the localversion, this setlocalversion script
handle the availability of .scmversion file and append the string accordingly to the kernelrelease.

Added qemuamd64-cip BSP to demonstrate this feature.

Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
---
 meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
 .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
 meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

Comments

srinuvasan.a Oct. 23, 2024, 12:54 p.m. UTC | #1
Hi Jan,

         Addressed all the comment in V2.

Many thanks,
Srinu

-----Original Message-----
From: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com> 
Sent: 23 October 2024 18:23
To: isar-users@googlegroups.com
Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.hombourger@siemens.com>; Kiszka, Jan (FT RPD CED) <jan.kiszka@siemens.com>; Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com>
Subject: [PATCH v2 2/2] linux-custom: Add a provision to support CONFIG_LOCALVERSION_AUTO

From: srinuvasan <srinuvasan.a@siemens.com>

This change might be useful for downstream layers to set the CONFIG_LOCALVERSION_AUTO in their base defconfig to append the version automatically to kernel release.

Presently ISAR doesn't have this support, hence add this provision.

Here we try to find the CONFIG_LOCALVERSION_AUTO availability and .git present during build the kernel package, unfortunately we are not getting the .git directory in the dpkg_build stage even if we are fetching the git repo, this is due to sbuild always uses the sources (dsc) file to build the package, when we generate the dsc file it create the tar ball without .git, hence during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"

To solve this issue we have base .config and .git available in the do_dpkg_source stage, here we try to find the latest commit and write them into .scmversion file, later during the kernel build package stage we are calling the kernelrelease target to set the localversion, this setlocalversion script handle the availability of .scmversion file and append the string accordingly to the kernelrelease.

Added qemuamd64-cip BSP to demonstrate this feature.

Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
---
 meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
 .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
 meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
index f3bafe00..c27a5a61 100644
--- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
+++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
@@ -1,6 +1,6 @@
 # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration purposes
 
-# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
diff --git a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
index 17effe52..1ab699f5 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
@@ -1,2 +1 @@
 CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
-# CONFIG_LOCALVERSION_AUTO is not set
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 0f23d6f0..04c3fdb6 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -296,6 +296,17 @@ EOF
 	done
 }
 
+get_localversion_auto() {
+	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
+		cd ${S}
+		if (git rev-parse --git-dir >/dev/null 2>&1) &&
+		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
+			echo "-g${head}" >${S}/.scmversion
+		fi
+	fi
+}
+
 do_dpkg_source:prepend() {
 	dpkg_configure_kernel
+	get_localversion_auto
 }
--
2.39.5
Jan Kiszka Oct. 23, 2024, 4:04 p.m. UTC | #2
On 23.10.24 14:53, srinuvasan.a@siemens.com wrote:
> From: srinuvasan <srinuvasan.a@siemens.com>
> 
> This change might be useful for downstream layers to set the CONFIG_LOCALVERSION_AUTO
> in their base defconfig to append the version automatically to kernel release.
> 
> Presently ISAR doesn't have this support, hence add this provision.
> 
> Here we try to find the CONFIG_LOCALVERSION_AUTO availability and .git present during
> build the kernel package, unfortunately we are not getting the .git directory in the dpkg_build stage
> even if we are fetching the git repo, this is due to sbuild always uses the sources (dsc) file
> to build the package, when we generate the dsc file it create the tar ball without .git, hence
> during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"
> 
> To solve this issue we have base .config and .git available in the do_dpkg_source stage, here we try to find the
> latest commit and write them into .scmversion file, later during the kernel build package stage
> we are calling the kernelrelease target to set the localversion, this setlocalversion script
> handle the availability of .scmversion file and append the string accordingly to the kernelrelease.
> 
> Added qemuamd64-cip BSP to demonstrate this feature.
> 
> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
> ---
>  meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
>  .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
>  meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> index f3bafe00..c27a5a61 100644
> --- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> +++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> @@ -1,6 +1,6 @@
>  # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration purposes
>  
> -# CONFIG_LOCALVERSION_AUTO is not set
> +CONFIG_LOCALVERSION_AUTO=y
>  CONFIG_SYSVIPC=y
>  CONFIG_POSIX_MQUEUE=y
>  CONFIG_BSD_PROCESS_ACCT=y
> diff --git a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> index 17effe52..1ab699f5 100644
> --- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> @@ -1,2 +1 @@
>  CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
> -# CONFIG_LOCALVERSION_AUTO is not set
> diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
> index 0f23d6f0..04c3fdb6 100644
> --- a/meta/recipes-kernel/linux/linux-custom.inc
> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> @@ -296,6 +296,17 @@ EOF
>  	done
>  }
>  
> +get_localversion_auto() {
> +	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
> +		cd ${S}
> +		if (git rev-parse --git-dir >/dev/null 2>&1) &&

Still here - did I miss the explanation why it is needed?

> +		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
> +			echo "-g${head}" >${S}/.scmversion
> +		fi
> +	fi
> +}
> +
>  do_dpkg_source:prepend() {
>  	dpkg_configure_kernel
> +	get_localversion_auto
>  }

Jan
srinuvasan.a Oct. 23, 2024, 4:26 p.m. UTC | #3
-----Original Message-----
From: Kiszka, Jan (FT RPD CED) <jan.kiszka@siemens.com> 
Sent: 23 October 2024 21:35
To: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com>; isar-users@googlegroups.com
Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.hombourger@siemens.com>
Subject: Re: [PATCH v2 2/2] linux-custom: Add a provision to support CONFIG_LOCALVERSION_AUTO

On 23.10.24 14:53, srinuvasan.a@siemens.com wrote:
> From: srinuvasan <srinuvasan.a@siemens.com>
> 
> This change might be useful for downstream layers to set the 
> CONFIG_LOCALVERSION_AUTO in their base defconfig to append the version automatically to kernel release.
> 
> Presently ISAR doesn't have this support, hence add this provision.
> 
> Here we try to find the CONFIG_LOCALVERSION_AUTO availability and .git 
> present during build the kernel package, unfortunately we are not 
> getting the .git directory in the dpkg_build stage even if we are 
> fetching the git repo, this is due to sbuild always uses the sources 
> (dsc) file to build the package, when we generate the dsc file it create the tar ball without .git, hence during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"
> 
> To solve this issue we have base .config and .git available in the 
> do_dpkg_source stage, here we try to find the latest commit and write 
> them into .scmversion file, later during the kernel build package 
> stage we are calling the kernelrelease target to set the localversion, this setlocalversion script handle the availability of .scmversion file and append the string accordingly to the kernelrelease.
> 
> Added qemuamd64-cip BSP to demonstrate this feature.
> 
> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
> ---
>  meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
>  .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
>  meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig 
> b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> index f3bafe00..c27a5a61 100644
> --- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> +++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
> @@ -1,6 +1,6 @@
>  # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration 
> purposes
>  
> -# CONFIG_LOCALVERSION_AUTO is not set
> +CONFIG_LOCALVERSION_AUTO=y
>  CONFIG_SYSVIPC=y
>  CONFIG_POSIX_MQUEUE=y
>  CONFIG_BSD_PROCESS_ACCT=y
> diff --git 
> a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl 
> b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> index 17effe52..1ab699f5 100644
> --- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
> @@ -1,2 +1 @@
>  CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
> -# CONFIG_LOCALVERSION_AUTO is not set diff --git 
> a/meta/recipes-kernel/linux/linux-custom.inc 
> b/meta/recipes-kernel/linux/linux-custom.inc
> index 0f23d6f0..04c3fdb6 100644
> --- a/meta/recipes-kernel/linux/linux-custom.inc
> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> @@ -296,6 +296,17 @@ EOF
>  	done
>  }
>  
> +get_localversion_auto() {
> +	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
> +		cd ${S}
> +		if (git rev-parse --git-dir >/dev/null 2>&1) &&

Still here - did I miss the explanation why it is needed?

Here we are checking the repo is git or not, because mainline and cip kernel uses the same defconfig (x86_64_defconfig enabled with CONFIG_LOCALVERSION_AUTO) for few machines,  Just we are skipping the finding HEAD revision if kernel builds via tarball.

Thanks,
Srinu

> +		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
> +			echo "-g${head}" >${S}/.scmversion
> +		fi
> +	fi
> +}
> +
>  do_dpkg_source:prepend() {
>  	dpkg_configure_kernel
> +	get_localversion_auto
>  }

Jan

--
Siemens AG, Technology
Linux Expert Center
Jan Kiszka Oct. 23, 2024, 4:31 p.m. UTC | #4
On 23.10.24 18:26, Arjunan, Srinu (FT FDS CES LX PBU 2) wrote:
> 
> 
> -----Original Message-----
> From: Kiszka, Jan (FT RPD CED) <jan.kiszka@siemens.com> 
> Sent: 23 October 2024 21:35
> To: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com>; isar-users@googlegroups.com
> Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.hombourger@siemens.com>
> Subject: Re: [PATCH v2 2/2] linux-custom: Add a provision to support CONFIG_LOCALVERSION_AUTO
> 
> On 23.10.24 14:53, srinuvasan.a@siemens.com wrote:
>> From: srinuvasan <srinuvasan.a@siemens.com>
>>
>> This change might be useful for downstream layers to set the 
>> CONFIG_LOCALVERSION_AUTO in their base defconfig to append the version automatically to kernel release.
>>
>> Presently ISAR doesn't have this support, hence add this provision.
>>
>> Here we try to find the CONFIG_LOCALVERSION_AUTO availability and .git 
>> present during build the kernel package, unfortunately we are not 
>> getting the .git directory in the dpkg_build stage even if we are 
>> fetching the git repo, this is due to sbuild always uses the sources 
>> (dsc) file to build the package, when we generate the dsc file it create the tar ball without .git, hence during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"
>>
>> To solve this issue we have base .config and .git available in the 
>> do_dpkg_source stage, here we try to find the latest commit and write 
>> them into .scmversion file, later during the kernel build package 
>> stage we are calling the kernelrelease target to set the localversion, this setlocalversion script handle the availability of .scmversion file and append the string accordingly to the kernelrelease.
>>
>> Added qemuamd64-cip BSP to demonstrate this feature.
>>
>> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
>> ---
>>  meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
>>  .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
>>  meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
>>  3 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig 
>> b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> index f3bafe00..c27a5a61 100644
>> --- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> +++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> @@ -1,6 +1,6 @@
>>  # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration 
>> purposes
>>  
>> -# CONFIG_LOCALVERSION_AUTO is not set
>> +CONFIG_LOCALVERSION_AUTO=y
>>  CONFIG_SYSVIPC=y
>>  CONFIG_POSIX_MQUEUE=y
>>  CONFIG_BSD_PROCESS_ACCT=y
>> diff --git 
>> a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl 
>> b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> index 17effe52..1ab699f5 100644
>> --- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> @@ -1,2 +1 @@
>>  CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
>> -# CONFIG_LOCALVERSION_AUTO is not set diff --git 
>> a/meta/recipes-kernel/linux/linux-custom.inc 
>> b/meta/recipes-kernel/linux/linux-custom.inc
>> index 0f23d6f0..04c3fdb6 100644
>> --- a/meta/recipes-kernel/linux/linux-custom.inc
>> +++ b/meta/recipes-kernel/linux/linux-custom.inc
>> @@ -296,6 +296,17 @@ EOF
>>  	done
>>  }
>>  
>> +get_localversion_auto() {
>> +	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
>> +		cd ${S}
>> +		if (git rev-parse --git-dir >/dev/null 2>&1) &&
> 
> Still here - did I miss the explanation why it is needed?
> 
> Here we are checking the repo is git or not, because mainline and cip kernel uses the same defconfig (x86_64_defconfig enabled with CONFIG_LOCALVERSION_AUTO) for few machines,  Just we are skipping the finding HEAD revision if kernel builds via tarball.
> 

Why is

if head=$(git rev-parse --verify --short HEAD 2>/dev/null); then

not enough for this check?

Jan

> Thanks,
> Srinu
> 
>> +		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
>> +			echo "-g${head}" >${S}/.scmversion
>> +		fi
>> +	fi
>> +}
>> +
>>  do_dpkg_source:prepend() {
>>  	dpkg_configure_kernel
>> +	get_localversion_auto
>>  }
> 
> Jan
> 
> --
> Siemens AG, Technology
> Linux Expert Center
srinuvasan.a Oct. 23, 2024, 4:43 p.m. UTC | #5
-----Original Message-----
From: Kiszka, Jan (FT RPD CED) <jan.kiszka@siemens.com> 
Sent: 23 October 2024 22:01
To: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com>; isar-users@googlegroups.com
Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.hombourger@siemens.com>
Subject: Re: [PATCH v2 2/2] linux-custom: Add a provision to support CONFIG_LOCALVERSION_AUTO

On 23.10.24 18:26, Arjunan, Srinu (FT FDS CES LX PBU 2) wrote:
> 
> 
> -----Original Message-----
> From: Kiszka, Jan (FT RPD CED) <jan.kiszka@siemens.com>
> Sent: 23 October 2024 21:35
> To: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuvasan.a@siemens.com>; 
> isar-users@googlegroups.com
> Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.hombourger@siemens.com>
> Subject: Re: [PATCH v2 2/2] linux-custom: Add a provision to support 
> CONFIG_LOCALVERSION_AUTO
> 
> On 23.10.24 14:53, srinuvasan.a@siemens.com wrote:
>> From: srinuvasan <srinuvasan.a@siemens.com>
>>
>> This change might be useful for downstream layers to set the 
>> CONFIG_LOCALVERSION_AUTO in their base defconfig to append the version automatically to kernel release.
>>
>> Presently ISAR doesn't have this support, hence add this provision.
>>
>> Here we try to find the CONFIG_LOCALVERSION_AUTO availability and 
>> .git present during build the kernel package, unfortunately we are 
>> not getting the .git directory in the dpkg_build stage even if we are 
>> fetching the git repo, this is due to sbuild always uses the sources
>> (dsc) file to build the package, when we generate the dsc file it create the tar ball without .git, hence during dpkg_build stage it is not possible to get the latest commit HEAD value using "git rev-parse --verify HEAD"
>>
>> To solve this issue we have base .config and .git available in the 
>> do_dpkg_source stage, here we try to find the latest commit and write 
>> them into .scmversion file, later during the kernel build package 
>> stage we are calling the kernelrelease target to set the localversion, this setlocalversion script handle the availability of .scmversion file and append the string accordingly to the kernelrelease.
>>
>> Added qemuamd64-cip BSP to demonstrate this feature.
>>
>> Signed-off-by: srinuvasan <srinuvasan.a@siemens.com>
>> ---
>>  meta-isar/recipes-kernel/linux/files/x86_64_defconfig |  2 +-
>>  .../linux/files/debian/isar/version.cfg.tmpl          |  1 -
>>  meta/recipes-kernel/linux/linux-custom.inc            | 11 +++++++++++
>>  3 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> index f3bafe00..c27a5a61 100644
>> --- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> +++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
>> @@ -1,6 +1,6 @@
>>  # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration 
>> purposes
>>  
>> -# CONFIG_LOCALVERSION_AUTO is not set
>> +CONFIG_LOCALVERSION_AUTO=y
>>  CONFIG_SYSVIPC=y
>>  CONFIG_POSIX_MQUEUE=y
>>  CONFIG_BSD_PROCESS_ACCT=y
>> diff --git
>> a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> index 17effe52..1ab699f5 100644
>> --- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
>> @@ -1,2 +1 @@
>>  CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
>> -# CONFIG_LOCALVERSION_AUTO is not set diff --git 
>> a/meta/recipes-kernel/linux/linux-custom.inc
>> b/meta/recipes-kernel/linux/linux-custom.inc
>> index 0f23d6f0..04c3fdb6 100644
>> --- a/meta/recipes-kernel/linux/linux-custom.inc
>> +++ b/meta/recipes-kernel/linux/linux-custom.inc
>> @@ -296,6 +296,17 @@ EOF
>>  	done
>>  }
>>  
>> +get_localversion_auto() {
>> +	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
>> +		cd ${S}
>> +		if (git rev-parse --git-dir >/dev/null 2>&1) &&
> 
> Still here - did I miss the explanation why it is needed?
> 
> Here we are checking the repo is git or not, because mainline and cip kernel uses the same defconfig (x86_64_defconfig enabled with CONFIG_LOCALVERSION_AUTO) for few machines,  Just we are skipping the finding HEAD revision if kernel builds via tarball.
> 

Why is

if head=$(git rev-parse --verify --short HEAD 2>/dev/null); then

not enough for this check?

Jan

Yes this is enough to work, Just I added that option --git-dir to return
The status of .git availability for more readable code rather than checking 
With latest git commit.

Will address this one in next version patch.

Thanks,
Srinu

 

> Thanks,
> Srinu
> 
>> +		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
>> +			echo "-g${head}" >${S}/.scmversion
>> +		fi
>> +	fi
>> +}
>> +
>>  do_dpkg_source:prepend() {
>>  	dpkg_configure_kernel
>> +	get_localversion_auto
>>  }
> 
> Jan
> 
> --
> Siemens AG, Technology
> Linux Expert Center


--
Siemens AG, Technology
Linux Expert Center

Patch

diff --git a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
index f3bafe00..c27a5a61 100644
--- a/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
+++ b/meta-isar/recipes-kernel/linux/files/x86_64_defconfig
@@ -1,6 +1,6 @@ 
 # Copy of linux/arch/x86/configs/x86_64_defconfig for demonstration purposes
 
-# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
diff --git a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
index 17effe52..1ab699f5 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl
@@ -1,2 +1 @@ 
 CONFIG_LOCALVERSION="${LINUX_VERSION_EXTENSION}"
-# CONFIG_LOCALVERSION_AUTO is not set
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 0f23d6f0..04c3fdb6 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -296,6 +296,17 @@  EOF
 	done
 }
 
+get_localversion_auto() {
+	if grep -q "^CONFIG_LOCALVERSION_AUTO=y" ${S}/${KERNEL_BUILD_DIR}/.config; then
+		cd ${S}
+		if (git rev-parse --git-dir >/dev/null 2>&1) &&
+		   head=$(git rev-parse --verify --short HEAD 2>/dev/null); then
+			echo "-g${head}" >${S}/.scmversion
+		fi
+	fi
+}
+
 do_dpkg_source:prepend() {
 	dpkg_configure_kernel
+	get_localversion_auto
 }