Skip to content

Commit 5d0cd76

Browse files
authored
Refactor OnePlus 7 Kernel build workflow
1 parent 5d28919 commit 5d0cd76

File tree

1 file changed

+116
-216
lines changed

1 file changed

+116
-216
lines changed

.github/workflows/Novendor.yml

Lines changed: 116 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -1,246 +1,146 @@
1-
name: Build kernel (KSN) & WIFI A16 -- no vendor, no blobs
1+
name: Build OnePlus 7 Kernel (No Vendor Blobs)
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
kernel_source_url:
7-
description: "URL of the kernel source repository"
8-
required: true
9-
default: "https://github.com/LineageOS/android_kernel_oneplus_sm8150"
10-
kernel_branch:
11-
description: "Branch of the kernel source"
12-
required: true
13-
default: "lineage-23.0"
14-
kernel_defconfig:
15-
description: "defconfig file to use"
16-
required: true
17-
default: "vendor/sm8150_defconfig"
18-
output_name:
19-
description: "Name of the output.zip"
20-
required: false
21-
default: "OP7_KSN_wifi-LOS-noVendor.zip"
22-
apply_kernelsu:
23-
description: "Apply KernelSU patch (true/false)"
24-
required: true
25-
default: "false"
26-
kernelsu_patch_url:
27-
description: "KernelSU setup.sh URL (ignored if apply_kernelsu=false)"
28-
required: false
29-
default: "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh"
5+
push:
6+
branches:
7+
- main
8+
- lineage-21
9+
- android-16
3010

3111
jobs:
3212
build:
33-
runs-on: ubuntu-latest
34-
env:
35-
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
36-
CCACHE_NOHASHDIR: "true"
37-
CCACHE_MAXSIZE: "2G"
38-
KERNEL_CMDLINE: "ARCH=arm64 LLVM=1 LLVM_IAS=1 O=out CROSS_COMPILE=aarch64-linux-gnu- CLANG_TRIPLE=aarch64-linux-gnu-"
39-
OUTPUT_ZIP_NAME: ${{ github.event.inputs.output_name || 'OP7_KSN_wifi-LOS-noVendor.zip' }}
13+
runs-on: ubuntu-22.04
4014

4115
steps:
42-
- name: Checkout repository
16+
- name: Checkout source
4317
uses: actions/checkout@v4
44-
with:
45-
fetch-depth: 0
4618

