From c5ea818aa79da566a0eac1884da70973241ec06b Mon Sep 17 00:00:00 2001 From: SahilSonar Date: Wed, 13 Dec 2023 13:46:45 +0530 Subject: [PATCH 1/2] redfin: Move to T - Refactor script to support recovery*.zip --- .../linux/install-zipped-recovery-boot.sh | 57 ++++++++++++++++++ .../windows/install-zipped-recovery-boot.bat | 58 +++++++++++++++++++ src/main/resources/yaml/redfin_flash.yml | 3 +- src/main/resources/yaml/redfin_fs.yml | 8 +-- 4 files changed, 121 insertions(+), 5 deletions(-) create mode 100755 flash-scripts/linux/install-zipped-recovery-boot.sh create mode 100644 flash-scripts/windows/install-zipped-recovery-boot.bat diff --git a/flash-scripts/linux/install-zipped-recovery-boot.sh b/flash-scripts/linux/install-zipped-recovery-boot.sh new file mode 100755 index 00000000..edd05c2a --- /dev/null +++ b/flash-scripts/linux/install-zipped-recovery-boot.sh @@ -0,0 +1,57 @@ +#!/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 + +# Exit status +# - 0 : Recovery installed +# - 101 : TWRP_IMAGE_PATH missing +# - 103 : Failed to unzip + +TWRP_IMAGE_PATH=$1 +OUTPUT_FOLDER=$(dirname $TWRP_IMAGE_PATH) +FASTBOOT_FOLDER_PATH=$2 +FASTBOOT_PATH=${FASTBOOT_FOLDER_PATH}"fastboot" +JAVA_FOLDER_PATH=$3 +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 +fi + +# 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 + exit 103 +fi + +echo "Flashing boot $DEVICE_ID" +"$FASTBOOT_PATH" flash boot "$OUTPUT_FOLDER"/boot-*-redfin.img + +echo "Flashing dtbo $DEVICE_ID" +"$FASTBOOT_PATH" flash dtbo "$OUTPUT_FOLDER"/dtbo-*-redfin.img + +echo "Flash the recovery $DEVICE_ID" +"$FASTBOOT_PATH" flash vendor_boot "$OUTPUT_FOLDER"/recovery-*-redfin.img diff --git a/flash-scripts/windows/install-zipped-recovery-boot.bat b/flash-scripts/windows/install-zipped-recovery-boot.bat new file mode 100644 index 00000000..66e3455a --- /dev/null +++ b/flash-scripts/windows/install-zipped-recovery-boot.bat @@ -0,0 +1,58 @@ +@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 +:: 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 + +echo "fastboot path: %FASTBOOT_PATH%" + +IF not defined TWRP_IMAGE_PATH ( + echo "TWRP Image path is empty" + exit /b 101 +) + +:: 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%" + +IF %ERRORLEVEL% neq 0 ( + exit /b 103 +) + +echo "Flashing boot" +for %%I in (%OUTPUT_FOLDER%\boot-*-redfin.img) do %FASTBOOT_PATH% flash boot "%%I" + +echo "Flashing dtbo" +for %%I in (%OUTPUT_FOLDER%\dtbo-*-redfin.img) do %FASTBOOT_PATH% flash dtbo "%%I" + +echo "Flash the recovery" +for %%I in (%OUTPUT_FOLDER%\recovery-*-redfin.img) do %FASTBOOT_PATH% flash vendor_boot "%%I" diff --git a/src/main/resources/yaml/redfin_flash.yml b/src/main/resources/yaml/redfin_flash.yml index 2c39dd0d..253d3ad4 100644 --- a/src/main/resources/yaml/redfin_flash.yml +++ b/src/main/resources/yaml/redfin_flash.yml @@ -77,10 +77,11 @@ steps: instructions: - install_instr_recoveryInstall averageTime: 3 - script: install-recovery-boot + script: install-zipped-recovery-boot parameters: twrp_image_path: ${TWRP_IMAGE_PATH} fastboot_folder_path: ${ADB_FOLDER_PATH} + java_folder_path: ${JAVA_FOLDER_PATH} okCodes: 0: ~ koCodes: diff --git a/src/main/resources/yaml/redfin_fs.yml b/src/main/resources/yaml/redfin_fs.yml index 0efd5ef0..558220e8 100644 --- a/src/main/resources/yaml/redfin_fs.yml +++ b/src/main/resources/yaml/redfin_fs.yml @@ -16,11 +16,11 @@ --- sources: rom: - url: https://images.ecloud.global/stable/redfin/e-latest-s-redfin.zip - filePath: e-latest-s-redfin.zip + url: https://images.ecloud.global/stable/redfin/e-latest-t-redfin.zip + filePath: e-latest-t-redfin.zip twrp: - url: https://images.ecloud.global/stable/redfin/recovery-e-latest-s-redfin.img - filePath: recovery-e-latest-s-redfin.img + url: https://images.ecloud.global/stable/redfin/recovery-IMG-e-latest-t-redfin.zip + filePath: recovery-IMG-e-latest-t-redfin.zip patch: url: https://images.ecloud.global/stable/pkmd_pixel.bin filePath: pkmd_pixel.bin -- GitLab From 390b8056811089e6161c8bdcfe3ed959fbab40df Mon Sep 17 00:00:00 2001 From: SahilSonar Date: Wed, 13 Dec 2023 15:57:54 +0530 Subject: [PATCH 2/2] redfin: Cleanup existing *.img files --- flash-scripts/linux/install-zipped-recovery-boot.sh | 4 ++++ flash-scripts/windows/install-zipped-recovery-boot.bat | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/flash-scripts/linux/install-zipped-recovery-boot.sh b/flash-scripts/linux/install-zipped-recovery-boot.sh index edd05c2a..8fe64836 100755 --- a/flash-scripts/linux/install-zipped-recovery-boot.sh +++ b/flash-scripts/linux/install-zipped-recovery-boot.sh @@ -40,6 +40,10 @@ then exit 101 fi +# Delete any existing *.img files in OUTPUT_FOLDER +rm -rf "$OUTPUT_FOLDER"/*.img +rm -rf "$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" ; diff --git a/flash-scripts/windows/install-zipped-recovery-boot.bat b/flash-scripts/windows/install-zipped-recovery-boot.bat index 66e3455a..cd64209e 100644 --- a/flash-scripts/windows/install-zipped-recovery-boot.bat +++ b/flash-scripts/windows/install-zipped-recovery-boot.bat @@ -40,6 +40,10 @@ IF not defined TWRP_IMAGE_PATH ( exit /b 101 ) +:: Delete any existing *.img files in OUTPUT_FOLDER +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%" -- GitLab