File: ubuntu-kernel-variants.patch

package info (click to toggle)
kpatch 0.9.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,716 kB
  • sloc: ansic: 9,716; sh: 2,592; makefile: 260; asm: 35
file content (107 lines) | stat: -rw-r--r-- 3,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Description: support ubuntu kernel flavors
 Add support for kernel flavors (generic, lowlatency, aws, etc...) the flavor
 may contain dashes and/or tildes, so handle these cases.

Author: Benjamin M Romer <benjamin.romer@canonical.com>
Last-Update: 2022-05-24
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -741,7 +741,7 @@
 	die "gawk not installed"
 fi
 
-options="$(getopt -o ha:r:s:c:v:j:t:n:o:dR -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace,version" -- "$@")" || die "getopt failed"
+options="$(getopt -o ha:r:s:c:v:j:t:n:o:dRf -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace,version" -- "$@")" || die "getopt failed"
 
 eval set -- "$options"
 
@@ -827,6 +827,10 @@
 		echo "Version : $VERSION"
 		exit 0
 		;;
+	-f|--flavor)
+		FLAVOR="$2"
+		shift
+		;;
 	*)
 		[[ "$1" = "--" ]] && shift && continue
 		[[ ! -f "$1" ]] && die "patch file '$1' not found"
@@ -883,12 +887,25 @@
 		fi
 		ARCHVERSION="$VMLINUX_VER"
 	fi
+	FLAV=${ARCHVERSION#*-*-}
+	if [[ -n "$FLAVOR" ]]; then
+		if [[ "$FLAVOR" != "$FLAV" ]]; then
+			die "specified flavor $FLAVOR does not match vmlinux ($FLAV)"
+		fi
+	else
+			FLAVOR=$FLAV
+	fi
 fi
 
 if [[ -n "$OOT_MODULE" ]]; then
 	ARCHVERSION="$(modinfo -F vermagic "$OOT_MODULE" | awk '{print $1}')"
 fi
 
+
+if [[ -z "$FLAVOR" ]]; then
+	FLAVOR=$(uname -r | cut -d - -f 3)
+fi
+
 [[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)"
 
 if [[ -n "$OOT_MODULE" ]]; then
@@ -898,7 +915,7 @@
 	BUILDDIR="$OOT_MODULE_SRCDIR"
 else
 	if [[ $DISTRO = ubuntu ]]; then
-		BUILDDIR="$TEMPDIR/build-generic"
+		BUILDDIR="$TEMPDIR/build-$FLAVOR"
 		mkdir -p "$BUILDDIR"
 	else
 		BUILDDIR="$KERNEL_SRCDIR"
@@ -1306,7 +1323,7 @@
 	# shellcheck disable=SC1117
 	MAKEFLAGS="--no-print-directory" fakeroot \
 		debian/rules "${MAKEVARS[@]}" "-j$CPUS" \
-		build-generic build_image=vmlinux builddir="$TEMPDIR" \
+		"build-$FLAVOR" build_image=vmlinux builddir="$TEMPDIR" \
 		enable_zfs=false  2>&1 | logger \
 		|| die
 else
@@ -1317,7 +1334,7 @@
 
 MODULE_SYMVERS="$KERNEL_SRCDIR/Module.symvers"
 if [[ "$DISTRO" = ubuntu ]]; then
-	MODULE_SYMVERS="$TEMPDIR/build-generic/Module.symvers"
+	MODULE_SYMVERS="$TEMPDIR/build-$FLAVOR/Module.symvers"
 fi
 
 # Save original module symvers
@@ -1331,11 +1348,11 @@
 save_env
 
 if [[ $DISTRO = ubuntu ]]; then
-	rm -f debian/stamps/stamp-build-generic
+	rm -f "debian/stamps/stamp-build-$FLAVOR"
 	# shellcheck disable=SC1117
 	MAKEFLAGS="--no-print-directory" fakeroot \
 		debian/rules "${MAKEVARS[@]}" "-j$CPUS" \
-		build-generic build_image=vmlinux builddir="$TEMPDIR" \
+		"build-$FLAVOR" build_image=vmlinux builddir="$TEMPDIR" \
 		enable_zfs=false  2>&1 | logger \
 		|| die
 else
@@ -1536,6 +1553,9 @@
 KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS" \
 KPATCH_LDFLAGS="$KPATCH_LDFLAGS" \
 CROSS_COMPILE="$CROSS_COMPILE"
+if [[ $DISTRO = ubuntu ]]; then
+	export KPATCH_BUILD="$BUILDDIR"
+fi
 save_env
 
 make "${MAKEVARS[@]}" 2>&1 | logger || die