build.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. branch:
  9. required: true
  10. type: string
  11. android_version:
  12. required: true
  13. type: string
  14. kernel_version:
  15. required: true
  16. type: string
  17. susfs:
  18. required: true
  19. type: string
  20. bbg:
  21. required: true
  22. type: string
  23. unicodefix:
  24. required: true
  25. type: string
  26. zeromount:
  27. required: true
  28. type: string
  29. wksu:
  30. required: true
  31. type: string
  32. droidspace:
  33. required: true
  34. type: string
  35. jobs:
  36. build-samsung-gki:
  37. name: "${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  38. runs-on: ubuntu-latest
  39. strategy:
  40. fail-fast: false
  41. steps:
  42. - name: Free Disk Space
  43. if: true
  44. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  45. with:
  46. remove_android: true
  47. remove_dotnet: true
  48. remove_haskell: true
  49. remove_tool_cache: true
  50. remove_swap: true
  51. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  52. remove_packages_one_command: true
  53. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  54. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  55. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  56. testing: false
  57. - name: Set CONFIG Environment Variable
  58. run: |
  59. # Set CONFIG dynamically based on inputs values
  60. CONFIG="${{ inputs.branch }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  61. # Set CONFIG as an environment variable for future steps
  62. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  63. - name: Clone AnyKernel3 and Other Dependencies
  64. run: |
  65. ANYKERNEL_BRANCH="gki-2.0"
  66. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  67. git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  68. git clone https://github.com/WildKernels/kernel_patches.git
  69. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  70. git clone https://github.com/jimsterino98/Super-Builders.git
  71. - name: Clone Kernel Source
  72. run: |
  73. git clone --depth 1 -b ${{ inputs.branch }} --single-branch https://github.com/WildKernels/Samsung_Kernels.git $CONFIG
  74. - name: Set Path Environment Variables
  75. run: |
  76. ROOT="$GITHUB_WORKSPACE"
  77. SUSFS4KSU="$ROOT/susfs4ksu"
  78. KERNEL_PATCHES="$ROOT/kernel_patches"
  79. ANYKERNEL3="$ROOT/AnyKernel3"
  80. ZEROMOUNT="$ROOT/Super-Builders"
  81. if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
  82. COMMON="$CONFIG"
  83. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  84. COMMON="$CONFIG/kernel-6.6"
  85. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  86. COMMON="$CONFIG/kernel"
  87. else
  88. COMMON="$CONFIG/kernel_platform/common"
  89. fi
  90. if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
  91. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
  92. elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" ]]; then
  93. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnsxx_defconfig"
  94. elif [[ "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  95. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8535-m14xnsxx_defconfig"
  96. else
  97. DEFCONFIG="$COMMON/arch/arm64/configs/gki_defconfig"
  98. fi
  99. echo "ROOT=$ROOT" >> $GITHUB_ENV
  100. echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
  101. echo "KERNEL_PATCHES=$KERNEL_PATCHES" >> $GITHUB_ENV
  102. echo "ANYKERNEL3=$ANYKERNEL3" >> $GITHUB_ENV
  103. echo "COMMON=$COMMON" >> $GITHUB_ENV
  104. echo "DEFCONFIG=$DEFCONFIG" >> $GITHUB_ENV
  105. echo "ZEROMOUNT=$ZEROMOUNT" >> $GITHUB_ENV
  106. - name: Extract all tar.xz files and delete them
  107. run: |
  108. cd "$CONFIG"
  109. find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
  110. echo "Extracting $file"
  111. tar -xf "$file"
  112. rm "$file"
  113. done
  114. - name: Add Wild_KSU
  115. if: inputs.wksu == 'true'
  116. run: |
  117. cd "$COMMON"
  118. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s canary
  119. cd "$GITHUB_WORKSPACE"
  120. cat >> "$DEFCONFIG" << 'EOF'
  121. # KernelSU Configuration
  122. CONFIG_KSU=y
  123. EOF
  124. - name: Getting Wild_KSU Version
  125. if: inputs.wksu == 'true'
  126. run: |
  127. cd "$COMMON/Wild_KSU/kernel"
  128. KSU_DIR=$(pwd)
  129. KBUILD="Kbuild"
  130. BASE_VERSION=30000
  131. if [ -d "$KSU_DIR/.git" ]; then
  132. echo "✔ Git repo detected"
  133. # Unshallow if needed
  134. if [ -f "$KSU_DIR/.git/shallow" ]; then
  135. git -C "$KSU_DIR" fetch --unshallow || true
  136. fi
  137. # Get commit count
  138. KSU_GIT_VERSION=$(git -C "$KSU_DIR" rev-list --count HEAD)
  139. # Calculate version
  140. KSU_VERSION=$((BASE_VERSION + KSU_GIT_VERSION))
  141. # Get latest tag (safe)
  142. KSU_GIT_TAG=$(git -C "$KSU_DIR" describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")
  143. else
  144. echo "⚠ Not a git repo, using defaults"
  145. KSU_VERSION=33212
  146. KSU_GIT_TAG="v3.1.2"
  147. fi
  148. echo "Computed version: $KSU_VERSION"
  149. echo "Computed tag: $KSU_GIT_TAG"
  150. # Export for CI (optional)
  151. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  152. echo "KSU_VERSION_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  153. # --- Update Kbuild fallback values ---
  154. # Update numeric fallback
  155. sed -i "s/KSU_VERSION_FALLBACK := [0-9]\+/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" "$KBUILD"
  156. # Update tag fallback
  157. sed -i "s/KSU_VERSION_TAG_FALLBACK := .*/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" "$KBUILD"
  158. echo "✅ Updated fallback values in $KBUILD"
  159. - name: Apply SUSFS Patches
  160. if: inputs.susfs == 'true'
  161. run: |
  162. cd "$COMMON"
  163. # Apply compatibility fixes
  164. SUSFS_VERSION="2.1.0"
  165. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  166. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  167. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./
  168. #Prepare open.c for susfs patching
  169. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  170. #Prepare namespace.c for susfs patching
  171. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  172. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  173. /#else/,/#endif/!d
  174. /#else/d
  175. /#endif/d
  176. }
  177. }' fs/namespace.c
  178. # Apply SUSFS core patch
  179. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  180. rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  181. if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}" ]; then
  182. echo "Directory exists, applying fixes"
  183. cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/"*.patch ./
  184. # Fix SUSFS rejects
  185. for p in *.patch; do
  186. patch -p1 < "$p"
  187. rm -f "$p"
  188. done
  189. else
  190. echo "No directory found, skipping"
  191. fi
  192. cd "$GITHUB_WORKSPACE"
  193. cat >> "$DEFCONFIG" << 'EOF'
  194. # SUSFS Configuration
  195. CONFIG_KSU_SUSFS=y
  196. EOF
  197. if [[ ${{ inputs.zeromount }} == 'true' ]]; then
  198. echo "adding zeromount..."
  199. cp "$ZEROMOUNT/${{ inputs.android_version }}-${{ inputs.kernel_version }}/WildKSU/patches/60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
  200. #patch -p1 < 51_enhanced_susfs_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  201. patch -p1 < 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  202. rm -rf 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  203. if [ -f fs/proc/task_mmu.c ]; then
  204. echo "Fixing task_mmu.c..."
  205. sed -i '/pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;/a\
  206. #ifdef CONFIG_ZEROMOUNT\
  207. \tzeromount_spoof_mmap_metadata(inode, \&dev, \&ino);\
  208. #endif' fs/proc/task_mmu.c
  209. fi
  210. if [ -f fs/stat.c.rej ]; then
  211. echo "fixing stat.c."
  212. if ! grep -q 'zeromount_stat_hook(dfd, filename, stat, request_mask, flags)' fs/stat.c; then
  213. perl -0pi -e 's@(static int vfs_statx\(.*?\)\s*\{.*?orig_flow:\n#endif\n)@$1\n#ifdef CONFIG_ZEROMOUNT\n\tif (filename) {\n\t\tint zm_ret = zeromount_stat_hook(dfd, filename, stat, request_mask, flags);\n\t\tif (zm_ret != -ENOENT)\n\t\t\treturn zm_ret;\n\t}\n#endif\n\n@s' fs/stat.c
  214. fi
  215. fi
  216. if [ -f fs/Kconfig.rej ]; then
  217. echo "Applying Kconfig zeromount fix..."
  218. if ! grep -q '^config ZEROMOUNT$' fs/Kconfig; then
  219. perl -0pi -e 's@(config IO_WQ\n\tbool\n)@\1\nconfig ZEROMOUNT\n\tbool "ZeroMount Path Redirection Subsystem"\n\tdefault y\n\thelp\n\t ZeroMount allows path redirection and virtual file injection\n\t without mounting filesystems. Useful for systemless modifications.\n\n@' fs/Kconfig
  220. fi
  221. fi
  222. #patch -p1 < 70_ksu_safety-wksu-${{ inputs.kernel_version }}.patch || true
  223. cd "$GITHUB_WORKSPACE"
  224. cat >> "$DEFCONFIG" << 'EOF'
  225. # Zeromount Configuration
  226. CONFIG_ZEROMOUNT=y
  227. EOF
  228. fi
  229. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  230. if: ${{ inputs.kernel_version == '6.6' }}
  231. run: |
  232. cd "$COMMON"
  233. SYMBOL_LIST=android/abi_gki_aarch64_galaxy
  234. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  235. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  236. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  237. if [[ "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  238. echo "snd_soc_find_dai" >> $SYMBOL_LIST
  239. sed -i '
  240. /"kernel_aarch64": {/,/},/ {
  241. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  242. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  243. }
  244. /"kernel_aarch64_16k": {/,/},/ {
  245. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  246. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  247. }
  248. ' BUILD.bazel
  249. fi
  250. cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
  251. echo "obj-y += min_kdp.o" >> drivers/Makefile
  252. - name: Add BBG
  253. if: inputs.bbg == 'true'
  254. run: |
  255. cd "$COMMON"
  256. echo "Adding BBG..."
  257. curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  258. echo "CONFIG_BBG=y" >> arch/arm64/configs/gki_defconfig
  259. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
  260. if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/bbg" ]; then
  261. echo "Directory exists, adding bbg in configLSM"
  262. cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/bbg/"* ./
  263. # patch for adding bbg in configLSM for some devices
  264. for p in *.patch; do
  265. patch -p1 < "$p"
  266. rm -f "$p"
  267. done
  268. else
  269. echo "BBG already enabled"
  270. fi
  271. # if grep -qxF $'\t\tconst char* symlink_target_link = inode->i_op->get_link(dentry, inode, NULL);' ./Baseband-guard/baseband_guard.c; then
  272. # echo "Applying BBG get_link fix"
  273. # patch -p1 --forward < "$KERNEL_PATCHES/experimental/bbg/bbg_fix_get_link.patch"
  274. # fi
  275. - name: Add unicodefix
  276. if: inputs.unicodefix == 'true'
  277. run: |
  278. cd "$COMMON"
  279. echo "detected kernel version: ${{ inputs.kernel_version }}"
  280. if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
  281. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
  282. patch -p1 < unicode_bypass_fix_6.1+.patch
  283. else
  284. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
  285. patch -p1 < unicode_bypass_fix_6.1-.patch
  286. fi
  287. - name: Add droidspace support
  288. if: inputs.droidspace == 'true'
  289. run: |
  290. cd "$COMMON"
  291. # ABI: use ABI padding for SYSVIPC This commit allows us to enable CONFIG_SYSVIPC in defconfig without breaking kernel ABI
  292. curl -Ls https://github.com/nullptr-t-oss/android_kernel_common_oneplus_sm8550/commit/769a5cfdc17b98d8e0bd491d45f5651180e42196.patch | patch -p1 --forward
  293. cat >> "$DEFCONFIG" <<EOF
  294. CONFIG_SYSVIPC=y
  295. CONFIG_DEVTMPFS=y
  296. CONFIG_PID_NS=y
  297. CONFIG_POSIX_MQUEUE=y
  298. EOF
  299. - name: Set Kernel Configuration Variables
  300. if: inputs.wksu == 'true'
  301. run: |
  302. echo "Initializing kernel configuration..."
  303. cat >> "$DEFCONFIG" << 'EOF'
  304. # Mountify Support
  305. CONFIG_OVERLAY_FS=y
  306. CONFIG_TMPFS_XATTR=y
  307. CONFIG_TMPFS_POSIX_ACL=y
  308. # increase log buffer size to show bbg version in wksu homepage
  309. CONFIG_LOG_BUF_SHIFT=20
  310. EOF
  311. if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  312. echo "nothing needs to be done"
  313. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  314. cat >> "$DEFCONFIG" << 'EOF'
  315. # nuke root protection
  316. CONFIG_UH=n
  317. CONFIG_UH_RKP=n
  318. CONFIG_UH_LKMAUTH=n
  319. CONFIG_UH_LKM_BLOCK=n
  320. CONFIG_RKP_CFP_JOPP=n
  321. CONFIG_RKP_CFP=n
  322. CONFIG_SECURITY_DEFEX=n
  323. CONFIG_PROCA=n
  324. CONFIG_FIVE=n
  325. CONFIG_RKP=n
  326. CONFIG_KDP_NS=n
  327. CONFIG_KDP=n
  328. #Force Load Kernel Modules
  329. CONFIG_MODULES=y
  330. CONFIG_MODULE_FORCE_LOAD=y
  331. CONFIG_MODULE_UNLOAD=y
  332. CONFIG_MODULE_FORCE_UNLOAD=y
  333. CONFIG_MODVERSIONS=y
  334. CONFIG_MODULE_SRCVERSION_ALL=n
  335. CONFIG_MODULE_SIG=n
  336. CONFIG_MODULE_COMPRESS=n
  337. CONFIG_TRIM_UNUSED_KSYMS=n
  338. EOF
  339. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  340. cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
  341. # nuke root protection
  342. CONFIG_UH=n
  343. CONFIG_UH_RKP=n
  344. CONFIG_UH_LKMAUTH=n
  345. CONFIG_UH_LKM_BLOCK=n
  346. CONFIG_RKP_CFP_JOPP=n
  347. CONFIG_RKP_CFP=n
  348. CONFIG_SECURITY_DEFEX=n
  349. CONFIG_PROCA=n
  350. CONFIG_FIVE=n
  351. CONFIG_RKP=n
  352. CONFIG_KDP_NS=n
  353. CONFIG_KDP=n
  354. EOF
  355. else
  356. cat >> "$DEFCONFIG" << 'EOF'
  357. # nuke root protection
  358. CONFIG_UH=n
  359. CONFIG_UH_RKP=n
  360. CONFIG_UH_LKMAUTH=n
  361. CONFIG_UH_LKM_BLOCK=n
  362. CONFIG_RKP_CFP_JOPP=n
  363. CONFIG_RKP_CFP=n
  364. CONFIG_SECURITY_DEFEX=n
  365. CONFIG_PROCA=n
  366. CONFIG_FIVE=n
  367. CONFIG_RKP=n
  368. CONFIG_KDP_NS=n
  369. CONFIG_KDP=n
  370. EOF
  371. fi
  372. cd "$COMMON"
  373. # Remove check_defconfig
  374. sed -i 's/check_defconfig//' ./build.config.gki
  375. - name: Change Kernel Name and remove protected exports
  376. run: |
  377. cd "$COMMON"
  378. if [[ "${{ inputs.wksu }}" == "true" ]]; then
  379. #Add Wild to Kernel Version
  380. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
  381. #Set Kernel Timestamp
  382. perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sun Apr 20 04:20:00 UTC 2025"}' ./scripts/mkcompile_h
  383. fi
  384. #Remove Abi Exports and Error
  385. rm -rf ./android/abi_gki_protected_exports_*
  386. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel
  387. - name: Clean Dirty Flags
  388. run: |
  389. # remove dirty
  390. sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"
  391. - name: Set file name
  392. if: inputs.wksu == 'true'
  393. run: |
  394. ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  395. # This gives: KSU33208-branch-xxx-xxx
  396. FILE_NAME="KSU${KSU_VERSION}-${ARTIFACT_BASE}"
  397. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  398. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  399. echo "✅ Final artifact name: $FILE_NAME"
  400. - name: Build
  401. run : |
  402. set -e
  403. set -x
  404. cd "$CONFIG"
  405. echo "Building the kernel..."
  406. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  407. chmod +x build_kernel_GKI.sh
  408. ./build_kernel_GKI.sh || true
  409. elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" ]]; then
  410. chmod +x build_kernel_GKI.sh
  411. LTO=thin ./build_kernel_GKI.sh || true
  412. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
  413. sudo apt update
  414. sudo apt-get install -y libyaml-dev
  415. LTO=thin ./build_kernel.sh || true
  416. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  417. chmod +x build_script.sh
  418. touch ./kernel-6.6/abi_symbollist.raw
  419. touch ./kernel-6.6/abi_symbollist
  420. ./build_script.sh || true
  421. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  422. tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
  423. else
  424. #temporarily using this until i can figure out the other phones build script issues
  425. cd kernel_platform
  426. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  427. fi
  428. - name: Prepare AnyKernel3
  429. run: |
  430. cd "$CONFIG"
  431. # Copy Image from normal build locations
  432. #if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  433. # cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  434. #elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  435. # cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  436. #else
  437. # echo "Error: Image file not found in any expected location"
  438. # exit 1
  439. #fi
  440. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  441. cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
  442. elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
  443. cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
  444. elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  445. cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
  446. elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
  447. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
  448. elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" ]]; then
  449. cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
  450. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
  451. cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
  452. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  453. cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
  454. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  455. cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
  456. elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
  457. cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
  458. else
  459. echo "Error: Image file not found in any expected location"
  460. exit 1
  461. fi
  462. - name: Upload AnyKernel3 Artifacts
  463. id: upload_ak3
  464. uses: actions/upload-artifact@v6
  465. with:
  466. name: ${{ env.FILE_NAME }}-AnyKernel3
  467. path: |
  468. ./AnyKernel3/**
  469. compression-level: 9
  470. - name: Scan and collect patch rejects
  471. if: ${{ always() }}
  472. run: |
  473. set -e
  474. CONFIG_DIR="$CONFIG"
  475. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  476. mkdir -p "$REJECTS_DIR"
  477. # Find all .rej files under the configuration directory
  478. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  479. REJ_COUNT=${#REJS[@]}
  480. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  481. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  482. if [ "$REJ_COUNT" -gt 0 ]; then
  483. for REJ in "${REJS[@]}"; do
  484. # Relative path from $CONFIG
  485. REL="${REJ#"$CONFIG_DIR"/}"
  486. DEST="$REJECTS_DIR/$REL"
  487. mkdir -p "$(dirname "$DEST")"
  488. cp "$REJ" "$DEST"
  489. # Copy the associated original file alongside the .rej
  490. ORIG="${REJ%.rej}"
  491. if [ -f "$ORIG" ]; then
  492. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  493. mkdir -p "$(dirname "$ORIG_DEST")"
  494. cp "$ORIG" "$ORIG_DEST"
  495. fi
  496. echo "$REL" >> "$REJECTS_DIR/index.txt"
  497. done
  498. fi
  499. - name: Generate Build Summary
  500. if: ${{ always() }}
  501. run: |
  502. # Create build summary file for inclusion in Misc artifact
  503. echo "# Kernel Build Summary" > build_summary.md
  504. # Add build variant header
  505. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  506. # Add build info
  507. echo "## Build Information" >> build_summary.md
  508. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  509. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  510. echo "- **BBG**: Installed" >> build_summary.md
  511. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  512. echo "" >> build_summary.md
  513. # Get Wild_KSU commit
  514. if [ -d "$CONFIG/Wild_KSU" ]; then
  515. cd "$CONFIG/Wild_KSU"
  516. WKSU_COMMIT=$(git rev-parse HEAD)
  517. WKSU_URL="https://github.com/WildKernels/Wild_KSU/commit/$WKSU_COMMIT"
  518. echo "- **Wild_KSU**: [$WKSU_COMMIT]($WKSU_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  519. cd "$GITHUB_WORKSPACE"
  520. else
  521. echo "- **Wild_KSU**: not present" >> build_summary.md
  522. fi
  523. # Get Baseband-guard commit
  524. if [ -d "$CONFIG/Baseband-guard" ]; then
  525. cd "$CONFIG/Baseband-guard"
  526. BBG_COMMIT=$(git rev-parse HEAD)
  527. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  528. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  529. cd "$GITHUB_WORKSPACE"
  530. else
  531. echo "- **Baseband-guard**: not present" >> build_summary.md
  532. fi
  533. # Get SUSFS4KSU commit
  534. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  535. cd "$GITHUB_WORKSPACE/susfs4ksu"
  536. SUSFS_COMMIT=$(git rev-parse HEAD)
  537. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  538. echo "- **SUSFS4KSU (v2.1.0)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  539. cd "$GITHUB_WORKSPACE"
  540. else
  541. echo "- **SUSFS4KSU (v2.1.0)**: not present" >> build_summary.md
  542. fi
  543. echo "" >> build_summary.md
  544. # Add artifact summary with presence verification
  545. echo "## Build Artifacts" >> build_summary.md
  546. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  547. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  548. AK3_STATUS="✅"
  549. else
  550. AK3_STATUS="❌"
  551. fi
  552. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  553. echo "### Misc (uploaded files)" >> build_summary.md
  554. FILES_PRESENT=0
  555. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  556. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  557. done
  558. if [ "$FILES_PRESENT" -gt 0 ]; then
  559. MISC_STATUS="✅"
  560. else
  561. MISC_STATUS="❌"
  562. fi
  563. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  564. if [ "$MISC_STATUS" = "✅" ]; then
  565. echo " Included:" >> build_summary.md
  566. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  567. if [ -f "$f" ]; then
  568. echo " - $f" >> build_summary.md
  569. fi
  570. done
  571. fi
  572. echo "### Diagnostics" >> build_summary.md
  573. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  574. if [ -f patch-rejects/index.txt ]; then
  575. if [ -s patch-rejects/index.txt ]; then
  576. echo " Rejected files:" >> build_summary.md
  577. while IFS= read -r line; do
  578. echo " - $line" >> build_summary.md
  579. done < patch-rejects/index.txt
  580. else
  581. echo " Rejected file list is empty." >> build_summary.md
  582. fi
  583. else
  584. echo " No rejected patches found." >> build_summary.md
  585. fi