Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR
@ 2022-07-06 21:06 Florian Fainelli
  2022-07-18 13:01 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2022-07-06 21:06 UTC (permalink / raw)
  To: buildroot; +Cc: Florian Fainelli, Thomas Petazzoni, mmayer, yann.morin.1998

Linux is able to generate an automic version based upon the git tree
that is being used which is very useful for making sure that the kernel
being used is truly the one that we intend to be using.

When using LINUX_OVERRIDE_SRCDIR however, since we do not rsync the .git
folder, all of the necessary information for scripts/setlocalversion to
compute the exact version and git commit id is lost.

Add a post rsync hook that copies it over in order to allow 'git
rev-parse' to work and produce an usable version.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 linux/linux.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/linux/linux.mk b/linux/linux.mk
index 322ccabbd9f7..a19a215187fd 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -131,6 +131,14 @@ define LINUX_FIXUP_CONFIG_PAHOLE_CHECK
 endef
 endif
 
+ifneq ($(LINUX_OVERRIDE_SRCDIR),)
+define LINUX_LOCALVERSION_AUTO_FIXUP
+	if [ -d $(SRCDIR)/.git ]; then \
+		rsync -au --chmod=u=rwX,go=rX $(call qstrip,$(SRCDIR)/.git)/ $(@D); \
+	fi;
+endef
+endif
+
 # If host-uboot-tools is selected by the user, assume it is needed to
 # create a custom image
 ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y)
@@ -145,6 +153,8 @@ LINUX_POST_EXTRACT_HOOKS += LINUX_XTENSA_OVERLAY_EXTRACT
 LINUX_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
 endif
 
