diff --git a/flash-scripts/linux/install-zipped-recovery-boot.sh b/flash-scripts/linux/install-zipped-recovery-boot.sh index ac287d99b3afa9a8a60fc174719580397d5faf26..7e87d8eaa6e07fdf3a4c01c9afa0401239a36644 100755 --- a/flash-scripts/linux/install-zipped-recovery-boot.sh +++ b/flash-scripts/linux/install-zipped-recovery-boot.sh @@ -26,33 +26,43 @@ # - 103 : Failed to unzip TWRP_IMAGE_PATH=$1 -OUTPUT_FOLDER=$(dirname $TWRP_IMAGE_PATH) +OUTPUT_FOLDER=$(dirname "$TWRP_IMAGE_PATH") FASTBOOT_FOLDER_PATH=$2 -FASTBOOT_PATH=${FASTBOOT_FOLDER_PATH}"fastboot" +FASTBOOT_PATH="${FASTBOOT_FOLDER_PATH}/fastboot" JAVA_FOLDER_PATH=$3 -JAR_PATH=${JAVA_FOLDER_PATH}"/bin/jar" +JAR_PATH="${JAVA_FOLDER_PATH}/bin/jar" echo "fastboot path: $FASTBOOT_PATH" -if [ -z "$TWRP_IMAGE_PATH" ] -then - echo "TWRP Image path is empty" - exit 101 +if [ -z "$TWRP_IMAGE_PATH" ]; then + echo "TWRP Image path is empty" + exit 101 fi # Delete any existing *.img files in OUTPUT_FOLDER -rm -rf "$OUTPUT_FOLDER"/*.img -rm -rf "$OUTPUT_FOLDER"/*.img.sha256sum +rm -f "$OUTPUT_FOLDER"/*.img +rm -f "$OUTPUT_FOLDER"/*.img.sha256sum # Use jar tool to extract all .img files from the zip archive cd "$OUTPUT_FOLDER" || exit 102 -if ! "$JAR_PATH" -x -v -f "$TWRP_IMAGE_PATH" ; -then +if ! "$JAR_PATH" -x -v -f "$TWRP_IMAGE_PATH"; then exit 103 fi -echo "Flashing boot $DEVICE_ID" -"$FASTBOOT_PATH" flash boot "$OUTPUT_FOLDER"/recovery-*-*.img +# Define slots to flash +SLOTS=("a" "b") -echo "Flashing dtbo $DEVICE_ID" -"$FASTBOOT_PATH" flash dtbo "$OUTPUT_FOLDER"/dtbo-*-*.img \ No newline at end of file +# Flash to both slots +for SLOT in "${SLOTS[@]}"; do + echo "Flashing boot to slot $SLOT" + for img in "$OUTPUT_FOLDER"/recovery-*-*.img; do + "$FASTBOOT_PATH" flash boot_"$SLOT" "$img" + done + + echo "Flashing dtbo to slot $SLOT" + for img in "$OUTPUT_FOLDER"/dtbo-*-*.img; do + "$FASTBOOT_PATH" flash dtbo_"$SLOT" "$img" + done +done + +echo "Flashing completed" diff --git a/flash-scripts/windows/install-zipped-recovery-boot.bat b/flash-scripts/windows/install-zipped-recovery-boot.bat index af25a4148d81177964ccff08f2178b3496aad6ea..2c363350fe0a1d339bc43ca4ab19c81bfca7d1cb 100644 --- a/flash-scripts/windows/install-zipped-recovery-boot.bat +++ b/flash-scripts/windows/install-zipped-recovery-boot.bat @@ -1,59 +1,70 @@ @echo off -:: !/bin/bash - :: Copyright (C) 2023 Murena SAS - Author: SahilSonar - :: This program is free software: you can redistribute it and/or modify :: it under the terms of the GNU General Public License as published by :: the Free Software Foundation, either version 3 of the License, or :: (at your option) any later version. - :: This program is distributed in the hope that it will be useful, :: but WITHOUT ANY WARRANTY; without even the implied warranty of :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :: GNU General Public License for more details. - :: You should have received a copy of the GNU General Public License :: along with this program. If not, see . -:: Parameter -:: $1: TWRP_IMAGE_PATH need twrp path (${TWRP_FOLDER}/${TWRP}) -:: $2: FASTBOOT_FOLDER_PATH needs fastboot binary path -:: $3: JAVA_FOLDER_PATH needs java binary path +:: Parameters +:: %1: TWRP_IMAGE_PATH need twrp path (%TWRP_FOLDER%\%TWRP%) +:: %2: FASTBOOT_FOLDER_PATH needs fastboot binary path +:: %3: JAVA_FOLDER_PATH needs java binary path + :: Exit status :: - 0 : Recovery installed :: - 101 : TWRP_IMAGE_PATH missing :: - 103 : Failed to unzip -SET TWRP_IMAGE_PATH=%1 -SET OUTPUT_FOLDER=%~dp1 -SET FASTBOOT_FOLDER_PATH=%2 -SET FASTBOOT_PATH=%FASTBOOT_FOLDER_PATH%fastboot -SET JAVA_FOLDER_PATH=%3 -SET JAR_PATH=%JAVA_FOLDER_PATH%\bin\jar +SET "TWRP_IMAGE_PATH=%~1" +SET "OUTPUT_FOLDER=%~dp1" +SET "FASTBOOT_FOLDER_PATH=%~2" +SET "FASTBOOT_PATH=%FASTBOOT_FOLDER_PATH%\fastboot" +SET "JAVA_FOLDER_PATH=%~3" +SET "JAR_PATH=%JAVA_FOLDER_PATH%\bin\jar" -echo "fastboot path: %FASTBOOT_PATH%" +:: Ensure there's no trailing backslash in FASTBOOT_FOLDER_PATH +IF "%FASTBOOT_FOLDER_PATH:~-1%"=="\" SET "FASTBOOT_FOLDER_PATH=%FASTBOOT_FOLDER_PATH:~0,-1%" +SET "FASTBOOT_PATH=%FASTBOOT_FOLDER_PATH%\fastboot" -IF not defined TWRP_IMAGE_PATH ( - echo "TWRP Image path is empty" +echo fastboot path: %FASTBOOT_PATH% + +IF NOT DEFINED TWRP_IMAGE_PATH ( + echo TWRP Image path is empty exit /b 101 ) :: Delete any existing *.img files in OUTPUT_FOLDER -del /Q %OUTPUT_FOLDER%\*.img -del /Q %OUTPUT_FOLDER%\*.img.sha256sum +del /Q "%OUTPUT_FOLDER%\*.img" +del /Q "%OUTPUT_FOLDER%\*.img.sha256sum" :: Use jar tool to extract all .img files from the zip archive -cd %OUTPUT_FOLDER% || exit /b 102 -%JAR_PATH% -x -v -f "%TWRP_IMAGE_PATH%" +cd /d "%OUTPUT_FOLDER%" || exit /b 102 +"%JAR_PATH%" -x -v -f "%TWRP_IMAGE_PATH%" -IF %ERRORLEVEL% neq 0 ( +IF %ERRORLEVEL% NEQ 0 ( exit /b 103 ) -echo "Flashing boot" -for %%I in (%OUTPUT_FOLDER%\recovery-*-*.img) do %FASTBOOT_PATH% flash boot "%%I" +:: Define slots to flash +SET "SLOTS=a b" + +echo Flashing boot +for %%I in ("%OUTPUT_FOLDER%\recovery-*-*.img") do ( + for %%S in (%SLOTS%) do ( + "%FASTBOOT_PATH%" flash boot_%%S "%%~I" + ) +) -echo "Flashing dtbo" -for %%I in (%OUTPUT_FOLDER%\dtbo-*-*.img) do %FASTBOOT_PATH% flash dtbo "%%I" +echo Flashing dtbo +for %%I in ("%OUTPUT_FOLDER%\dtbo-*-*.img") do ( + for %%S in (%SLOTS%) do ( + "%FASTBOOT_PATH%" flash dtbo_%%S "%%~I" + ) +)