-
Notifications
You must be signed in to change notification settings - Fork 20
239 lines (206 loc) · 7.8 KB
/
Copy pathbuild.yml
File metadata and controls
239 lines (206 loc) · 7.8 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Build NP2 Kernel
permissions:
contents: write
actions: write
on:
workflow_dispatch:
inputs:
kernel_repo:
description: 'Kernel source repo'
required: false
type: string
default: 'https://github.com/LineageOS/android_kernel_nothing_sm8475.git'
kernel_branch:
description: 'Kernel branch'
required: false
type: string
default: 'lineage-23.2'
kernel_defconfig:
description: 'Defconfig (relative to arch/arm64/configs/)'
required: false
type: string
default: 'gki_defconfig'
extra_configs:
description: 'Extra config fragments to merge (space-separated, relative to arch/arm64/configs/)'
required: false
type: string
default: 'vendor/waipio_GKI.config vendor/nothing/waipio_GKI.config vendor/debugfs.config'
workflow_call:
inputs:
kernel_repo:
required: false
type: string
default: 'https://github.com/LineageOS/android_kernel_nothing_sm8475.git'
kernel_branch:
required: false
type: string
default: 'lineage-23.2'
kernel_defconfig:
required: false
type: string
default: 'gki_defconfig'
extra_configs:
required: false
type: string
default: 'vendor/waipio_GKI.config vendor/nothing/waipio_GKI.config vendor/debugfs.config'
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 120
env:
MAKE_ARGS: >-
ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabi-
LLVM=1 LLVM_IAS=1
LD=ld.lld HOSTLD=ld.lld
CC=clang CXX=clang++
HOSTCC=clang HOSTCXX=clang++
O=out
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential bc bison flex libelf-dev libssl-dev \
lz4 zip python3 clang llvm lld gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi
- name: Clone sources
run: |
# Kernel
git clone --depth=1 -b "${{ inputs.kernel_branch || 'lineage-23.2' }}" \
"${{ inputs.kernel_repo || 'https://github.com/LineageOS/android_kernel_nothing_sm8475.git' }}" \
kernel
# AnyKernel3
git clone --depth=1 https://github.com/osm0sis/AnyKernel3.git
rm -rf AnyKernel3/.git
# SUSFS
git clone --depth=1 -b gki-android13-5.10 \
https://gitlab.com/simonpunk/susfs4ksu.git
- name: Setup ReSukiSU
run: |
cd kernel
curl -LSs "https://raw.githubusercontent.com/ReSukiSU/ReSukiSU/main/kernel/setup.sh" | bash
- name: Apply SUSFS patches
run: |
cd kernel
# Copy SUSFS source files
cp ../susfs4ksu/kernel_patches/fs/* ./fs/
cp ../susfs4ksu/kernel_patches/include/linux/* ./include/linux/
# Apply kernel patch
patch -p1 < ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-android13-5.10.patch
# Safety net: force susfs.o into the build regardless of Kconfig resolution.
# The Configure step uses scripts/config to guarantee CONFIG_KSU_SUSFS=y,
# but obj-y avoids a silent empty-object link failure if it gets dropped.
# sed -i 's/obj-$(CONFIG_KSU_SUSFS) += susfs.o/obj-y += susfs.o/' fs/Makefile
# grep -q 'susfs\.o' fs/Makefile || echo 'obj-y += susfs.o' >> fs/Makefile
# In case I need the below for other kernel I keep it but not needed rn :b
# - name: Add ReSukiSU patches
# run: |
# cd kernel
# # Apply ReSukiSU patches
# find ../patches -type f -name '*.diff' | while read -r patch; do
# echo "Applying $patch"
# patch -p1 < "$patch"
# done
- name: Configure kernel
run: |
cd kernel
DEFCONFIG="./arch/arm64/configs/${{ inputs.kernel_defconfig || 'gki_defconfig' }}"
# Merge extra config fragments into defconfig (if any)
EXTRA="${{ inputs.extra_configs }}"
if [ -n "$EXTRA" ]; then
for frag in $EXTRA; do
FRAG_PATH="./arch/arm64/configs/$frag"
if [ -f "$FRAG_PATH" ]; then
echo "Merging: $frag"
cat "$FRAG_PATH" >> "$DEFCONFIG"
fi
done
fi
# Add ReSukiSU configs
echo "CONFIG_KSU=y" >> "$DEFCONFIG"
echo "CONFIG_KPM=y" >> "$DEFCONFIG"
echo "CONFIG_KSU_SUSFS=y" >> "$DEFCONFIG"
echo "CONFIG_KSU_MANUAL_HOOK=y" >> "$DEFCONFIG"
echo "CONFIG_KSU_MANUAL_HOOK_AUTO_INPUT_HOOK=y" >> "$DEFCONFIG"
echo "CONFIG_KSU_MANUAL_HOOK_AUTO_SETUID_HOOK=y" >> "$DEFCONFIG"
echo "CONFIG_KSU_MANUAL_HOOK_AUTO_INITRC_HOOK=y" >> "$DEFCONFIG"
# Generate initial .config from defconfig
make $MAKE_ARGS "${{ inputs.kernel_defconfig || 'gki_defconfig' }}"
# Force-set configs via scripts/config so Kconfig cannot silently drop them
KCFG="./scripts/config --file out/.config"
$KCFG -e KSU
$KCFG -e KSU_SUSFS
# Resolve dependencies without dropping our forced configs
make $MAKE_ARGS olddefconfig
# Remove -dirty suffix
[ -f scripts/setlocalversion ] && sed -i 's/-dirty//g' scripts/setlocalversion || true
- name: Enable swap space
run: |
# Remove existing swap file first
sudo swapoff /swapfile 2>/dev/null || true
sudo rm -f /swapfile
sudo fallocate -l 12G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
- name: Build kernel
run: |
cd kernel
# Reduce parallel jobs to prevent memory exhaustion
JOBS=$(( $(nproc) / 2 ))
[ "$JOBS" -lt 1 ] && JOBS=1
make -j$JOBS $MAKE_ARGS KCFLAGS="-Wno-error"
- name: Package AnyKernel3
run: |
# Verify build output exists
if [ ! -f kernel/out/arch/arm64/boot/Image ]; then
echo "ERROR: kernel Image not found — build failed"
exit 1
fi
# Copy kernel image
cp kernel/out/arch/arm64/boot/Image AnyKernel3/
cp kernel/out/arch/arm64/boot/Image.gz AnyKernel3/ 2>/dev/null || true
# Copy anykernel.sh from repo and set variant kernel string
cp Scripts/anykernel.sh AnyKernel3/anykernel.sh
sed -i 's/kernel.string=.*/kernel.string=NP2 Kernel - ReSukiSU/' AnyKernel3/anykernel.sh
# Create zip
cd AnyKernel3
ZIP_NAME="ReSukiSU-NP2-Pong.zip"
zip -r9 "../$ZIP_NAME" ./*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: kernel-NP2-ReSukiSU
path: "*.zip"
retention-days: 30
- name: Upload .config for debugging
if: always()
uses: actions/upload-artifact@v4
with:
name: config-NP2-ReSukiSU
path: kernel/out/.config
retention-days: 1
- name: Collect .rej files
if: always()
id: collect_rej
run: |
mkdir -p rej
found="false"
while IFS= read -r -d '' f; do
found="true"
mkdir -p "rej/$(dirname "$f")"
cp "$f" "rej/$f"
orig="${f%.rej}"
[ -f "$orig" ] && cp "$orig" "rej/$orig"
done < <(find . -name '*.rej' -print0)
echo "found=$found" >> "$GITHUB_OUTPUT"
- name: Upload .rej files
if: always() && steps.collect_rej.outputs.found == 'true'
uses: actions/upload-artifact@v4
with:
name: rej-NP2-ReSukiSU
path: rej/