name: prepare ak3 description: copy kernel image to ak3 folder runs: using: composite steps: - name: copy image to ak3 folder depending on branch shell: bash run: | cd "$CONFIG" # 1. Determine target file name based on branch structure if [[ "$BRANCH" == SM-A055* || "$BRANCH" == SM-X926* || "$BRANCH" == "SM-A075M-Oneui7" ]]; then target_name="Image.gz" else target_name="Image" fi shopt -s globstar shopt -s nocaseglob KERNEL_IMAGE="" priority_found=false fallback_images=() search_roots=("." "kernel_platform/out" "out") # ========================================== # PHASE 1: DIRECT BAZEL DEPENDENCY QUERY (SMART) # ========================================== for priority in "kbuild_mixed_tree" "dist" "kernel_aarch64" ".user" "_user" "boot"; do for root in "${search_roots[@]}"; do if [ -d "$root" ]; then # Place the wildcard * directly in the path syntax so Bash expands it natively for file in "$root"/**/*"$priority"/"$target_name"; do if [ -f "$file" ] && [[ "$file" != *".git"* ]]; then KERNEL_IMAGE="$file" priority_found=true cp "$KERNEL_IMAGE" "$ANYKERNEL3/$target_name" break 3 # Lock in and break out of all three loops immediately fi done fi done done # ========================================== # PHASE 3: DEEP WORKSPACE FALLBACK DISCOVERY # ========================================== if [ "$priority_found" = false ]; then echo "Priority folder target missing. Running complete disk scan..." for root in "${search_roots[@]}"; do if [ -d "$root" ]; then for file in "$root"/**/"$target_name"; do if [ -f "$file" ] && [[ "$file" != *".git"* ]]; then if [[ ! " ${fallback_images[*]} " =~ " ${file} " ]]; then fallback_images+=("$file") fi fi done fi done if [ ${#fallback_images[@]} -gt 0 ]; then KERNEL_IMAGE="${fallback_images[0]}" fi fi shopt -u nocaseglob # ========================================== # VALIDATION AND LOGGING OUTPUT # ========================================== if [ "$priority_found" = true ]; then echo "========================================================" echo "SUCCESS: Selected kernel binary path:" echo " -> $KERNEL_IMAGE" echo "KERNEL_IMAGE=$KERNEL_IMAGE" >> $GITHUB_ENV echo "========================================================" else echo "WARNING: Could not locate '$target_name' inside specified priority targets!" if [ ${#fallback_images[@]} -eq 0 ]; then echo "ERROR: The file was not found ANYWHERE in the workspace. Compilation likely failed." exit 1 else echo "--------------------------------------------------------" echo "DISCOVERY MODE: Found the following alternative locations:" echo "--------------------------------------------------------" for fallback in "${fallback_images[@]}"; do echo " -> $fallback" done echo "--------------------------------------------------------" echo "Action Required: Update your script matching rules using a parent folder named above." exit 1 fi fi - name: check IKCONFIG shell: bash run: | "$COMMON/scripts/extract-ikconfig" "$CONFIG/$KERNEL_IMAGE" | grep -E 'CONFIG_UH|CONFIG_UH_RKP|CONFIG_UH_LKMAUTH|CONFIG_UH_LKM_BLOCK|CONFIG_RKP|CONFIG_RKP_CFP_JOPP|CONFIG_RKP_CFP_ROPP|CONFIG_RKP_CFP|CONFIG_SECURITY_DEFEX|CONFIG_PROCA|CONFIG_FIVE|CONFIG_KDP|CONFIG_KDP_NS|CONFIG_LTO' #if [[ $BRANCH == SM-S928B* || $BRANCH == SM-S931* || $BRANCH == SM-F741* ]]; then # KERNEL_IMAGE=$(find kernel_platform/out -type f -path "*_kbuild_mixed_tree/Image" | head -n1) # echo "$KERNEL_IMAGE" # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image" #elif [[ -f ./kernel_platform/bazel-bin/common/kernel_aarch64/Image ]]; then # cp ./kernel_platform/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image" #elif [[ -f ./bazel-bin/kernel/kernel_aarch64/Image ]]; then #cp ./bazel-bin/kernel/kernel_aarch64/Image "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-S928B-Oneui7" || "$BRANCH" == "SM-S928B-Oneui8-bit4" || "$BRANCH" == "SM-S928B-Oneui8-bit5" || "$BRANCH" == "SM-F741B-Oneui8" ]]; then # cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-S928B-Oneui6.1" ]]; then # cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-S938B-Oneui7" || "$BRANCH" == "SM-S931B-Oneui8" || "$BRANCH" == "SM-M556B-Oneui8" ]]; then # cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-X916B" || "$BRANCH" == "SM-F946N-Oneui7" || "$BRANCH" == "SM-F946B-Oneui8" || "$BRANCH" == "SM-S916B-Oneui8" || "$BRANCH" == "SM-S918B-Oneui8" || $BRANCH == SM-S911B* || "$BRANCH" == "SM-X710-Oneui6.1.1" ]]; then # cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image" #elif [[ $BRANCH == SM-A546* || "$BRANCH" == "SM-M146B-Oneui7-ADYJ2" || "$BRANCH" == "SM-S908B-Oneui8-bitK" || "$BRANCH" == "SM-X610-Oneui6.1.1-bit7" || "$BRANCH" == "SM-A166B-Oneui7" ]]; then # cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-A566B" ]]; then # cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image" #elif [[ $BRANCH == SM-S926B* ]]; then # #cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image" # KERNEL_IMAGE=$(find out -type f -name "Image" | head -n1) # echo "$KERNEL_IMAGE" # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image" #elif [[ $BRANCH == SM-A556* ]]; then # #cp ./out/s5e8845_user/dist/Image "$ANYKERNEL3/Image" # KERNEL_IMAGE=$(find out -type f -name "Image" | head -n1) # echo "$KERNEL_IMAGE" # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image" #elif [[ "$BRANCH" == "SM-S901E-Oneui8" || "$BRANCH" == "SM-X800-Oneui8" ]]; then # cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image" #elif [[ $BRANCH == SM-A055* ]]; then # #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" # KERNEL_IMAGE=$(find out -type f -name "Image.gz" | head -n1) # echo "$KERNEL_IMAGE" # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image.gz" #elif [[ "$BRANCH" == "SM-A075M-Oneui7" ]]; then # cp ./out/target/product/a07/obj/KERNEL_OBJ/kernel-5.10/arch/arm64/boot/Image.gz "$ANYKERNEL3/Image.gz" #elif [[ $BRANCH == SM-X926* ]]; then # #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" # KERNEL_IMAGE=$(find out -type f -name "Image.gz" | head -n1) # echo "$KERNEL_IMAGE" # cp "$KERNEL_IMAGE" "$ANYKERNEL3/Image.gz" #else # echo "Error: Image file not found in any expected location" # exit 1 #fi