/ build-kernel.sh
build-kernel.sh
 1  #!/bin/bash
 2  
 3  set -xeo pipefail
 4  
 5  linux_t2_patches_commit_hash="4cd1efe5cf92f53bea7fcabf20277e06e41dae95"
 6  linux_t2_archive="${linux_t2_patches_commit_hash}.tar.gz"
 7  linux_t2_patches_url="https://github.com/t2linux/linux-t2-patches/archive/${linux_t2_archive}"
 8  linux_t2_dir="linux-t2-patches-${linux_t2_patches_commit_hash}"
 9  
10  # kernel_ver="6.18.18"
11  kernel_ver="6.18.18"
12  kernel_archive="linux-${kernel_ver}.tar.gz"
13  kernel_url="https://www.kernel.org/pub/linux/kernel/v6.x/${kernel_archive}"
14  kernel_dir="linux-${kernel_ver}"
15  
16  mkdir -p build
17  cd build
18  
19  wget -nc -q -O "${linux_t2_archive}" "${linux_t2_patches_url}" || true
20  wget -nc -q -O "linux-${kernel_ver}.tar.gz" "${kernel_url}" || true
21  
22  if [[ -d "${linux_t2_dir}" ]]; then
23      rm -rf "${linux_t2_dir}"
24  fi
25  if [[ -d "${kernel_dir}" ]]; then
26      rm -rf "${kernel_dir}"
27  fi
28  
29  tar -xf "${linux_t2_archive}"
30  tar -xf "${kernel_archive}"
31  
32  cd "${kernel_dir}"
33  for patch in ../${linux_t2_dir}/*.patch; do
34      patch -p1 < $patch
35  done