linux: preserve VCS info when using OVERRIDE_SRCDIR
PATCH v2 1/1 linux: preserve VCS info when using OVERRIDE_SRCDIR
The Linux build system will try to include VCS information into the kernel version. This is very convenient when developing to be sure you're looking at the right kernel.
However, since Buildroot rsyncs everything to the build directory, but leaves the .git directory behind, this version information is lost.
Fortunately, the kernel's setlocalversion script supports this kind of situation: it can save the VCS info in a file ".scmversion" and use that during the build. Calling the script with --save-scmversion will create .scmversion.
The --save-scmversion option exists since v2.6.35. On older kernels, we just ignore the error. It can be assumed that people using older kernel don't do a lot of development anymore :-)
We can just unconditionally run this in a POST_RSYNC_HOOK - it will only get executed when LINUX_OVERRIDE_SRCDIR is used.
Note that in kernels before v3.14, the Buildroot git commit would be used, which is even more confusing.
Note that if we ever support out-of-tree builds for the kernel, this patch will no longer be needed.
---
In a similar vein, it would be useful to save some version information for the normal kernel builds. Currently, for v3.14+ kernels, we just get the upstream kernel version even if it is a vendor/local kernel. And for older kernels, we get the Buildroot VCS info.
However, it turns out to be quite complicated to get this version info. For CUSTOM_TARBALL it's plain impossible. For CUSTOM_VERSION it's not necessary, because (at least for v3.14+ kernels) setlocalversion already produces the correct value. For CUSTOM_GIT/HG/SVN, we do have version info, but it's not nicely formatted like the results of setlocalversion. In those cases we should run setlocalversion from within the download helper script...
Changes v2: actually added the || true - forgot to commit --amend,
a skill I learned from Yann :-P
--- linux/linux.mk | 7 +++++++ 1 file changed, 7 insertions(+)
linux/linux.mk +7 -0
@@ -51,6 +51,13 @@ LINUX_SITE := $(LINUX_SITE)/testing endif # -rc endif +# Conserve VCS information for override srcdir +define LINUX_ADD_LOCALVERSION + cd $(@D); \ + ./scripts/setlocalversion --save-scmversion $(LINUX_OVERRIDE_SRCDIR) || true +endef +LINUX_POST_RSYNC_HOOKS += LINUX_ADD_LOCALVERSION + LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH)) # We rely on the generic package infrastructure to download and apply
Signature · 1 line
2.11.0
PATCH v2 1/1 linux: preserve VCS info when using OVERRIDE_SRCDIR
Hello,
Quoted 20 lines · Arnout Vandecappelle (Essensium/Mind)
The Linux build system will try to include VCS information into the kernel version. This is very convenient when developing to be sure you're looking at the right kernel.
However, since Buildroot rsyncs everything to the build directory, but leaves the .git directory behind, this version information is lost.
Fortunately, the kernel's setlocalversion script supports this kind of situation: it can save the VCS info in a file ".scmversion" and use that during the build. Calling the script with --save-scmversion will create .scmversion.
The --save-scmversion option exists since v2.6.35. On older kernels, we just ignore the error. It can be assumed that people using older kernel don't do a lot of development anymore :-)
We can just unconditionally run this in a
POST_RSYNC_HOOK- it will only get executed whenLINUX_OVERRIDE_SRCDIRis used.
Quoted 7 lines
Note that in kernels before v3.14, the Buildroot git commit would be used, which is even more confusing.
Note that if we ever support out-of-tree builds for the kernel, this patch will no longer be needed.
I am not super enthusiastic about this change, for the simple reason that it solves the problem only for the linux package.
I believe what is really needed instead is to support out of tree build for packages that use OVERRIDE_SRCDIR/SITE_METHOD=local. That will solve this problem for all packages, and bring many other benefits.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v2 1/1 linux: preserve VCS info when using OVERRIDE_SRCDIR
Quoted 30 lines · Thomas Petazzoni
Hello,
Quoted 26 lines · Arnout Vandecappelle (Essensium/Mind)
The Linux build system will try to include VCS information into the kernel version. This is very convenient when developing to be sure you're looking at the right kernel.
However, since Buildroot rsyncs everything to the build directory, but leaves the .git directory behind, this version information is lost.
Fortunately, the kernel's setlocalversion script supports this kind of situation: it can save the VCS info in a file ".scmversion" and use that during the build. Calling the script with --save-scmversion will create .scmversion.
The --save-scmversion option exists since v2.6.35. On older kernels, we just ignore the error. It can be assumed that people using older kernel don't do a lot of development anymore :-)
We can just unconditionally run this in a
POST_RSYNC_HOOK- it will only get executed whenLINUX_OVERRIDE_SRCDIRis used.Note that in kernels before v3.14, the Buildroot git commit would be used, which is even more confusing.
Note that if we ever support out-of-tree builds for the kernel, this patch will no longer be needed.
Quoted 8 lines
Quoted 1 line
I am not super enthusiastic about this change, for the simple reason that it solves the problem only for the linux package.
I believe what is really needed instead is to support out of tree build for packages that use OVERRIDE_SRCDIR/SITE_METHOD=local. That will solve this problem for all packages, and bring many other benefits.
I couldn't agree more. I remember that someone once posted patches on the list
to this effect, but they never went anywhere and the original poster seems to have lost his latest version :-P
I needed a solution *now*, so I posted it. If anyone else needs it, they can
pick up the patch.
I've marked the patch as Rejected in patchwork.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF