From 35ff62400cd7562323f1567f90bc7b93446af8e2 Mon Sep 17 00:00:00 2001 From: Jackeagle Date: Mon, 31 Jul 2023 19:19:25 +0530 Subject: [PATCH 1/3] build: Revamp RECOVERY_NEEDS_SUPPORT_IMG flag logic - Conditionally include vendor_boot.img when RECOVERY_NEEDS_VENDOR_BOOT_IMG is set - Most OnePlus devices depend on dtbo and vbmeta for recovery to boot up hence having only these files make sense. - Zip them up with recovery-*.zip so that it looks clean and neat on download page. Signed-off-by: Jackeagle --- src/build.sh | 83 +++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/src/build.sh b/src/build.sh index c9599f9..eba7501 100755 --- a/src/build.sh +++ b/src/build.sh @@ -318,44 +318,52 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if [ "$RECOVERY_IMG" = true ]; then - RECOVERY_IMG_NAME="recovery-${build%.*}.img" - BOOT_IMG_NAME="boot-${build%.*}.img" - DTBO_IMG_NAME="dtbo-${build%.*}.img" - SUPER_EMPTY_IMG_NAME="super_empty-${build%.*}.img" - VBMETA_IMG_NAME="vbmeta-${build%.*}.img" - VENDOR_BOOT_IMG_NAME="vendor_boot-${build%.*}.img" - - if [ "$RECOVERY_NEEDS_SUPPORT_IMG" = true ]; then - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/boot.img "$BOOT_IMG_NAME" - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/dtbo.img "$DTBO_IMG_NAME" - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/super_empty.img "$SUPER_EMPTY_IMG_NAME" - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vbmeta.img "$VBMETA_IMG_NAME" - sha256sum "$BOOT_IMG_NAME" > "$BOOT_IMG_NAME.sha256sum" - sha256sum "$DTBO_IMG_NAME" > "$DTBO_IMG_NAME.sha256sum" - sha256sum "$SUPER_EMPTY_IMG_NAME" > "$SUPER_EMPTY_IMG_NAME.sha256sum" - sha256sum "$VBMETA_IMG_NAME" > "$VBMETA_IMG_NAME.sha256sum" - mv "$BOOT_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" - mv "$DTBO_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" - mv "$SUPER_EMPTY_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" - mv "$VBMETA_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" - fi - - if [ "$RECOVERY_NEEDS_VENDOR_BOOT_IMG" = true ]; then - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$VENDOR_BOOT_IMG_NAME" - sha256sum "$VENDOR_BOOT_IMG_NAME" > "$VENDOR_BOOT_IMG_NAME.sha256sum" - mv "$VENDOR_BOOT_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" - fi + RECOVERY_IMG_NAME="recovery-${build%.*}.img" + BOOT_IMG_NAME="boot-${build%.*}.img" + DTBO_IMG_NAME="dtbo-${build%.*}.img" + SUPER_EMPTY_IMG_NAME="super_empty-${build%.*}.img" + VBMETA_IMG_NAME="vbmeta-${build%.*}.img" + VENDOR_BOOT_IMG_NAME="vendor_boot-${build%.*}.img" + RECOVERY_ZIP_NAME="recovery-IMG-${build%.*}.zip" + + if [ "$RECOVERY_NEEDS_SUPPORT_IMG" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/dtbo.img "$DTBO_IMG_NAME" + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vbmeta.img "$VBMETA_IMG_NAME" + + if [ "$RECOVERY_NEEDS_VENDOR_BOOT_IMG" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$VENDOR_BOOT_IMG_NAME" + fi + + if [ "$VBOOT_IS_RECOVERY" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$RECOVERY_IMG_NAME" + elif [ -f "recovery.img" ]; then + cp -a recovery.img "$RECOVERY_IMG_NAME" + else + cp -a boot.img "$RECOVERY_IMG_NAME" + fi + + # Conditionally include vendor_boot.img only when RECOVERY_NEEDS_VENDOR_BOOT_IMG is set. + if [ "$RECOVERY_NEEDS_VENDOR_BOOT_IMG" = true ]; then + zip "$RECOVERY_ZIP_NAME" "$DTBO_IMG_NAME" "$VBMETA_IMG_NAME" $RECOVERY_IMG_NAME "$VENDOR_BOOT_IMG_NAME" + else + zip "$RECOVERY_ZIP_NAME" "$DTBO_IMG_NAME" "$VBMETA_IMG_NAME" $RECOVERY_IMG_NAME + fi + + sha256sum "$RECOVERY_ZIP_NAME" > "$RECOVERY_ZIP_NAME.sha256sum" + mv "$RECOVERY_ZIP_NAME"* "$ZIP_DIR/$zipsubdir/" + else + if [ "$VBOOT_IS_RECOVERY" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$RECOVERY_IMG_NAME" + elif [ -f "recovery.img" ]; then + cp -a recovery.img "$RECOVERY_IMG_NAME" + else + cp -a boot.img "$RECOVERY_IMG_NAME" + fi + + sha256sum "$RECOVERY_IMG_NAME" > "$RECOVERY_IMG_NAME.sha256sum" + mv "$RECOVERY_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" + fi - if [ "$VBOOT_IS_RECOVERY" = true ]; then - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$RECOVERY_IMG_NAME" - elif [ -f "recovery.img" ]; then - cp -a recovery.img "$RECOVERY_IMG_NAME" - else - cp -a boot.img "$RECOVERY_IMG_NAME" - fi - - sha256sum "$RECOVERY_IMG_NAME" > "$RECOVERY_IMG_NAME.sha256sum" - mv "$RECOVERY_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" fi done @@ -434,3 +442,4 @@ fi if [ "$build_successful" = false ] || [ "$sync_successful" = false ]; then exit 1 fi + -- GitLab From 5341445b46eccffc1b3729ecdef079b3ee813f49 Mon Sep 17 00:00:00 2001 From: Jackeagle Date: Tue, 1 Aug 2023 13:23:15 +0530 Subject: [PATCH 2/3] build: Conditionalize addition of img files to recovery zip - Optimize and let maintainers decide what img files are required for recovery to boot on their devices Signed-off-by: Jackeagle --- src/build.sh | 57 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/build.sh b/src/build.sh index eba7501..6e57bfe 100755 --- a/src/build.sh +++ b/src/build.sh @@ -317,22 +317,27 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then fi if [ "$RECOVERY_IMG" = true ]; then - - RECOVERY_IMG_NAME="recovery-${build%.*}.img" - BOOT_IMG_NAME="boot-${build%.*}.img" - DTBO_IMG_NAME="dtbo-${build%.*}.img" - SUPER_EMPTY_IMG_NAME="super_empty-${build%.*}.img" - VBMETA_IMG_NAME="vbmeta-${build%.*}.img" - VENDOR_BOOT_IMG_NAME="vendor_boot-${build%.*}.img" - RECOVERY_ZIP_NAME="recovery-IMG-${build%.*}.zip" + DTBO_IMG_NAME="dtbo-${build%.*}.img" + SUPER_EMPTY_IMG_NAME="super_empty-${build%.*}.img" + VBMETA_IMG_NAME="vbmeta-${build%.*}.img" + VENDOR_BOOT_IMG_NAME="vendor_boot-${build%.*}.img" + RECOVERY_IMG_NAME="recovery-${build%.*}.img" + RECOVERY_ZIP_NAME="recovery-IMG-${build%.*}.zip" if [ "$RECOVERY_NEEDS_SUPPORT_IMG" = true ]; then - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/dtbo.img "$DTBO_IMG_NAME" - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vbmeta.img "$VBMETA_IMG_NAME" - + # Copy the files specified by the flags + if [ "$RECOVERY_NEEDS_DTBO_IMG" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/dtbo.img "$DTBO_IMG_NAME" + fi + if [ "$RECOVERY_NEEDS_VBMETA_IMG" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vbmeta.img "$VBMETA_IMG_NAME" + fi if [ "$RECOVERY_NEEDS_VENDOR_BOOT_IMG" = true ]; then cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$VENDOR_BOOT_IMG_NAME" fi + if [ "$RECOVERY_NEEDS_SUPER_IMG" = true ]; then + cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/super_empty.img "$SUPER_EMPTY_IMG_NAME" + fi if [ "$VBOOT_IS_RECOVERY" = true ]; then cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$RECOVERY_IMG_NAME" @@ -342,28 +347,38 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then cp -a boot.img "$RECOVERY_IMG_NAME" fi - # Conditionally include vendor_boot.img only when RECOVERY_NEEDS_VENDOR_BOOT_IMG is set. + # Conditionally include files in zip command based on flags + files_to_zip=("$RECOVERY_IMG_NAME") + if [ "$RECOVERY_NEEDS_DTBO_IMG" = true ]; then + files_to_zip+=("$DTBO_IMG_NAME") + fi + if [ "$RECOVERY_NEEDS_VBMETA_IMG" = true ]; then + files_to_zip+=("$VBMETA_IMG_NAME") + fi if [ "$RECOVERY_NEEDS_VENDOR_BOOT_IMG" = true ]; then - zip "$RECOVERY_ZIP_NAME" "$DTBO_IMG_NAME" "$VBMETA_IMG_NAME" $RECOVERY_IMG_NAME "$VENDOR_BOOT_IMG_NAME" - else - zip "$RECOVERY_ZIP_NAME" "$DTBO_IMG_NAME" "$VBMETA_IMG_NAME" $RECOVERY_IMG_NAME + files_to_zip+=("$VENDOR_BOOT_IMG_NAME") + fi + if [ "$RECOVERY_NEEDS_SUPER_IMG" = true ]; then + files_to_zip+=("$SUPER_EMPTY_IMG_NAME") fi + # Zip command + zip "$RECOVERY_ZIP_NAME" "${files_to_zip[@]}" sha256sum "$RECOVERY_ZIP_NAME" > "$RECOVERY_ZIP_NAME.sha256sum" - mv "$RECOVERY_ZIP_NAME"* "$ZIP_DIR/$zipsubdir/" + mv "$RECOVERY_ZIP_NAME" "$ZIP_DIR/$zipsubdir/" else if [ "$VBOOT_IS_RECOVERY" = true ]; then - cp -a obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img "$RECOVERY_IMG_NAME" + cp -a "obj/PACKAGING/target_files_intermediates/lineage_*/IMAGES/vendor_boot.img" "$RECOVERY_IMG_NAME" elif [ -f "recovery.img" ]; then - cp -a recovery.img "$RECOVERY_IMG_NAME" + RECOVERY_IMG_NAME="recovery.img" else - cp -a boot.img "$RECOVERY_IMG_NAME" + RECOVERY_IMG_NAME="boot.img" fi + # Calculate sha256sum and move file sha256sum "$RECOVERY_IMG_NAME" > "$RECOVERY_IMG_NAME.sha256sum" - mv "$RECOVERY_IMG_NAME"* "$ZIP_DIR/$zipsubdir/" + mv "$RECOVERY_IMG_NAME" "$ZIP_DIR/$zipsubdir/" fi - fi done -- GitLab From e63a4f0d1528911966bb2b5d0fbe83c51e5356b0 Mon Sep 17 00:00:00 2001 From: Jackeagle Date: Tue, 1 Aug 2023 13:51:18 +0530 Subject: [PATCH 3/3] Dockerfile: Declare new flags and set default to false Added Flags: RECOVERY_NEEDS_DTBO_IMG RECOVERY_NEEDS_VBMETA_IMG RECOVERY_NEEDS_SUPER_IMG Signed-off-by: Jackeagle --- Dockerfile | 9 +++++++++ Dockerfile.community | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Dockerfile b/Dockerfile index 80535e7..f72404e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -106,6 +106,15 @@ ENV RECOVERY_NEEDS_SUPPORT_IMG false # Assume device does not use vendor_boot for recovery to boot by default. ENV RECOVERY_NEEDS_VENDOR_BOOT_IMG false +# Assume device does not use DTBO for recovery to boot by default. +ENV RECOVERY_NEEDS_DTBO_IMG false + +# Assume device does not use VBMETA for recovery to boot by default. +ENV RECOVERY_NEEDS_VBMETA_IMG false + +# Assume device does not use super_image for recovery to boot by default. +ENV RECOVERY_NEEDS_SUPER_IMG false + # Ship with Minimal Apps ENV MINIMAL_APPS false diff --git a/Dockerfile.community b/Dockerfile.community index b343e2a..159af97 100644 --- a/Dockerfile.community +++ b/Dockerfile.community @@ -105,6 +105,24 @@ ENV DELETE_OLD_ZIPS 0 # Delete old logs in $LOGS_DIR, keep only the N latest one (0 to disable) ENV DELETE_OLD_LOGS 0 +# Assume device does not use vendor_boot as recovery by default +ENV VBOOT_IS_RECOVERY false + +# Assume device does not need additional files for recovery to boot. +ENV RECOVERY_NEEDS_SUPPORT_IMG false + +# Assume device does not use vendor_boot for recovery to boot by default. +ENV RECOVERY_NEEDS_VENDOR_BOOT_IMG false + +# Assume device does not use DTBO for recovery to boot by default. +ENV RECOVERY_NEEDS_DTBO_IMG false + +# Assume device does not use VBMETA for recovery to boot by default. +ENV RECOVERY_NEEDS_VBMETA_IMG false + +# Assume device does not use super_image for recovery to boot by default. +ENV RECOVERY_NEEDS_SUPER_IMG false + # Force an eng build even when device name doesn't contain -eng ENV ENG_BUILD false -- GitLab