-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkernel-module_patch.sh
More file actions
executable file
·32 lines (21 loc) · 1.27 KB
/
Copy pathkernel-module_patch.sh
File metadata and controls
executable file
·32 lines (21 loc) · 1.27 KB
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
#!/bin/bash
# find out kernel version to use ------------------------------------------------------------------
KERNEL_VERSION=$kernelver
. kernel-version_get.sh
if [ -z $SOURCE_SUB_VERSION ]; then
echo "Determining the kernel subversion not (yet) supported for your Linux distro. You might want to modify the distro-specific commands. Aborting."
exit 4
fi
echo "Building for kernel version ${KERNEL_VERSION}"
# download kernel source and patch it -------------------------------------------------------------
# see https://www.collabora.com/news-and-blog/blog/2021/05/05/quick-hack-patching-kernel-module-using-dkms/
[ "${SOURCE_SUB_VERSION}" = '0' ] && unset SOURCE_SUB_VERSION
SOURCE_VERSION_STRING="${SOURCE_MAJOR_VERSION}.${SOURCE_MINOR_VERSION}$( [ -n "${SOURCE_SUB_VERSION}" ] && echo ".${SOURCE_SUB_VERSION}" )"
echo "Downloading source ${SOURCE_VERSION_STRING} for installed kernel ${KERNEL_VERSION}"
wget "https://mirrors.edge.kernel.org/pub/linux/kernel/v${SOURCE_MAJOR_VERSION}.x/linux-${SOURCE_VERSION_STRING}.tar.xz"
echo "Extracting original source of the kernel module"
tar -xf "linux-${SOURCE_VERSION_STRING}.tar."* "linux-${SOURCE_VERSION_STRING}/${1}" "--xform=s,linux-${SOURCE_VERSION_STRING}/$1,.,"
for i in `ls *.patch`; do
echo "Applying $i"
patch < $i
done