diff --git a/Dockerfile b/Dockerfile index 80535e7987adc593e2dfd52b8d49acf123e95224..f72404e1685b05132afa49c994b39c8acd2dfbe3 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 b343e2a1cf4ff8e5ce5faaf9a44405b0e6e098f4..159af972edcb47ba3b69f5d0eed61fbf00442951 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 diff --git a/src/build.sh b/src/build.sh index c9599f995ea8e4d2cfc0f38c006b65a649b38f54..6e57bfe702f39cb804eb5cda0d2496a1b86d7cf3 100755 --- a/src/build.sh +++ b/src/build.sh @@ -317,45 +317,68 @@ 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" - - 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 - - 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/" + RECOVERY_IMG_NAME="recovery-${build%.*}.img" + RECOVERY_ZIP_NAME="recovery-IMG-${build%.*}.zip" + + if [ "$RECOVERY_NEEDS_SUPPORT_IMG" = true ]; then + # 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" + elif [ -f "recovery.img" ]; then + cp -a recovery.img "$RECOVERY_IMG_NAME" + else + cp -a boot.img "$RECOVERY_IMG_NAME" + fi + + # 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 + 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/" + 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 + RECOVERY_IMG_NAME="recovery.img" + else + 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/" + fi fi done @@ -434,3 +457,4 @@ fi if [ "$build_successful" = false ] || [ "$sync_successful" = false ]; then exit 1 fi +