0

I am using buildroot to generate an OS and would like to append a dynamically-generated version string to the linux kernel version to be reported with uname -r. I see that I can set a fixed string with the linux's LOCALVERSION configuration option, but I don't have a way to populate that dynamically at build time.

I also see you can add a file to the linux src tree name "localversion*" that will append to the version string, but I can't find a hook or way to generate that file pre-build. Buildroot has a great post-build script, but I need the file generated pre-build. My current thought is to create a patch that can add the version file, but I still can't find a way within the buildroot process to generate that patch file with my desired string.

Does buildroot have a pre-build hook or the like that I can generate that patch file, and apply it after the linux src is downloaded, but before it is compiled?

T. Waters
  • 3
  • 4

1 Answers1

0

There is no built in way to do this, but if you use a br2-external tree then you can add a post-configure hook for the Linux package, E.G. something like:

# Include Linux git version info in uname.  Maximum length is 64 chars,
# so limit to 64-strlen("x.yy.zzz-")
define LINUX_ADD_LOCALVERSION
        [ -z "${BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION}" ] || \
                printf -- "-%.55s\n" "${LINUX_VERSION}" > $(@D)/localversion-custom
endef
LINUX_POST_CONFIGURE_HOOKS += LINUX_ADD_LOCALVERSION


Peter Korsgaard
  • 626
  • 4
  • 3