scripts: Remove pre-3.10 kernel support

Reject unsupported kernel versions before download or patch generation.
Remove 2.x paths, RHEL 5/6 and Scientific Linux repositories, and
compatibility branches that cannot run with the Linux 3.10 minimum.

Keep the maintained ABT_KERNELS matrix unchanged.
This commit is contained in:
Gleb Chesnokov
2026-08-21 19:58:59 +03:00
parent f6ae51b613
commit 2b1dc822e8
5 changed files with 36 additions and 227 deletions
+26 -173
View File
@@ -20,20 +20,22 @@ function kernel_version_lt {
# Kernel version number.
function kernel_version {
if [ "${1#2.}" != "$1" ]; then
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p'
else
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\).*$/\1/p'
fi
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\).*$/\1/p'
}
# Last component of the kernel version, or the empty string if $1 does
# not contain a patchlevel.
function patchlevel {
if [ "${1#2.}" != "$1" ]; then
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
else
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
}
function check_kernel_version {
local kver
kver="$(kernel_version "${1/^*}")"
if [ -z "$kver" ] || kernel_version_lt "$kver" 3.10; then
echo "Error: kernel versions before 3.10 are not supported: $1" >&2
return 1
fi
}
@@ -56,10 +58,7 @@ function download_kernel {
local plevel="$(patchlevel "$1")"
local series="$1"
case "${series:0:2}" in
[12].*) series="${series:0:3}";;
*) series="${series/.*/}.x";;
esac
series="${series/.*/}.x"
mkdir -p "${kernel_downloads}" || return $?
@@ -129,23 +128,20 @@ function extract_kernel_tree {
# Patch a kernel tree where $1 is the kernel version.
function patch_kernel {
check_kernel_version "$1" || return $?
case "$1" in
*^*)
# RHEL-compatible distro or UEK.
;;
# RHEL-compatible distro or UEK.
;;
*)
# See also commit f153b82121b0 ("Sanitize gcc version header
# includes") # v2.6.29. See also commit 71458cfc782e ("kernel: add
# support for gcc 5") # v3.18. See also commit cb984d101b30
# ("compiler-gcc: integrate the various compiler-gcc[345].h
# files") # v4.2.
if kernel_version_le 2.6.29 "$1" && kernel_version_lt "$1" 4.2; then
# Tell the kernel that we are using gcc 4.6 since older kernel
# versions do not support recent gcc versions. See also commit
# 9c695203a7dd ("compiler-gcc.h: gcc-4.5 needs noclone and
# noinline on __naked functions") # v2.6.35.
if kernel_version_le 2.6.34.2 "$1"; then
patch -f -s -p1 <<'EOF'
if kernel_version_lt "$1" 4.2; then
patch -f -s -p1 <<'EOF'
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 02ae99e8e6d3..47e12c19c965 100644
--- a/include/linux/compiler-gcc.h
@@ -160,24 +156,9 @@ index 02ae99e8e6d3..47e12c19c965 100644
#if !defined(__noclone)
#define __noclone /* not needed */
EOF
else
patch -f -s -p1 <<'EOF'
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index a3ed7cb8ca34..c5a6b8b52db4 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -83,4 +83,4 @@
#define __gcc_header(x) #x
#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
#define gcc_header(x) _gcc_header(x)
-#include gcc_header(__GNUC__)
+#include "linux/compiler-gcc4.h"
EOF
fi
# See also commit 733ed6e43756 ("compiler-gcc{3,4}.h: Use
# GCC_VERSION macro") # v3.9.
if kernel_version_le 3.9 "$1"; then
patch -f -s -p1 <<'EOF'
patch -f -s -p1 <<'EOF'
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 769e19864632..2ec6c7a11502 100644
--- a/include/linux/compiler-gcc4.h
@@ -197,87 +178,10 @@ index 769e19864632..2ec6c7a11502 100644
#define __must_check __attribute__((warn_unused_result))
#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
EOF
else
patch -f -s -p1 <<'EOF'
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 412bc6c2b023..901ca31be7f8 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -2,13 +2,6 @@
#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
#endif
-/* GCC 4.1.[01] miscompiles __weak */
-#ifdef __KERNEL__
-# if __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1
-# error Your version of gcc miscompiles the __weak directive
-# endif
-#endif
-
#define __used __attribute__((__used__))
#define __must_check __attribute__((warn_unused_result))
#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
EOF
fi
fi
;;
esac
if [ "${1#2.6.31}" != "$1" ]; then
patch -f -s -p1 <<'EOF'
Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
with sparse (make C=2) triggers a sparse warning on code that uses the
kmemcheck_annotate_bitfield() macro. An example of such a warning:
include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Vegard Nossum <vegardno@ifi.uio.no>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
See also http://lkml.org/lkml/2009/9/26/51
--- linux-2.6.31.1/include/linux/kmemcheck-orig.h 2009-09-26 13:53:44.000000000 +0200
+++ linux-2.6.31.1/include/linux/kmemcheck.h 2009-09-26 13:53:56.000000000 +0200
@@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
int name##_end[0];
#define kmemcheck_annotate_bitfield(ptr, name) \
- do if (ptr) { \
+ do { if (ptr) { \
int _n = (long) &((ptr)->name##_end) \
- (long) &((ptr)->name##_begin); \
BUILD_BUG_ON(_n < 0); \
\
kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
- } while (0)
+ } } while (0)
#define kmemcheck_annotate_variable(var) \
do { \
EOF
fi
if [ "${1#2.6.32}" != "$1" ] || [ "${1#2.6.33}" != "$1" ]
then
patch -f -s -p1 <<'EOF'
Get rid of sparse errors on sk_buff.protocol.
--- linux/include/linux/skbuff-orig.h 2010-12-07 13:40:51.000000000 -0500
+++ linux/include/linux/skbuff.h 2010-12-07 13:41:05.000000000 -0500
@@ -349,8 +349,8 @@ struct sk_buff {
ipvs_property:1,
peeked:1,
nf_trace:1;
- __be16 protocol:16;
kmemcheck_bitfield_end(flags1);
+ __be16 protocol;
void (*destructor)(struct sk_buff *skb);
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
EOF
fi
if [ "${1#3.13}" != "$1" ]; then
if [ "$1" = "3.13" ] || [ "${1#3.13.}" -lt 6 ]; then
patch -f -s -p1 <<'EOF'
@@ -411,7 +315,7 @@ index d6d65537b0d9..6aad8308a0ac 100644
EOF
fi
if kernel_version_le 2.6.36 "$1" && kernel_version_lt "$1" 4.8; then
if kernel_version_lt "$1" 4.8; then
patch -f -s -p1 <<'EOF'
From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001
From: Borislav Petkov <bp@suse.de>
@@ -474,59 +378,6 @@ index 0ed6ce300543..c324b43712f0 100644
KBUILD_CFLAGS_MODULE := -DMODULE
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
EOF
else
case "$1" in
# CentOS 6.x.
2.6.32-*)
patch -f -s -p1 <<'EOF'
--- linux-2.6.32-754.29.1.el6/Makefile.orig 2020-05-13 14:09:18.448503420 -0700
+++ linux-2.6.32-754.29.1.el6/Makefile 2020-05-13 14:11:24.265441790 -0700
@@ -355,7 +355,8 @@
KBUILD_CPPFLAGS := -D__KERNEL__
-KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS := $(call cc-option,-fno-PIE) \
+ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
@@ -380,7 +381,7 @@
endif ##($(KBUILD_EXTMOD),)
endif #(,$(filter $(ARCH), i386 x86_64))
-KBUILD_AFLAGS := -D__ASSEMBLY__
+KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
EOF
;;
2.6.3[1-5]*)
patch -f -s -p1 <<'EOF'
diff --git a/Makefile b/Makefile
index 141da26fda4b..343ec388ae2e 100644
--- a/Makefile
+++ b/Makefile
@@ -349,12 +349,13 @@ LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
KBUILD_CPPFLAGS := -D__KERNEL__
-KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS := $(call cc-option,-fno-PIE) \
+ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks
-KBUILD_AFLAGS := -D__ASSEMBLY__
+KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
EOF
;;
esac
fi
case "$1" in
@@ -610,7 +461,7 @@ index 8fa38d3e7538..f5bc4c046461 100644
EOF
;;
2.*|3.*)
3.*)
patch -f -s -p1 <<'EOF'
--- linux-3.10.0-1127.el7/include/linux/init.h.orig 2020-05-09 20:55:48.638956513 -0700
+++ linux-3.10.0-1127.el7/include/linux/init.h 2020-05-09 20:56:46.947612445 -0700
@@ -636,7 +487,7 @@ EOF
;;
esac
if kernel_version_le 3.2 "$1" && kernel_version_lt "$1" 3.18; then
if kernel_version_lt "$1" 3.18; then
patch -f -s -p1 <<'EOF'
From eeeda4cd06e828b331b15741a204ff9f5874d28d Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
@@ -678,7 +529,7 @@ EOF
# See also commit e33a814e772c ("scripts/dtc: Remove redundant YYLOC global
# declaration") # v5.6~10^2.
if kernel_version_le 2.6.38 "$1" && kernel_version_lt "$1" 5.6; then
if kernel_version_lt "$1" 5.6; then
patch -p1 -f -s <<'EOF'
From e33a814e772cdc36436c8c188d8c42d019fda639 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dmueller@suse.com>
@@ -745,7 +596,7 @@ EOF
# See also commit 52a9dab6d892 ("libsubcmd: Fix use-after-free for
# realloc(..., 0)") # v5.17
if kernel_version_le 2.6.38 "$1" && kernel_version_lt "$1" 5.17; then
if kernel_version_lt "$1" 5.17; then
patch -p1 -f -s <<'EOF'
From 52a9dab6d892763b2a8334a568bd4e2c1a6fde66 Mon Sep 17 00:00:00 2001
From: Kees Cook <keescook@chromium.org>
@@ -937,6 +788,8 @@ function download_and_extract_distro_rpm {
}
function download_and_extract_kernel_tree {
check_kernel_version "$1" || return $?
if [ "${1/^}" = "$1" ]; then
# Upstream kernel.
if [ -e "${kernel_tree}" ]; then