build.yml 29 KB

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