-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_kernel.yml
More file actions
144 lines (129 loc) · 4.27 KB
/
build_kernel.yml
File metadata and controls
144 lines (129 loc) · 4.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build Linux Kernel (5.10 and 6.6)
on:
push:
branches:
- main
workflow_dispatch: # 手动触发工作流
jobs:
build:
runs-on: ubuntu-latest # 使用最新的 Ubuntu 环境
steps:
# 检出代码
- name: Checkout repository
uses: actions/checkout@v2
# 设置交叉编译工具链
- name: Set up cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libncurses-dev \
bison \
flex \
libssl-dev \
libelf-dev \
bc \
git \
wget \
ccache \
zlib1g-dev \
liblz4-tool \
libusb-1.0-0-dev \
gcc-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu
# 设置变量
- name: Set up kernel version and paths
run: |
export BUILD_DIR="$GITHUB_WORKSPACE/kernel_build"
export KERNEL_SRC_DIR="$BUILD_DIR/kernel_src"
export OUT_DIR="$BUILD_DIR/out"
export ANYKERNEL_DIR="$BUILD_DIR/AnyKernel3"
export KERNEL_REPO="https://github.com/liliumproject/kernel_xiaomi_gold.git"
export TOOLCHAIN_AARCH64="/usr/bin/aarch64-linux-gnu-"
export TOOLCHAIN_ARM="/usr/bin/arm-linux-gnueabihf-"
export KERNEL_VERSION="${{ github.event.inputs.kernel_version }}"
echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV
# 克隆内核源代码并切换版本
- name: Clone kernel source
run: |
mkdir -p $KERNEL_SRC_DIR
git clone $KERNEL_REPO $KERNEL_SRC_DIR
cd $KERNEL_SRC_DIR
if [ "$KERNEL_VERSION" == "5.10" ]; then
git checkout 5.10
elif [ "$KERNEL_VERSION" == "6.6" ]; then
git checkout 6.6
else
echo "Unsupported kernel version"
exit 1
fi
# 安装依赖
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libncurses-dev \
bison \
flex \
libssl-dev \
libelf-dev \
bc \
git \
wget \
ccache \
zlib1g-dev \
liblz4-tool \
libusb-1.0-0-dev
# 配置内核 (ARM64)
- name: Configure kernel for ARM64
run: |
cd $KERNEL_SRC_DIR
make ARCH=arm64 CROSS_COMPILE=$TOOLCHAIN_AARCH64 O=$OUT_DIR sukisuultra_defconfig
echo "CONFIG_SLUB=y" >> $OUT_DIR/.config
echo "CONFIG_SLUB_DEBUG=y" >> $OUT_DIR/.config
echo "CONFIG_ZRAM=y" >> $OUT_DIR/.config
echo "CONFIG_ZSWAP=y" >> $OUT_DIR/.config
echo "CONFIG_ZSWAP_COMPRESSORS_LZ4=y" >> $OUT_DIR/.config
echo "CONFIG_OVERCOMMIT_MEMORY=1" >> $OUT_DIR/.config
echo "CONFIG_OVERCOMMIT_RATIO=80" >> $OUT_DIR/.config
echo "CONFIG_NUMA=y" >> $OUT_DIR/.config
echo "CONFIG_CGROUPS=y" >> $OUT_DIR/.config
echo "CONFIG_MEMCG=y" >> $OUT_DIR/.config
# 编译内核(ARM64)
- name: Build kernel for ARM64
run: |
cd $KERNEL_SRC_DIR
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=$TOOLCHAIN_AARCH64 O=$OUT_DIR
if [ ! -f "$OUT_DIR/arch/arm64/boot/Image" ]; then
echo "Kernel build failed: Image not found!"
exit 1
fi
# 克隆 AnyKernel3
- name: Clone AnyKernel3
run: |
git clone https://github.com/osm0sis/AnyKernel3.git $ANYKERNEL_DIR
rm -rf $ANYKERNEL_DIR/*
# 将编译好的内核镜像和设备树复制到 AnyKernel3
- name: Copy kernel image and device tree to AnyKernel3
run: |
cp $OUT_DIR/arch/arm64/boot/Image $ANYKERNEL_DIR/
cp $OUT_DIR/arch/arm64/boot/dts/*.dtb $ANYKERNEL_DIR/
# 复制编译好的模块
- name: Copy kernel modules to AnyKernel3
run: |
cp -r $OUT_DIR/lib/modules/* $ANYKERNEL_DIR/modules/
# 打包内核
- name: Package kernel with AnyKernel3
run: |
cd $ANYKERNEL_DIR
./anykernel.sh
# 上传构建好的内核包
- name: Upload Kernel Package
uses: actions/upload-artifact@v2
with:
name: kernel-package
path: $ANYKERNEL_DIR/*.zip
# 打印构建完成信息
- name: Build complete
run: echo "Kernel build completed. The package is available in the artifacts."