47-
- name: Checkout Kernel Source
48-
env:
49-
KERNEL_SOURCE_URL: ${{ github.event.inputs.kernel_source_url || 'https://github.com/LineageOS/android_kernel_oneplus_sm8150' }}
50-
KERNEL_BRANCH: ${{ github.event.inputs.kernel_branch || 'lineage-23.0' }}
19+
- name: Setup build environment
5120
run: |
52-
set -euo pipefail
53-
git clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_SOURCE_URL}" kernel
54-
cd kernel
55-
git submodule update --init --recursive
21+
sudo apt-get update
22+
sudo apt-get install -y bc bison flex clang lld llvm lz4 \
23+
make python3 git zip curl wget ccache \
24+
libssl-dev rsync tar
5625
57-
- name: Set up ccache
58-
uses: hendrikmuhs/ccache-action@v1.2
59-
60-
- name: Cleanup space
26+
- name: Download prebuilt Clang toolchain
6127
run: |
62-
set -euo pipefail
63-
sudo rm -rf /opt/ghc /usr/local/share/boost /usr/share/dotnet "${AGENT_TOOLSDIRECTORY:-/opt/hostedtoolcache}" || true
28+
mkdir -p clang
29+
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-r530567.tar.gz -O clang.tar.gz
30+
tar -xf clang.tar.gz -C clang
31+
echo "Clang toolchain extracted."
6432
65-
- name: Install dependencies
33+
- name: Set derived env / defaults
6634
run: |
67-
set -euo pipefail
68-
sudo apt-get update -y
69-
sudo apt-get install -y \
70-
clang-18 llvm-18 lld-18 gcc-aarch64-linux-gnu \
71-
binutils-aarch64-linux-gnu binutils make python3 libssl-dev \
72-
build-essential bc bison flex unzip git git-lfs libelf-dev pahole \
73-
zip
74-
git clone https://github.com/khalidaboelmagd/AnyKernel3
75-
rm -rf AnyKernel3/.git
76-
mkdir -p modules/vendor/lib/modules
77-
78-
- name: Optional KernelSU-Next setup
79-
if: ${{ inputs.apply_kernelsu == 'true' }}
80-
working-directory: kernel
81-
env:
82-
KSU_URL: ${{ github.event.inputs.kernelsu_patch_url }}
35+
echo "KERNEL_DEFCONFIG=${{ github.event.inputs.kernel_defconfig || 'vendor/sm8150_defconfig' }}" >> $GITHUB_ENV
36+
echo "KERNEL_SOURCE_URL=${{ github.event.inputs.kernel_source_url || 'https://github.com/LineageOS/android_kernel_oneplus_sm8150' }}" >> $GITHUB_ENV
37+
echo "KERNEL_BRANCH=${{ github.event.inputs.kernel_branch || 'lineage-23.0' }}" >> $GITHUB_ENV
38+
echo "OUTPUT_ZIP_NAME=${{ github.event.inputs.output_name || 'OP7_KSN_wifi-LOS-noVendor.zip' }}" >> $GITHUB_ENV
39+
40+
- name: Configure environment variables
8341
run: |
84-
set -euo pipefail
85-
export PATH="/usr/lib/llvm-18/bin:$PATH"
86-
curl -LSs "${KSU_URL}" | bash -
42+
export ARCH=arm64
43+
export SUBARCH=arm64
44+
export PATH=$PWD/clang/bin:$PATH
45+
export CC=clang
46+
export CROSS_COMPILE=aarch64-linux-gnu-
47+
export CROSS_COMPILE_ARM32=arm-linux-gnueabi-
48+
mkdir -p out
8749
88-
- name: Write novendor.defaults
50+
- name: Write novendor.defaults and kernel config disables
8951
working-directory: kernel
9052
run: |
9153
set -euo pipefail
9254
cat > ../novendor.defaults <<'EOF'
93-
CONFIG_LOCALVERSION_AUTO=y
94-
95-
# Vendor / proprietary modules
96-
CONFIG_VENDOR_EDIT=n
97-
CONFIG_OPLUS_DEVICE_INFO=n
98-
CONFIG_OPLUS_PROJECT_INFO=n
99-
CONFIG_OPLUS_ARCH_EXTENDS=n
100-
CONFIG_OPLUS_FEATURE_CHG_BASIC=n
101-
CONFIG_OPLUS_FEATURE_SENSOR=n
102-
CONFIG_MSM_CAMERA=n
103-
CONFIG_QCOM_CAMERA=n
104-
CONFIG_SPECTRA_CAMERA=n
105-
CONFIG_SPECTRA_EEPROM=n
106-
CONFIG_DRM_MSM_OPLUS=n
107-
CONFIG_TOUCHSCREEN_OPLUS=n
108-
CONFIG_SOUND_OPLUS=n
109-
110-
# Wireless stacks (likely require blobs)
111-
CONFIG_MAC80211=n
112-
CONFIG_CFG80211=n
113-
CONFIG_WLAN=n
114-
115-
# Netfilter / xt / nf_conntrack (disable entirely)
116-
CONFIG_NETFILTER=n
117-
CONFIG_NETFILTER_XTABLES=n
118-
CONFIG_NF_CONNTRACK=n
119-
CONFIG_NF_CONNTRACK_IPV4=n
120-
CONFIG_NF_CONNTRACK_IPV6=n
121-
CONFIG_IP_NF_IPTABLES=n
122-
CONFIG_IP_NF_FILTER=n
123-
CONFIG_IP_NF_NAT=n
124-
CONFIG_IP_NF_TARGET_MASQUERADE=n
125-
CONFIG_IP6_NF_IPTABLES=n
126-
CONFIG_IP6_NF_FILTER=n
127-
CONFIG_BRIDGE_NETFILTER=n
128-
CONFIG_NF_TABLES=n
129-
CONFIG_NF_TABLES_IPV4=n
130-
CONFIG_NF_TABLES_IPV6=n
131-
132-
# Optional: reduce debug
133-
CONFIG_DEBUG_INFO=n
134-
CONFIG_DEBUG_KERNEL=n
135-
EOF
136-
137-
- name: Prepare defconfig
55+
# Force localversion predictable
56+
CONFIG_LOCALVERSION_AUTO=y
57+
58+
# Vendor / proprietary modules
59+
CONFIG_VENDOR_EDIT=n
60+
CONFIG_OPLUS_DEVICE_INFO=n
61+
CONFIG_OPLUS_PROJECT_INFO=n
62+
CONFIG_OPLUS_ARCH_EXTENDS=n
63+
CONFIG_OPLUS_FEATURE_CHG_BASIC=n
64+
CONFIG_OPLUS_FEATURE_SENSOR=n
65+
CONFIG_MSM_CAMERA=n
66+
CONFIG_QCOM_CAMERA=n
67+
CONFIG_SPECTRA_CAMERA=n
68+
CONFIG_SPECTRA_EEPROM=n
69+
CONFIG_DRM_MSM_OPLUS=n
70+
CONFIG_TOUCHSCREEN_OPLUS=n
71+
CONFIG_SOUND_OPLUS=n
72+
73+
# Wireless stacks that usually need blobs
74+
CONFIG_MAC80211=n
75+
CONFIG_CFG80211=n
76+
CONFIG_WLAN=n
77+
78+
# Netfilter / iptables / conntrack disables
79+
CONFIG_NETFILTER=n
80+
CONFIG_NETFILTER_XTABLES=n
81+
CONFIG_NF_CONNTRACK=n
82+
CONFIG_NF_CONNTRACK_IPV4=n
83+
CONFIG_NF_CONNTRACK_IPV6=n
84+
CONFIG_IP_NF_IPTABLES=n
85+
CONFIG_IP_NF_FILTER=n
86+
CONFIG_IP_NF_NAT=n
87+
CONFIG_IP_NF_TARGET_MASQUERADE=n
88+
CONFIG_IP6_NF_IPTABLES=n
89+
CONFIG_IP6_NF_FILTER=n
90+
CONFIG_BRIDGE_NETFILTER=n
91+
CONFIG_NF_TABLES=n
92+
CONFIG_NF_TABLES_IPV4=n
93+
CONFIG_NF_TABLES_IPV6=n
94+
95+
# Reduce debug for smaller kernel (optional)
96+
CONFIG_DEBUG_INFO=n
97+
CONFIG_DEBUG_KERNEL=n
98+
EOF
99+
100+
- name: Disable vendor directories
138101
working-directory: kernel
139-
env:
140-
KERNEL_DEFCONFIG: ${{ github.event.inputs.kernel_defconfig || 'vendor/sm8150_defconfig' }}
141102
run: |
142-
set -euo pipefail
143-
export PATH="/usr/lib/llvm-18/bin:$PATH"
144-
mkdir -p out
145-
make O=out ARCH=arm64 "${KERNEL_DEFCONFIG}"
146-
147-
- name: Apply novendor defaults and blackhole dirs
148-
working-directory: kernel
149-
run: |
150-
set -euo pipefail
151-
export PATH="/usr/lib/llvm-18/bin:$PATH"
152-
153-
make O=out ARCH=arm64 olddefconfig KCONFIG_ALLCONFIG=../novendor.defaults
154-
155-
# Save resulting config as reference
156-
cp out/.config arch/arm64/configs/oneplus_novendor_defconfig || true
157-
158-
# Blackhole problematic dirs (Makefiles to empty obj lists)
159-
blackhole() {
160-
d="$1"
103+
echo "🔧 Disabling vendor-related directories..."
104+
for d in \
105+
drivers/gpu/drm/msm/oplus \
106+
drivers/misc/oplus* \
107+
drivers/soc/oplus \
108+
drivers/input/oplus* \
109+
drivers/oneplus* \
110+
drivers/staging/qcacld-3.0 \
111+
drivers/media/platform/msm/camera \
112+
drivers/thermal/qcom \
113+
sound/soc/oplus* \
114+
net/netfilter \
115+
net/ipv6/netfilter \
116+
net/bridge/netfilter; do
161117
if [ -d "$d" ]; then
162-
printf '%s
163-
' '# blackholed for no-vendor build' 'obj-y :=' 'obj-m :=' > "$d/Makefile"
164-
chmod 0644 "$d/Makefile"
165-
echo "Blackholed: $d"
118+
echo "# disabled (no vendor blobs)" > "$d/Makefile"
119+
echo "obj-y :=" >> "$d/Makefile"
120+
echo "obj-m :=" >> "$d/Makefile"
166121
fi
167-
}
168-
169-
blackhole drivers/gpu/drm/msm/oplus
170-
blackhole drivers/misc/oplus
171-
for d in drivers/misc/oplus*; do [ -d "$d" ] && blackhole "$d" || true; done
172-
blackhole drivers/soc/oplus
173-
for d in drivers/input/oplus*; do [ -d "$d" ] && blackhole "$d" || true; done
174-
for d in drivers/oneplus*; do [ -d "$d" ] && blackhole "$d" || true; done
175-
blackhole drivers/staging/qcacld-3.0
176-
blackhole drivers/media/platform/msm/camera
177-
blackhole drivers/thermal/qcom
178-
for d in sound/soc/oplus*; do [ -d "$d" ] && blackhole "$d" || true; done
179-
blackhole net/netfilter
180-
blackhole net/ipv6/netfilter
181-
blackhole net/bridge/netfilter
182-
183-
# Remove vendor fragments from Kconfig includes (best effort)
184-
sed -i '/^source.*vendor/d' arch/arm64/configs/* || true
185-
sed -i '/^# Kconfig: vendor/d' arch/arm64/configs/* || true
186-
187-
# Extra guard: wipe any leftover Makefiles in netfilter families
188-
find net/netfilter net/ipv6/netfilter net/bridge/netfilter -type f -name Makefile -print0 | \
189-
xargs -0 -I{} bash -c "printf '%s
190-
' '# disabled (no vendor blobs/netfilter)' 'obj-y :=' 'obj-m :=' > '{}'"
191-
192-
- name: Build kernel
193-
working-directory: kernel
194-
env:
195-
KBUILD_OUTPUT: out
196-
run: |
197-
set -euo pipefail
198-
export PATH="/usr/lib/llvm-18/bin:$PATH"
199-
export LD_LIBRARY_PATH="/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
200-
export DTC_EXT="dtc"
201-
export HOSTCC="clang-18"
202-
export HOSTCXX="clang++-18"
203-
204-
make ${KERNEL_CMDLINE} V=1 CC="ccache clang-18" LD="ld.lld-18" AR="llvm-ar-18" NM="llvm-nm-18" OBJCOPY="llvm-objcopy-18" OBJDUMP="llvm-objdump-18" STRIP="llvm-strip-18" -j$(nproc)
205-
test -f out/arch/arm64/boot/Image
206-
cp out/arch/arm64/boot/Image ../AnyKernel3
122+
done
207123

208-
- name: Build Wi-Fi Module (qca_cld3)
209-
working-directory: kernel
124+
- name: Build Kernel
210125
run: |
211-
set -euo pipefail
212-
export PATH="/usr/lib/llvm-18/bin:$PATH"
213-
export LD_LIBRARY_PATH="/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
214-
export HOSTCC="clang-18"
215-
export HOSTCXX="clang++-18"
216-
217-
make ${KERNEL_CMDLINE} modules_prepare CC="ccache clang-18"
218-
make ${KERNEL_CMDLINE} V=1 CC="ccache clang-18" LD="ld.lld-18" AR="llvm-ar-18" NM="llvm-nm-18" \
219-
OBJCOPY="llvm-objcopy-18" OBJDUMP="llvm-objdump-18" STRIP="llvm-strip-18" \
220-
-j$(nproc) M=drivers/staging/qcacld-3.0 modules
221-
222-
sudo mkdir -p ../modules/vendor/lib/modules
223-
sudo find out/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ ;
224-
sudo chown -R "$(id -u)":"$(id -g)" ../modules
225-
226-
- name: Package Kernel and Wi-Fi Modules
126+
export ARCH=arm64
127+
export SUBARCH=arm64
128+
export PATH=$PWD/clang/bin:$PATH
129+
make O=out ARCH=arm64 $KERNEL_DEFCONFIG
130+
make O=out ARCH=arm64 -j$(nproc) \
131+
CC=clang \
132+
CROSS_COMPILE=aarch64-linux-gnu- \
133+
CROSS_COMPILE_ARM32=arm-linux-gnueabi-
134+
135+
- name: Package Image
227136
run: |
228-
set -euo pipefail
229-
cd AnyKernel3
230-
zip -r "../${OUTPUT_ZIP_NAME}.zip" *
231-
cd ../modules
232-
if ls vendor/lib/modules/*.ko >/dev/null 2>&1; then
233-
zip -r "../${OUTPUT_ZIP_NAME}-modules.zip" *
234-
else
235-
echo "No Wi-Fi modules found; skipping modules zip"
236-
fi
237-
cd ..
238-
239-
- name: Upload outputs
137+
mkdir -p artifacts
138+
cp out/arch/arm64/boot/Image.gz-dtb artifacts/ || true
139+
cp out/arch/arm64/boot/Image artifacts/ || true
140+
cd artifacts && zip -r kernel-build.zip .
141+
142+
- name: Upload Kernel Artifact
240143
uses: actions/upload-artifact@v4
241144
with:
242-
name: outputs
243-
path: |
244-
${{ env.OUTPUT_ZIP_NAME }}.zip
245-
${{ env.OUTPUT_ZIP_NAME }}-modules.zip
246-
if-no-files-found: warn
145+
name: oneplus7-kernel
146+
path: artifacts/kernel-build.zip

0 commit comments

Comments
 (0)