From ef6b6059610678983d779fe9db825d5363e45492 Mon Sep 17 00:00:00 2001 From: ading2210 Date: Tue, 30 Jan 2024 22:25:45 +0000 Subject: [PATCH] retry build stages if failed --- .github/workflows/build-image.yaml | 2 +- build_complete.sh | 11 +++++++++-- image_utils.sh | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 3772f34..f3002bc 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: run build - run: sudo DEBUG=1 ./build_complete.sh ${{ matrix.board }} compress_img=1 quiet_download=1 + run: sudo DEBUG=1 ./build_complete.sh ${{ matrix.board }} compress_img=1 quiet=1 - name: upload img uses: actions/upload-artifact@v4 diff --git a/build_complete.sh b/build_complete.sh index 59477d0..d6527a7 100755 --- a/build_complete.sh +++ b/build_complete.sh @@ -93,6 +93,13 @@ download_and_unzip() { fi } +retry_cmd() { + local cmd="$@" + for i in 1 2 3 4 5; do + $cmd && break + done +} + echo "downloading recovery image" download_and_unzip $reco_url $reco_zip $reco_bin @@ -115,12 +122,12 @@ else fi echo "patching debian rootfs" -./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=${args['quiet']}" +retry_cmd ./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=${args['quiet']}" echo "building final disk image" final_image="$base_dir/data/shimboot_$board.bin" rm -rf $final_image -./build.sh $final_image $shim_bin $rootfs_dir +retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=${args['quiet']}" echo "build complete! the final disk image is located at $final_image" if [ "${args['compress_img']}" ]; then diff --git a/image_utils.sh b/image_utils.sh index b95d807..5847696 100755 --- a/image_utils.sh +++ b/image_utils.sh @@ -69,7 +69,7 @@ safe_mount() { rm -rf $2 mkdir -p $2 #try to mount multiple times - mount $1 $2 || mount $1 $2 || mount $1 $2 || mount $1 $2 + mount $1 $2 } create_partitions() {