helpers/envkernel.sh: Try harder to not generate Git version suffix (MR 2084)

The Git version suffixes usually generated automatically by the Linux
build system break packaging in Alpine because the flavor (e.g.
"-postmarketos-qcom-msm8916") will no longer match the module and
zImage path. So far setting LOCALVERSION= and disabling
CONFIG_LOCALVERSION_AUTO was sufficient to avoid the Git version
suffixes but this is no longer enough in Linux 5.14.

Instead, add a better fix by creating an empty .scmversion file
that will be used by the kernel instead of checking the Git status.
The advantage is that this works on Linux 5.14 and it should even
work when CONFIG_LOCALVERSION_AUTO is set.

The .scmversion code can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/setlocalversion?h=v5.14-rc1#n38
This commit is contained in:
Minecrell 2021-07-12 14:59:25 +02:00 committed by Clayton Craft
parent a34db4c8fd
commit f62242aeb1
No known key found for this signature in database
GPG Key ID: 7A3461CA187CEA54
1 changed files with 3 additions and 5 deletions

View File

@ -14,6 +14,9 @@ check_kernel_folder() {
clean_kernel_src_dir() {
# Prevent Linux from appending Git version information to kernel version
# This will cause kernels to be packaged incorrectly.
touch .scmversion
if [ -f ".config" ] || [ -d "include/config" ]; then
echo "Source directory is not clean, running 'make mrproper'."
@ -222,11 +225,6 @@ set_alias_make() {
cmd="$cmd make -C /mnt/linux O=/mnt/linux/.output"
cmd="$cmd CC=$cc HOSTCC=$hostcc"
# Avoid "+" suffix in kernel version if the working directory is dirty.
# (Otherwise we will generate a package that uses different paths...)
# Note: Set CONFIG_LOCALVERSION_AUTO=n in kernel config additionally
cmd="$cmd LOCALVERSION="
# shellcheck disable=SC2139
alias make="$cmd"
unset cmd