@@ -615,7 +615,7 @@ run_super_unpack_interactive() {
615615 read -rp $' \n Press Enter to return...'
616616}
617617
618- # --- MODIFIED: run_super_create_config_interactive now handles percentage overhead ---
618+ # --- MODIFIED: run_super_create_config_interactive now asks for logging preference ---
619619run_super_create_config_interactive () {
620620
621621 local project_dir metadata_dir final_config_file
@@ -700,12 +700,26 @@ run_super_create_config_interactive() {
700700 done
701701 done
702702
703+ clear; print_banner
704+ echo -e " \n${BOLD} Final Configuration Step${RESET} "
705+ select_option " Enable detailed, real-time logs during super repack?" \
706+ " Yes (Recommended for debugging)" \
707+ " No (Show a clean spinner)"
708+
709+ local enable_verbose_logs=" false"
710+ if [ " $AIT_CHOICE_INDEX " -eq 0 ]; then
711+ enable_verbose_logs=" true"
712+ fi
713+
703714 {
704715 echo " # --- Universal Repack Configuration ---"
705716 echo " # Project: $( basename " $project_dir " ) "
706717 echo " # Generated on $( date) "
707718 echo " # WARNING: Do NOT edit this file manually unless you know what you are doing."
708719 echo " "
720+ echo " # --- Repack Behavior Settings ---"
721+ echo " ENABLE_VERBOSE_LOGS=${enable_verbose_logs} "
722+ echo " "
709723 echo " # --- Super Partition Metadata ---"
710724 grep -v -E ' ^(#|$)' " ${metadata_dir} /super_repack_info.txt"
711725 echo " "
@@ -733,7 +747,7 @@ run_super_create_config_interactive() {
733747 read -rp $' \n Press Enter to return...'
734748}
735749
736- # --- MODIFIED: run_super_repack_interactive now passes percentage overhead ---
750+ # --- MODIFIED: run_super_repack_interactive now supports conditional logging ---
737751run_super_repack_interactive () {
738752
739753 local project_dir metadata_dir part_config_file logical_dir extracted_dir
@@ -773,7 +787,6 @@ run_super_repack_interactive() {
773787 set +e # Disable exit on error for the loop
774788 local total=$( echo " $PARTITION_LIST " | wc -w)
775789 local current=0
776- local spinner=( ' ⠋' ' ⠙' ' ⠹' ' ⠸' ' ⠼' ' ⠴' ' ⠦' ' ⠧' ' ⠇' ' ⠏' )
777790 local all_successful=true
778791
779792 echo -e " \n${BLUE} --- Repacking content into logical partitions ---${RESET} "
@@ -794,23 +807,40 @@ run_super_repack_interactive() {
794807 fi
795808 fi
796809
797- bash " $REPACK_SCRIPT_PATH " " ${project_dir} /extracted_content/ ${part_name} " " ${logical_dir} / ${part_name} .img " " ${repack_args[@]} " --no-banner > /dev/null 2>&1 &
798- local pid= $!
799-
800- while kill -0 $pid 2> /dev/null ; do
801- echo -ne " \r\033[K ${YELLOW} ( ${current} / ${total} ) Repacking: ${BOLD} ${part_name}${RESET} ... ${spinner[$((spin++ % 10)) ]}"
802- sleep 0.1
803- done
804-
805- wait $pid
806- if [ $? -ne 0 ] ; then
807- echo -e " \r\033[K ${RED} ( ${current} / ${total} ) FAILED to repack: ${BOLD}${part_name}${RESET} [✗] "
808- all_successful=false
809- break
810+ # Use a default of 'false' if the variable isn't in the config file
811+ if [ " ${ENABLE_VERBOSE_LOGS :- false} " == " true " ] ; then
812+ # --- VERBOSE LOGGING PATH ---
813+ echo -e " \n ${YELLOW} --- ( ${current} / ${total} ) Repacking: ${BOLD}${part_name}${RESET} --- ${RESET} "
814+ bash " $REPACK_SCRIPT_PATH " " ${project_dir} /extracted_content/ ${part_name} " " ${logical_dir} / ${part_name} .img " " ${repack_args[@ ]}" --no-banner
815+
816+ if [ $? -ne 0 ] ; then
817+ echo -e " ${RED} --- [✗] FAILED: ${BOLD}${part_name}${RESET} repack failed. See logs above. --- ${RESET} "
818+ all_successful=false
819+ break
820+ else
821+ echo -e " ${GREEN} --- [✓] Success: ${BOLD}${part_name}${RESET} repacked --- ${RESET} "
822+ fi
810823 else
811- echo -e " \r\033[K${GREEN} (${current} /${total} ) Repacked: ${BOLD}${part_name}${RESET} [✓]"
824+ # --- SILENT SPINNER PATH ---
825+ bash " $REPACK_SCRIPT_PATH " " ${project_dir} /extracted_content/${part_name} " " ${logical_dir} /${part_name} .img" " ${repack_args[@]} " --no-banner > /dev/null 2>&1 &
826+ local pid=$!
827+ local spin=0
828+ local spinner=( ' ⠋' ' ⠙' ' ⠹' ' ⠸' ' ⠼' ' ⠴' ' ⠦' ' ⠧' ' ⠇' ' ⠏' )
829+
830+ while kill -0 $pid 2> /dev/null; do
831+ echo -ne " \r\033[K${YELLOW} (${current} /${total} ) Repacking: ${BOLD}${part_name}${RESET} ... ${spinner[$((spin++ % 10))]} "
832+ sleep 0.1
833+ done
834+
835+ wait $pid
836+ if [ $? -ne 0 ]; then
837+ echo -e " \r\033[K${RED} (${current} /${total} ) FAILED to repack: ${BOLD}${part_name}${RESET} [✗]"
838+ all_successful=false
839+ break
840+ else
841+ echo -e " \r\033[K${GREEN} (${current} /${total} ) Repacked: ${BOLD}${part_name}${RESET} [✓]"
842+ fi
812843 fi
813-
814844 done
815845
816846 if [ " $all_successful " = false ]; then
@@ -820,10 +850,23 @@ run_super_repack_interactive() {
820850 fi
821851
822852 echo -e " \n${BLUE} --- Assembling final super image ---${RESET} "
853+
854+ set -e
823855 bash " $SUPER_SCRIPT_PATH " repack " $logical_dir " " $output_image " " $sparse_flag " --no-banner
824856
825- rm -rf " $logical_dir "
857+ # Check the exit code of the last command explicitly
858+ if [ $? -ne 0 ]; then
859+ # This block will now correctly execute if super-tools.sh fails
860+ echo -e " \n${RED}${BOLD} FATAL: Failed to assemble the final super image. Please check the errors above.${RESET} "
861+ # Restore the original trap and exit
862+ trap ' cleanup_and_exit' INT TERM EXIT
863+ read -rp $' \n Press Enter to return...'
864+ return
865+ fi
866+
826867 set +e
868+
869+ rm -rf " $logical_dir "
827870 trap ' cleanup_and_exit' INT TERM EXIT
828871
829872 echo -e " \n${GREEN}${BOLD} Super repack successful!${RESET} "
0 commit comments