Skip to content

Commit f3b036c

Browse files
authored
Update Novendor.yml
1 parent 5d0cd76 commit f3b036c

File tree

1 file changed

+174
-70
lines changed

1 file changed

+174
-70
lines changed

.github/workflows/Novendor.yml

Lines changed: 174 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,87 @@ name: Build OnePlus 7 Kernel (No Vendor Blobs)
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
- lineage-21
9-
- android-16
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 patch/setup script URL (leave empty to skip)"
28+
required: false
29+
default: ""
1030

1131
jobs:
1232
build:
1333
runs-on: ubuntu-22.04
1434

35+
env:
36+
# keep the toolchain path set later
37+
OUTDIR: out
38+
CLANG_DIR: clang
39+
1540
steps:
16-
- name: Checkout source
41+
- name: Checkout this workflow repository
1742
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
1845

19-
- name: Setup build environment
46+
- name: Install system dependencies (tar early so checkout won't fail)
2047
run: |
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
25-
26-
- name: Download prebuilt Clang toolchain
48+
sudo apt-get update -y
49+
sudo apt-get install -y \
50+
git wget curl tar gzip xz-utils unzip zip \
51+
build-essential bc bison flex libssl-dev libncurses-dev \
52+
clang-18 lld-18 llvm-18 gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu \
53+
ccache
54+
55+
- name: Set inputs into environment (no YAML expressions later)
2756
run: |
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."
32-
33-
- name: Set derived env / defaults
57+
# Write inputs directly to GITHUB_ENV; we'll apply shell defaults later
58+
echo "KERNEL_SOURCE_URL=${{ github.event.inputs.kernel_source_url }}" >> $GITHUB_ENV
59+
echo "KERNEL_BRANCH=${{ github.event.inputs.kernel_branch }}" >> $GITHUB_ENV
60+
echo "KERNEL_DEFCONFIG=${{ github.event.inputs.kernel_defconfig }}" >> $GITHUB_ENV
61+
echo "OUTPUT_ZIP_NAME=${{ github.event.inputs.output_name }}" >> $GITHUB_ENV
62+
echo "APPLY_KERNELSU=${{ github.event.inputs.apply_kernelsu }}" >> $GITHUB_ENV
63+
echo "KERNELSU_PATCH_URL=${{ github.event.inputs.kernelsu_patch_url }}" >> $GITHUB_ENV
64+
65+
- name: Download Clang toolchain (if system clang-18 missing)
3466
run: |
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
67+
if ! command -v clang-18 >/dev/null 2>&1; then
68+
mkdir -p ${CLANG_DIR}
69+
CLANG_TGZ="clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
70+
wget -q "https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/${CLANG_TGZ}"
71+
tar -xf ${CLANG_TGZ} -C ${CLANG_DIR} --strip-components=1
72+
fi
73+
echo "${PWD}/${CLANG_DIR}/bin" >> $GITHUB_PATH
74+
75+
- name: Clone kernel source
4176
run: |
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
49-
50-
- name: Write novendor.defaults and kernel config disables
77+
# apply shell-level defaults (if user left inputs empty)
78+
: "${KERNEL_SOURCE_URL:=https://github.com/LineageOS/android_kernel_oneplus_sm8150}"
79+
: "${KERNEL_BRANCH:=lineage-23.0}"
80+
echo "Cloning kernel from $KERNEL_SOURCE_URL (branch $KERNEL_BRANCH)"
81+
git clone --depth=1 --branch "$KERNEL_BRANCH" "$KERNEL_SOURCE_URL" kernel
82+
cd kernel
83+
git submodule update --init --recursive || true
84+
85+
- name: Create novendor.defaults (safe heredoc)
5186
working-directory: kernel
5287
run: |
5388
set -euo pipefail
@@ -97,50 +132,119 @@ CONFIG_DEBUG_INFO=n
97132
CONFIG_DEBUG_KERNEL=n
98133
EOF
99134

100-
- name: Disable vendor directories
135+
- name: Prepare kernel output directory and seed defconfig
101136
working-directory: kernel
102137
run: |
103-
echo "🔧 Disabling vendor-related directories..."
138+
set -euo pipefail
139+
export PATH="${PWD}/../${CLANG_DIR}/bin:$PATH"
140+
mkdir -p ../${OUTDIR}
141+
# Use provided defconfig, or fallback to vendor/sm8150_defconfig if empty
142+
if [ -z "${KERNEL_DEFCONFIG}" ]; then
143+
KCONF="vendor/sm8150_defconfig"
144+
else
145+
KCONF="${KERNEL_DEFCONFIG}"
146+
fi
147+
echo "Using defconfig: $KCONF"
148+
make O=../${OUTDIR} ARCH=arm64 "$KCONF"
149+
150+
- name: Merge novendor.defaults and save cleaned defconfig
151+
working-directory: kernel
152+
run: |
153+
set -euo pipefail
154+
make O=../${OUTDIR} ARCH=arm64 olddefconfig KCONFIG_ALLCONFIG=../novendor.defaults
155+
cp ../${OUTDIR}/.config arch/arm64/configs/oneplus_novendor_defconfig || true
156+
157+
- name: Blackhole vendor-heavy directories
158+
working-directory: kernel
159+
run: |
160+
set -euo pipefail
104161
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
162+
drivers/gpu/drm/msm/oplus \
163+
drivers/misc/oplus* \
164+
drivers/soc/oplus \
165+
drivers/input/oplus* \
166+
drivers/oneplus* \
167+
drivers/staging/qcacld-3.0 \
168+
drivers/media/platform/msm/camera \
169+
drivers/thermal/qcom \
170+
sound/soc/oplus* \
171+
net/netfilter \
172+
net/ipv6/netfilter \
173+
net/bridge/netfilter; do
117174
if [ -d "$d" ]; then
118-
echo "# disabled (no vendor blobs)" > "$d/Makefile"
119-
echo "obj-y :=" >> "$d/Makefile"
120-
echo "obj-m :=" >> "$d/Makefile"
175+
echo -e "# blackholed for no-vendor build\nobj-y :=\nobj-m :=" > "$d/Makefile"
176+
chmod 644 "$d/Makefile"
177+
echo "Blackholed: $d"
121178
fi
122179
done
123180
124-
- name: Build Kernel
181+
- name: (optional) Apply KernelSU patch
182+
if: env.APPLY_KERNELSU == 'true'
183+
working-directory: kernel
125184
run: |
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
185+
set -euo pipefail
186+
if [ -n "${KERNELSU_PATCH_URL}" ]; then
187+
echo "Applying KernelSU from ${KERNELSU_PATCH_URL}"
188+
curl -LSs "${KERNELSU_PATCH_URL}" | bash -
189+
else
190+
echo "APPLY_KERNELSU was true but no KERNELSU_PATCH_URL provided - skipping"
191+
fi
192+
193+
- name: Build kernel (no-vendor)
194+
working-directory: kernel
195+
env:
196+
KBUILD_OUTPUT: ../${OUTDIR}
136197
run: |
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
198+
set -euo pipefail
199+
export PATH="${PWD}/../${CLANG_DIR}/bin:$PATH"
200+
export CC="clang-18"
201+
export LD="ld.lld-18"
202+
make O=../${OUTDIR} ARCH=arm64 oneplus_novendor_defconfig || true
203+
# fallback: if that custom defconfig isn't present, just use the earlier .config
204+
make O=../${OUTDIR} ARCH=arm64 -j$(nproc) CC="ccache clang-18" LD="ld.lld-18"
205+
206+
- name: Verify and copy kernel image to AnyKernel3
207+
working-directory: kernel
208+
run: |
209+
set -euo pipefail
210+
if [ -f ../${OUTDIR}/arch/arm64/boot/Image.gz-dtb ]; then
211+
echo "Found Image.gz-dtb"
212+
cp ../${OUTDIR}/arch/arm64/boot/Image.gz-dtb ../AnyKernel3/zImage
213+
elif [ -f ../${OUTDIR}/arch/arm64/boot/Image ]; then
214+
echo "Found Image"
215+
cp ../${OUTDIR}/arch/arm64/boot/Image ../AnyKernel3/zImage
216+
else
217+
echo "Kernel image not found in ../${OUTDIR}/arch/arm64/boot"
218+
ls -la ../${OUTDIR}/arch/arm64/boot || true
219+
exit 1
220+
fi
221+
222+
- name: Prepare AnyKernel3 and package zip
223+
run: |
224+
git clone --depth=1 https://github.com/khalidaboelmagd/AnyKernel3 || true
225+
rm -rf AnyKernel3/.git || true
226+
cd AnyKernel3 || exit 1
227+
sed -i 's|device.name1=.*|device.name1=guacamole|' anykernel.sh || true
228+
sed -i 's|device.name2=.*|device.name2=guacamoleb|' anykernel.sh || true
229+
sed -i 's|do.devicecheck=1|do.devicecheck=0|' anykernel.sh || true
230+
zip -r9 ../${OUTPUT_ZIP_NAME}.zip ./*
231+
232+
- name: Package modules (if built)
233+
working-directory: kernel
234+
run: |
235+
set -euo pipefail
236+
mkdir -p ../modules/vendor/lib/modules || true
237+
if [ -d ../${OUTDIR}/drivers/staging/qcacld-3.0 ]; then
238+
find ../${OUTDIR}/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ \; || true
239+
fi
240+
cd ../modules || exit 0
241+
zip -r ../${OUTPUT_ZIP_NAME}-modules.zip . || true
242+
243+
- name: Upload zips
143244
uses: actions/upload-artifact@v4
144245
with:
145-
name: oneplus7-kernel
146-
path: artifacts/kernel-build.zip
246+
name: outputs
247+
path: |
248+
${OUTPUT_ZIP_NAME}.zip
249+
${OUTPUT_ZIP_NAME}-modules.zip
250+
if-no-files-found: error

0 commit comments

Comments
 (0)