+LINUX_POST_RSYNC_HOOKS += LINUX_LOCALVERSION_AUTO_FIXUP
+
 # We don't want to run depmod after installing the kernel. It's done in a
 # target-finalize hook, to encompass modules installed by packages.
 # Disable building host tools with -Werror: newer gcc versions can be
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR
  2022-07-06 21:06 [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR Florian Fainelli
@ 2022-07-18 13:01 ` Thomas Petazzoni via buildroot
  2022-07-18 20:21   ` Yann E. MORIN
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-07-18 13:01 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: yann.morin.1998, mmayer, buildroot

Hello Florian,

On Wed,  6 Jul 2022 14:06:21 -0700
Florian Fainelli <f.fainelli@gmail.com> wrote:

> Linux is able to generate an automic version based upon the git tree
> that is being used which is very useful for making sure that the kernel
> being used is truly the one that we intend to be using.
> 
> When using LINUX_OVERRIDE_SRCDIR however, since we do not rsync the .git
> folder, all of the necessary information for scripts/setlocalversion to
> compute the exact version and git commit id is lost.
> 
> Add a post rsync hook that copies it over in order to allow 'git
> rev-parse' to work and produce an usable version.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Thanks for your patch. What bothers me is that it is a Linux-specific
solution for a problem that isn't Linux-specific. Many other packages
also use Git commands to generate a version string that they embed in
their binaries. So this problem really is global and I'm not sure we
want a Linux-specific fixup for it.

To me the long term solution is to enable out of tree build of
packages. This way, instead of rsync'ing the code, we would directly
build it from its original location. Some initial work was done in this
area, but it's obviously a much larger endeavor than the fixup you are
proposing. A more immediate alternative would be to also rsync the .git
folder instead of excluding it, but do that globally for all packages
that use override-srcdir. The .git directory was explicitly excluded to
reduce the amount of data to rsync.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR
  2022-07-18 13:01 ` Thomas Petazzoni via buildroot
@ 2022-07-18 20:21   ` Yann E. MORIN
  2022-07-18 23:05     ` Florian Fainelli
  0 siblings, 1 reply; 4+ messages in thread
From: Yann E. MORIN @ 2022-07-18 20:21 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Florian Fainelli, mmayer, buildroot

Florian, Thomas, All,

On 2022-07-18 15:01 +0200, Thomas Petazzoni via buildroot spake thusly:
> On Wed,  6 Jul 2022 14:06:21 -0700
> Florian Fainelli <f.fainelli@gmail.com> wrote:
> > Linux is able to generate an automic version based upon the git tree
> > that is being used which is very useful for making sure that the kernel
> > being used is truly the one that we intend to be using.
> > 
> > When using LINUX_OVERRIDE_SRCDIR however, since we do not rsync the .git
> > folder, all of the necessary information for scripts/setlocalversion to
> > compute the exact version and git commit id is lost.
> > 
> > Add a post rsync hook that copies it over in order to allow 'git
> > rev-parse' to work and produce an usable version.
> > 
> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> 
> Thanks for your patch. What bothers me is that it is a Linux-specific
> solution for a problem that isn't Linux-specific. Many other packages
> also use Git commands to generate a version string that they embed in
> their binaries. So this problem really is global and I'm not sure we
> want a Linux-specific fixup for it.

Indeed.

> To me the long term solution is to enable out of tree build of
> packages. This way, instead of rsync'ing the code, we would directly
> build it from its original location. Some initial work was done in this
> area, but it's obviously a much larger endeavor than the fixup you are
> proposing. A more immediate alternative would be to also rsync the .git
> folder instead of excluding it, but do that globally for all packages
> that use override-srcdir. The .git directory was explicitly excluded to
> reduce the amount of data to rsync.

And in any case, it is still possible to hack this for now:

  - set LINUX_OVERRIDE_SRC_DIR in your local.mk
  - define the post-rsync hook there as well

Note: it is usualy possible to add the hook in local.mk, but it is
fragile: if the package itself uses post-rsync hooks, but its first
assignment is not an append-assignment +=, then your hook in local.mk is
ignored. In practice, we have no package [*] that uses post-rsync hooks,
so it shoiuld be safe to do define one in local.mk.

[*] of course, there is one exception: uboot, and I wonder if we should
not have a better solution nowadays.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR
  2022-07-18 20:21   ` Yann E. MORIN
@ 2022-07-18 23:05     ` Florian Fainelli
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2022-07-18 23:05 UTC (permalink / raw)
  To: Yann E. MORIN, Thomas Petazzoni; +Cc: mmayer, buildroot

On 7/18/22 13:21, Yann E. MORIN wrote:
> Florian, Thomas, All,
> 
> On 2022-07-18 15:01 +0200, Thomas Petazzoni via buildroot spake thusly:
>> On Wed,  6 Jul 2022 14:06:21 -0700
>> Florian Fainelli <f.fainelli@gmail.com> wrote:
>>> Linux is able to generate an automic version based upon the git tree
>>> that is being used which is very useful for making sure that the kernel
>>> being used is truly the one that we intend to be using.
>>>
>>> When using LINUX_OVERRIDE_SRCDIR however, since we do not rsync the .git
>>> folder, all of the necessary information for scripts/setlocalversion to
>>> compute the exact version and git commit id is lost.
>>>
>>> Add a post rsync hook that copies it over in order to allow 'git
>>> rev-parse' to work and produce an usable version.
>>>
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>
>> Thanks for your patch. What bothers me is that it is a Linux-specific
>> solution for a problem that isn't Linux-specific. Many other packages
>> also use Git commands to generate a version string that they embed in
>> their binaries. So this problem really is global and I'm not sure we
>> want a Linux-specific fixup for it.
> 
> Indeed.
> 
>> To me the long term solution is to enable out of tree build of
>> packages. This way, instead of rsync'ing the code, we would directly
>> build it from its original location. Some initial work was done in this
>> area, but it's obviously a much larger endeavor than the fixup you are
>> proposing. A more immediate alternative would be to also rsync the .git
>> folder instead of excluding it, but do that globally for all packages
>> that use override-srcdir. The .git directory was explicitly excluded to
>> reduce the amount of data to rsync.
> 
> And in any case, it is still possible to hack this for now:
> 
>   - set LINUX_OVERRIDE_SRC_DIR in your local.mk
>   - define the post-rsync hook there as well
> 
> Note: it is usualy possible to add the hook in local.mk, but it is
> fragile: if the package itself uses post-rsync hooks, but its first
> assignment is not an append-assignment +=, then your hook in local.mk is
> ignored. In practice, we have no package [*] that uses post-rsync hooks,
> so it shoiuld be safe to do define one in local.mk.

I suppose that works for now.

What I am really after anyway are out of tree build support for Linux, which ought to be taking care of two birds with the same stone here. Thanks!

> 
> [*] of course, there is one exception: uboot, and I wonder if we should
> not have a better solution nowadays.
> 
> Regards,
> Yann E. MORIN.
> 


-- 
Florian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-18 23:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-06 21:06 [Buildroot] [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR Florian Fainelli
2022-07-18 13:01 ` Thomas Petazzoni via buildroot
2022-07-18 20:21   ` Yann E. MORIN
2022-07-18 23:05     ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox