Message ID | 20220706210621.284257-1-f.fainelli@gmail.com |
---|---|
State | Rejected |
Headers | show |
Series | [RFC] linux: Make CONFIG_LOCALVERSION_AUTO work with OVERRIDE_SRCDIR | expand |
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
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.
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. >
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
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(+)