action.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. name: prepare ak3
  2. description: copy kernel image to ak3 folder
  3. inputs:
  4. branch:
  5. description: 'device kernel/repo'
  6. required: true
  7. runs:
  8. using: composite
  9. steps:
  10. - name: copy image to ak3 folder depending on branch
  11. shell: bash
  12. run: |
  13. cd "$CONFIG"
  14. # 1. Determine target file name based on branch structure
  15. if [[ "${{ inputs.branch }}" == SM-A055* || "${{ inputs.branch }}" == SM-X926* || "${{ inputs.branch }}" == "SM-A075M-Oneui7" ]]; then
  16. target_name="Image.gz"
  17. else
  18. target_name="Image"
  19. fi
  20. shopt -s globstar
  21. shopt -s nocaseglob
  22. KERNEL_IMAGE=""
  23. priority_found=false
  24. fallback_images=()
  25. # ==========================================
  26. # PHASE 1: DIRECT BAZEL DEPENDENCY QUERY (SMART)
  27. # ==========================================
  28. if [ -f "kernel_platform/tools/bazel" ]; then
  29. echo "Bazel detected. Querying for target: //common:kernel_aarch64 ($target_name)..."
  30. # 1. Gather all files matching the target name into an array
  31. mapfile -t cquery_outputs < <(tools/bazel cquery //common:kernel_aarch64 --output=files 2>/dev/null | grep -E "/${target_name}$")
  32. # 2. First Pass: Look strictly for your priority folder structures in the Bazel paths
  33. for priority in *_kbuild_mixed_tree *.user "kernel_aarch64"; do
  34. for path in "${cquery_outputs[@]}"; do
  35. # Use case-insensitive matching to verify if the path contains the priority folder name
  36. if [[ "${path,,}" == *"${priority,,}"* ]] && [ -f "$path" ]; then
  37. kernel_image="$path"
  38. priority_found=true
  39. echo "Match found via prioritized Bazel Graph lookup: $kernel_image"
  40. break 2
  41. fi
  42. done
  43. done
  44. else
  45. echo "No Bazel installation detected. Skipping Phase 1..."
  46. fi
  47. # 2. Phase 2: Hunt inside priority folders if build did not use bazel
  48. for priority in "dist" "boot"; do
  49. for file in **/"$priority"/"$target_name"; do
  50. if [ -f "$file" ] && [[ "$file" != *".git"* ]]; then
  51. KERNEL_IMAGE="$file"
  52. priority_found=true
  53. break 2
  54. fi
  55. done
  56. done
  57. # 3. Phase 3: If not in priority folders, gather ALL copies across the workspace
  58. if [ "$priority_found" = false ]; then
  59. for file in **/"$target_name"; do
  60. if [ -f "$file" ] && [[ "$file" != *".git"* ]]; then
  61. fallback_images+=("$file")
  62. fi
  63. done
  64. fi
  65. shopt -u nocaseglob
  66. # ==========================================
  67. # VALIDATION AND LOGGING OUTPUT
  68. # ==========================================
  69. if [ "$priority_found" = true ]; then
  70. echo "========================================================"
  71. echo "SUCCESS: Selected kernel binary path:"
  72. echo " -> $KERNEL_IMAGE"
  73. echo "========================================================"
  74. else
  75. echo "WARNING: Could not locate '$target_name' inside specified priority targets!"
  76. if [ ${#fallback_images[@]} -eq 0 ]; then
  77. echo "ERROR: The file was not found ANYWHERE in the workspace. Compilation likely failed."
  78. exit 1
  79. else
  80. echo "--------------------------------------------------------"
  81. echo "DISCOVERY MODE: Found the following alternative locations:"
  82. echo "--------------------------------------------------------"
  83. for fallback in "${fallback_images[@]}"; do
  84. echo " -> $fallback"
  85. done
  86. echo "--------------------------------------------------------"
  87. echo "Action Required: Update your script matching rules using a parent folder named above."
  88. exit 1
  89. fi
  90. fi
  91. #if [[ ${{ inputs.branch }} == SM-S928B* || ${{ inputs.branch }} == SM-S931* || ${{ inputs.branch }} == SM-F741* ]]; then
  92. # KERNEL_IMAGE=$(find kernel_platform/out -type f -path "*_kbuild_mixed_tree/Image" | head -n1)
  93. # echo "$KERNEL_IMAGE"
  94. # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image"
  95. #elif [[ -f ./kernel_platform/bazel-bin/common/kernel_aarch64/Image ]]; then
  96. # cp ./kernel_platform/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
  97. #elif [[ -f ./bazel-bin/kernel/kernel_aarch64/Image ]]; then
  98. #cp ./bazel-bin/kernel/kernel_aarch64/Image "$ANYKERNEL3/Image"
  99. #elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  100. # cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
  101. #elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
  102. # cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
  103. #elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
  104. # cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
  105. #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* || "${{ inputs.branch }}" == "SM-X710-Oneui6.1.1" ]]; then
  106. # cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
  107. #elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" || "${{ inputs.branch }}" == "SM-X610-Oneui6.1.1-bit7" || "${{ inputs.branch }}" == "SM-A166B-Oneui7" ]]; then
  108. # cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
  109. #elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  110. # cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
  111. #elif [[ ${{ inputs.branch }} == SM-S926B* ]]; then
  112. # #cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
  113. # KERNEL_IMAGE=$(find out -type f -name "Image" | head -n1)
  114. # echo "$KERNEL_IMAGE"
  115. # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image"
  116. #elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
  117. # #cp ./out/s5e8845_user/dist/Image "$ANYKERNEL3/Image"
  118. # KERNEL_IMAGE=$(find out -type f -name "Image" | head -n1)
  119. # echo "$KERNEL_IMAGE"
  120. # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image"
  121. #elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
  122. # cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
  123. #elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
  124. # #cp ./out/target/product/a05m/obj/KLEAF_OBJ/dist/kernel_device_modules-6.6/mgk_64_k66_kernel_aarch64.user/Image.gz "$ANYKERNEL3/Image.gz"
  125. # KERNEL_IMAGE=$(find out -type f -name "Image.gz" | head -n1)
  126. # echo "$KERNEL_IMAGE"
  127. # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image.gz"
  128. #elif [[ "${{ inputs.branch }}" == "SM-A075M-Oneui7" ]]; then
  129. # cp ./out/target/product/a07/obj/KERNEL_OBJ/kernel-5.10/arch/arm64/boot/Image.gz "$ANYKERNEL3/Image.gz"
  130. #elif [[ ${{ inputs.branch }} == SM-X926* ]]; then
  131. # #cp ./out/target/product/gts10u/obj/KLEAF_OBJ/dist/kernel_device_modules-6.1/mgk_64_k61_kernel_aarch64.user/Image.gz "$ANYKERNEL3/Image.gz"
  132. # KERNEL_IMAGE=$(find out -type f -name "Image.gz" | head -n1)
  133. # echo "$KERNEL_IMAGE"
  134. # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image.gz"
  135. #else
  136. # echo "Error: Image file not found in any expected location"
  137. # exit 1
  138. #fi