build.yml 26 KB

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