diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 2029b558..a7345340 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -210,6 +210,8 @@ restore_kernel_files() { } cleanup() { + rm -f "$BUILDDIR/.scmversion" + remove_patches restore_kernel_files @@ -1118,18 +1120,23 @@ fi # appended to the kernel version string (VERMAGIC_STRING), even if the original # kernel was not dirty. That can complicate both the build (create-diff-object # false positive changes) and the patch module link (module version mismatch -# load failures). +# load failures). Before making any changes to the source: +# +# For pre-v6.3 kernels: +# Run `./scripts/setlocalversion --save-scmversion`. # -# Prevent that by replacing the original setlocalversion with a friendlier one -# which just echo's the original version. This should be done before any -# changes to the source. +# For v6.3+ kernels: +# Replace the original setlocalversion with a friendlier one which just echo's +# the original version. if [[ -n "$USERSRCDIR" && -e "$KERNEL_SRCDIR/.git" ]]; then cd "$KERNEL_SRCDIR" || die - backup_kernel_file "scripts/setlocalversion" - LOCALVERSION="$(make kernelversion)" - LOCALVERSION="$(KERNELVERSION="$LOCALVERSION" ./scripts/setlocalversion)" - [[ -n "$LOCALVERSION" ]] || die "setlocalversion failed" - echo "echo $LOCALVERSION" > scripts/setlocalversion + if ! ./scripts/setlocalversion --save-scmversion &>/dev/null; then + backup_kernel_file "scripts/setlocalversion" + LOCALVERSION="$(make kernelversion)" + LOCALVERSION="$(KERNELVERSION="$LOCALVERSION" ./scripts/setlocalversion)" + [[ -n "$LOCALVERSION" ]] || die "setlocalversion failed" + echo "echo $LOCALVERSION" > scripts/setlocalversion + fi fi # kernel option checking