build.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. bbrv3:
  24. required: true
  25. type: string
  26. unicodefix:
  27. required: true
  28. type: string
  29. optimizations:
  30. required: true
  31. type: string
  32. zeromount:
  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" ]]; 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" ]]; then
  91. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
  92. elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" ]]; 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. run: |
  116. cd "$COMMON"
  117. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s canary
  118. cd "$GITHUB_WORKSPACE"
  119. cat >> "$DEFCONFIG" << 'EOF'
  120. # KernelSU Configuration
  121. CONFIG_KSU=y
  122. EOF
  123. - name: Getting Wild_KSU Version
  124. run: |
  125. cd "$COMMON/Wild_KSU/kernel"
  126. KSU_DIR=$(pwd)
  127. KBUILD="Kbuild"
  128. BASE_VERSION=30000
  129. if [ -d "$KSU_DIR/.git" ]; then
  130. echo "✔ Git repo detected"
  131. # Unshallow if needed
  132. if [ -f "$KSU_DIR/.git/shallow" ]; then
  133. git -C "$KSU_DIR" fetch --unshallow || true
  134. fi
  135. # Get commit count
  136. KSU_GIT_VERSION=$(git -C "$KSU_DIR" rev-list --count HEAD)
  137. # Calculate version
  138. KSU_VERSION=$((BASE_VERSION + KSU_GIT_VERSION))
  139. # Get latest tag (safe)
  140. KSU_GIT_TAG=$(git -C "$KSU_DIR" describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")
  141. else
  142. echo "⚠ Not a git repo, using defaults"
  143. KSU_VERSION=33212
  144. KSU_GIT_TAG="v3.1.2"
  145. fi
  146. echo "Computed version: $KSU_VERSION"
  147. echo "Computed tag: $KSU_GIT_TAG"
  148. # Export for CI (optional)
  149. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  150. echo "KSU_VERSION_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  151. # --- Update Kbuild fallback values ---
  152. # Update numeric fallback
  153. sed -i "s/KSU_VERSION_FALLBACK := [0-9]\+/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" "$KBUILD"
  154. # Update tag fallback
  155. sed -i "s/KSU_VERSION_TAG_FALLBACK := .*/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" "$KBUILD"
  156. echo "✅ Updated fallback values in $KBUILD"
  157. - name: Apply SUSFS Patches
  158. if: inputs.susfs == 'true' && inputs.zeromount == 'false'
  159. run: |
  160. cd "$COMMON"
  161. # Apply compatibility fixes
  162. SUSFS_VERSION="2.1.0"
  163. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  164. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  165. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./
  166. #Prepare open.c for susfs patching
  167. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  168. #Prepare namespace.c for susfs patching
  169. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  170. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  171. /#else/,/#endif/!d
  172. /#else/d
  173. /#endif/d
  174. }
  175. }' fs/namespace.c
  176. # Apply SUSFS core patch
  177. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  178. rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  179. if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}" ]; then
  180. echo "Directory exists, applying fixes"
  181. cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/"*.patch ./
  182. # Fix SUSFS rejects
  183. for p in *.patch; do
  184. patch -p1 < "$p"
  185. rm -f "$p"
  186. done
  187. else
  188. echo "No directory found, skipping"
  189. fi
  190. cd "$GITHUB_WORKSPACE"
  191. cat >> "$DEFCONFIG" << 'EOF'
  192. # SUSFS Configuration
  193. CONFIG_KSU_SUSFS=y
  194. EOF
  195. - name: Apply zeromount Patches
  196. if: inputs.susfs == 'false' && inputs.zeromount == 'true'
  197. run: |
  198. cd "$COMMON"
  199. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  200. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  201. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./
  202. #Prepare open.c for susfs patching
  203. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  204. #Prepare namespace.c for susfs patching
  205. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  206. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  207. /#else/,/#endif/!d
  208. /#else/d
  209. /#endif/d
  210. }
  211. }' fs/namespace.c
  212. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  213. rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  214. if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}" ]; then
  215. echo "Directory exists, applying fixes"
  216. cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/"*.patch ./
  217. # Fix SUSFS rejects
  218. for p in *.patch; do
  219. patch -p1 < "$p"
  220. rm -f "$p"
  221. done
  222. else
  223. echo "No directory found, skipping"
  224. fi
  225. cp "$ZEROMOUNT/${{ inputs.android_version }}-${{ inputs.kernel_version }}/WildKSU/patches/60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
  226. #patch -p1 < 51_enhanced_susfs_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  227. patch -p1 < 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  228. rm -rf 60_zeromount-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  229. #patch -p1 < 70_ksu_safety-wksu-${{ inputs.kernel_version }}.patch || true
  230. cd "$GITHUB_WORKSPACE"
  231. cat >> "$DEFCONFIG" << 'EOF'
  232. # SUSFS Configuration
  233. CONFIG_KSU_SUSFS=y
  234. CONFIG_ZEROMOUNT=y
  235. EOF
  236. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  237. if: ${{ inputs.kernel_version == '6.6' }}
  238. run: |
  239. cd "$COMMON"
  240. SYMBOL_LIST=android/abi_gki_aarch64_galaxy
  241. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  242. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  243. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  244. if [[ "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  245. echo "snd_soc_find_dai" >> $SYMBOL_LIST
  246. sed -i '
  247. /"kernel_aarch64": {/,/},/ {
  248. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  249. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  250. }
  251. /"kernel_aarch64_16k": {/,/},/ {
  252. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  253. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  254. }
  255. ' BUILD.bazel
  256. fi
  257. cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
  258. echo "obj-y += min_kdp.o" >> drivers/Makefile
  259. - name: Add BBG
  260. if: inputs.bbg == 'true'
  261. run: |
  262. cd "$COMMON"
  263. echo "Adding BBG..."
  264. curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  265. echo "CONFIG_BBG=y" >> arch/arm64/configs/gki_defconfig
  266. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
  267. if [ -d "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/bbg" ]; then
  268. echo "Directory exists, adding bbg in configLSM"
  269. cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/bbg/"* ./
  270. # patch for adding bbg in configLSM for some devices
  271. for p in *.patch; do
  272. patch -p1 < "$p"
  273. rm -f "$p"
  274. done
  275. else
  276. echo "BBG already enabled"
  277. fi
  278. # if grep -qxF $'\t\tconst char* symlink_target_link = inode->i_op->get_link(dentry, inode, NULL);' ./Baseband-guard/baseband_guard.c; then
  279. # echo "Applying BBG get_link fix"
  280. # patch -p1 --forward < "$KERNEL_PATCHES/experimental/bbg/bbg_fix_get_link.patch"
  281. # fi
  282. - name: Add unicodefix
  283. if: inputs.unicodefix == 'true'
  284. run: |
  285. cd "$COMMON"
  286. echo "detected kernel version: ${{ inputs.kernel_version }}"
  287. if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
  288. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
  289. patch -p1 < unicode_bypass_fix_6.1+.patch
  290. else
  291. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
  292. patch -p1 < unicode_bypass_fix_6.1-.patch
  293. fi
  294. - name: Add BBRv3
  295. if: inputs.bbrv3 == 'true'
  296. run: |
  297. cd "$COMMON"
  298. echo "applying BBRv3"
  299. curl -L -s https://raw.githubusercontent.com/ahmed-alnassif/GKI-Duchamp/refs/heads/dev/kernel-patches/bbrv3/bbrv3.patch | patch -p1 --forward
  300. cd "$GITHUB_WORKSPACE"
  301. cat >> "$DEFCONFIG" << 'EOF'
  302. # Networking extras
  303. CONFIG_IP_NF_TARGET_TTL=y
  304. CONFIG_NET_SCH_FQ=y
  305. CONFIG_TCP_CONG_ADVANCED=y
  306. CONFIG_DEFAULT_BBR=y
  307. CONFIG_TCP_CONG_BBR=y
  308. CONFIG_TCP_CONG_WESTWOOD=y
  309. CONFIG_IP6_NF_TARGET_HL=y
  310. CONFIG_IP6_NF_MATCH_HL=y
  311. EOF
  312. - name: Add Optimizations
  313. if: inputs.optimizations == 'true'
  314. run: |
  315. echo "Adding Optimizations..."
  316. cat >> "$DEFCONFIG" << 'EOF'
  317. # Better I/O & filesystem performance
  318. CONFIG_SWAP=y
  319. CONFIG_BLK_DEV_ZRAM=y
  320. CONFIG_ZRAM_DEF_COMP_LZ4=y
  321. CONFIG_ZRAM_WRITEBACK=y
  322. CONFIG_ZRAM_MEMORY_TRACKING=y
  323. # Modern I/O scheduler
  324. CONFIG_MQ_IOSCHED_DEADLINE=y
  325. CONFIG_DEFAULT_DEADLINE=y
  326. # F2FS optimizations
  327. CONFIG_F2FS_FS=y
  328. CONFIG_F2FS_FS_XATTR=y
  329. CONFIG_F2FS_FS_POSIX_ACL=y
  330. CONFIG_F2FS_FS_COMPRESSION=y
  331. # Memory management improvements
  332. CONFIG_LRU_GEN=y
  333. CONFIG_LRU_GEN_ENABLED=y
  334. EOF
  335. - name: Set Kernel Configuration Variables
  336. run: |
  337. echo "Initializing kernel configuration..."
  338. cat >> "$DEFCONFIG" << 'EOF'
  339. # Mountify Support
  340. CONFIG_OVERLAY_FS=y
  341. CONFIG_TMPFS_XATTR=y
  342. CONFIG_TMPFS_POSIX_ACL=y
  343. # increase log buffer size to show bbg version in wksu homepage
  344. CONFIG_LOG_BUF_SHIFT=20
  345. EOF
  346. if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  347. echo "nothing needs to be done"
  348. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  349. cat >> "$DEFCONFIG" << 'EOF'
  350. # nuke root protection
  351. CONFIG_UH=n
  352. CONFIG_UH_RKP=n
  353. CONFIG_UH_LKMAUTH=n
  354. CONFIG_UH_LKM_BLOCK=n
  355. CONFIG_RKP_CFP_JOPP=n
  356. CONFIG_RKP_CFP=n
  357. CONFIG_SECURITY_DEFEX=n
  358. CONFIG_PROCA=n
  359. CONFIG_FIVE=n
  360. CONFIG_RKP=n
  361. CONFIG_KDP_NS=n
  362. CONFIG_KDP=n
  363. #Force Load Kernel Modules
  364. CONFIG_MODULES=y
  365. CONFIG_MODULE_FORCE_LOAD=y
  366. CONFIG_MODULE_UNLOAD=y
  367. CONFIG_MODULE_FORCE_UNLOAD=y
  368. CONFIG_MODVERSIONS=y
  369. CONFIG_MODULE_SRCVERSION_ALL=n
  370. CONFIG_MODULE_SIG=n
  371. CONFIG_MODULE_COMPRESS=n
  372. CONFIG_TRIM_UNUSED_KSYMS=n
  373. EOF
  374. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  375. cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
  376. # nuke root protection
  377. CONFIG_UH=n
  378. CONFIG_UH_RKP=n
  379. CONFIG_UH_LKMAUTH=n
  380. CONFIG_UH_LKM_BLOCK=n
  381. CONFIG_RKP_CFP_JOPP=n
  382. CONFIG_RKP_CFP=n
  383. CONFIG_SECURITY_DEFEX=n
  384. CONFIG_PROCA=n
  385. CONFIG_FIVE=n
  386. CONFIG_RKP=n
  387. CONFIG_KDP_NS=n
  388. CONFIG_KDP=n
  389. EOF
  390. else
  391. cat >> "$DEFCONFIG" << 'EOF'
  392. # nuke root protection
  393. CONFIG_UH=n
  394. CONFIG_UH_RKP=n
  395. CONFIG_UH_LKMAUTH=n
  396. CONFIG_UH_LKM_BLOCK=n
  397. CONFIG_RKP_CFP_JOPP=n
  398. CONFIG_RKP_CFP=n
  399. CONFIG_SECURITY_DEFEX=n
  400. CONFIG_PROCA=n
  401. CONFIG_FIVE=n
  402. CONFIG_RKP=n
  403. CONFIG_KDP_NS=n
  404. CONFIG_KDP=n
  405. EOF
  406. fi
  407. cd "$COMMON"
  408. # Remove check_defconfig
  409. sed -i 's/check_defconfig//' ./build.config.gki
  410. - name: Change Kernel Name
  411. run: |
  412. cd "$COMMON"
  413. #Add Wild to Kernel Version
  414. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
  415. #Set Kernel Timestamp
  416. 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
  417. #Remove Abi Exports and Error
  418. rm -rf ./android/abi_gki_protected_exports_*
  419. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel
  420. - name: Clean Dirty Flags
  421. run: |
  422. # remove dirty
  423. sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"
  424. - name: Set file name
  425. run: |
  426. ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  427. # This gives: KSU33208-branch-xxx-xxx
  428. FILE_NAME="KSU${KSU_VERSION}-${ARTIFACT_BASE}"
  429. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  430. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  431. echo "✅ Final artifact name: $FILE_NAME"
  432. - name: Build
  433. run : |
  434. set -e
  435. set -x
  436. cd "$CONFIG"
  437. echo "Building the kernel..."
  438. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  439. chmod +x build_kernel_GKI.sh
  440. ./build_kernel_GKI.sh || true
  441. 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
  442. chmod +x build_kernel_GKI.sh
  443. LTO=thin ./build_kernel_GKI.sh || true
  444. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  445. sudo apt update
  446. sudo apt-get install -y libyaml-dev
  447. LTO=thin ./build_kernel.sh || true
  448. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  449. chmod +x build_script.sh
  450. touch ./kernel-6.6/abi_symbollist.raw
  451. touch ./kernel-6.6/abi_symbollist
  452. ./build_script.sh || true
  453. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  454. tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
  455. else
  456. #temporarily using this until i can figure out the other phones build script issues
  457. cd kernel_platform
  458. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  459. fi
  460. - name: Prepare AnyKernel3
  461. run: |
  462. cd "$CONFIG"
  463. # Copy Image from normal build locations
  464. #if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  465. # cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  466. #elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  467. # cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  468. #else
  469. # echo "Error: Image file not found in any expected location"
  470. # exit 1
  471. #fi
  472. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  473. cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
  474. elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
  475. cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
  476. elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  477. cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
  478. elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
  479. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
  480. 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
  481. cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
  482. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  483. cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
  484. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  485. cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
  486. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  487. cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
  488. elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
  489. cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
  490. else
  491. echo "Error: Image file not found in any expected location"
  492. exit 1
  493. fi
  494. - name: Upload AnyKernel3 Artifacts
  495. id: upload_ak3
  496. uses: actions/upload-artifact@v6
  497. with:
  498. name: ${{ env.FILE_NAME }}-AnyKernel3
  499. path: |
  500. ./AnyKernel3/**
  501. compression-level: 9
  502. - name: Scan and collect patch rejects
  503. if: ${{ always() }}
  504. run: |
  505. set -e
  506. CONFIG_DIR="$CONFIG"
  507. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  508. mkdir -p "$REJECTS_DIR"
  509. # Find all .rej files under the configuration directory
  510. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  511. REJ_COUNT=${#REJS[@]}
  512. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  513. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  514. if [ "$REJ_COUNT" -gt 0 ]; then
  515. for REJ in "${REJS[@]}"; do
  516. # Relative path from $CONFIG
  517. REL="${REJ#"$CONFIG_DIR"/}"
  518. DEST="$REJECTS_DIR/$REL"
  519. mkdir -p "$(dirname "$DEST")"
  520. cp "$REJ" "$DEST"
  521. # Copy the associated original file alongside the .rej
  522. ORIG="${REJ%.rej}"
  523. if [ -f "$ORIG" ]; then
  524. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  525. mkdir -p "$(dirname "$ORIG_DEST")"
  526. cp "$ORIG" "$ORIG_DEST"
  527. fi
  528. echo "$REL" >> "$REJECTS_DIR/index.txt"
  529. done
  530. fi
  531. - name: Generate Build Summary
  532. if: ${{ always() }}
  533. run: |
  534. # Create build summary file for inclusion in Misc artifact
  535. echo "# Kernel Build Summary" > build_summary.md
  536. # Add build variant header
  537. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  538. # Add build info
  539. echo "## Build Information" >> build_summary.md
  540. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  541. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  542. echo "- **BBG**: Installed" >> build_summary.md
  543. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  544. echo "" >> build_summary.md
  545. # Get Wild_KSU commit
  546. if [ -d "$CONFIG/Wild_KSU" ]; then
  547. cd "$CONFIG/Wild_KSU"
  548. WKSU_COMMIT=$(git rev-parse HEAD)
  549. WKSU_URL="https://github.com/WildKernels/Wild_KSU/commit/$WKSU_COMMIT"
  550. echo "- **Wild_KSU**: [$WKSU_COMMIT]($WKSU_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  551. cd "$GITHUB_WORKSPACE"
  552. else
  553. echo "- **Wild_KSU**: not present" >> build_summary.md
  554. fi
  555. # Get Baseband-guard commit
  556. if [ -d "$CONFIG/Baseband-guard" ]; then
  557. cd "$CONFIG/Baseband-guard"
  558. BBG_COMMIT=$(git rev-parse HEAD)
  559. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  560. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  561. cd "$GITHUB_WORKSPACE"
  562. else
  563. echo "- **Baseband-guard**: not present" >> build_summary.md
  564. fi
  565. # Get SUSFS4KSU commit
  566. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  567. cd "$GITHUB_WORKSPACE/susfs4ksu"
  568. SUSFS_COMMIT=$(git rev-parse HEAD)
  569. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  570. echo "- **SUSFS4KSU (v2.1.0)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  571. cd "$GITHUB_WORKSPACE"
  572. else
  573. echo "- **SUSFS4KSU (v2.1.0)**: not present" >> build_summary.md
  574. fi
  575. echo "" >> build_summary.md
  576. # Add artifact summary with presence verification
  577. echo "## Build Artifacts" >> build_summary.md
  578. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  579. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  580. AK3_STATUS="✅"
  581. else
  582. AK3_STATUS="❌"
  583. fi
  584. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  585. echo "### Misc (uploaded files)" >> build_summary.md
  586. FILES_PRESENT=0
  587. 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
  588. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  589. done
  590. if [ "$FILES_PRESENT" -gt 0 ]; then
  591. MISC_STATUS="✅"
  592. else
  593. MISC_STATUS="❌"
  594. fi
  595. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  596. if [ "$MISC_STATUS" = "✅" ]; then
  597. echo " Included:" >> build_summary.md
  598. 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
  599. if [ -f "$f" ]; then
  600. echo " - $f" >> build_summary.md
  601. fi
  602. done
  603. fi
  604. echo "### Diagnostics" >> build_summary.md
  605. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  606. if [ -f patch-rejects/index.txt ]; then
  607. if [ -s patch-rejects/index.txt ]; then
  608. echo " Rejected files:" >> build_summary.md
  609. while IFS= read -r line; do
  610. echo " - $line" >> build_summary.md
  611. done < patch-rejects/index.txt
  612. else
  613. echo " Rejected file list is empty." >> build_summary.md
  614. fi
  615. else
  616. echo " No rejected patches found." >> build_summary.md
  617. fi