From 01b4d7efac9c424e66a9a1979d6b1c08d8d590eb Mon Sep 17 00:00:00 2001 From: Maslov Nikita Date: Tue, 2 May 2023 19:07:47 +0600 Subject: [PATCH] do not fail during rootfs build explicitly (#94) --- debian/changelog | 6 +++++ debian/postinst | 68 +++++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3fba5fa..1b903c5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wb-utils (4.9.4) stable; urgency=medium + + * do not fail during rootfs build explicitly + + -- Nikita Maslov Tue, 02 May 2023 18:50:48 +0600 + wb-utils (4.9.3) stable; urgency=medium * replace broken factory reset fit during installation diff --git a/debian/postinst b/debian/postinst index a121a57..c41772d 100755 --- a/debian/postinst +++ b/debian/postinst @@ -15,38 +15,42 @@ wb_source "of" if of_machine_match "wirenboard,wirenboard-720"; then # replace broken factoryreset FITs FACTORYRESET_FIT="/mnt/data/.wb-restore/factoryreset.fit" - FACTORYRESET_SHA256="$(sha256sum "$FACTORYRESET_FIT" | awk '{print $1}')" - - BROKEN_STABLE_FITS=( - "7ca056ba02c24f882283d16a0c0ee4cc2c0a92cd509fabb89021cb5305b61a3a" - "9ef0b4ac68d0c839a6ee59788a6230a3a21988472b006a6e37f4f1b6cfe73cc7" - "82618e593e59fa571c298d64e596188df5877ead0207a9611eee1a5c4f5036d9" - "b5e21070b69a0a258471c12f199f5f52c4d455b0cc5fbed7c4d2b055b21beccb" - ) - - BROKEN_TESTING_FITS=( - "edd8d2735dbd3d7b616eea64fab6ff4acf7c3729e27a4085576d60c843b280b1" - ) - - download_fixed_fit() { - URL="$1" - shift - for broken in "$@"; do - if [[ "$FACTORYRESET_SHA256" == "$broken" ]]; then - echo "Broken factory FIT found, downloading a working one" - wget -O "${FACTORYRESET_FIT}.new" "${URL}?broken&from=${FACTORYRESET_SHA256}&serial=$(wb-gen-serial -s)" - mv "${FACTORYRESET_FIT}.new" "$FACTORYRESET_FIT" - sync - break - fi - done - } - - STABLE_FIT_URL="https://fw-releases.wirenboard.com/fit_image/stable/7x/latest.fit" - download_fixed_fit "$STABLE_FIT_URL" "${BROKEN_STABLE_FITS[@]}" - - TESTING_FIT_URL="https://fw-releases.wirenboard.com/fit_image/testing/7x/latest.fit" - download_fixed_fit "$TESTING_FIT_URL" "${BROKEN_TESTING_FITS[@]}" + + # do not fail during rootfs build + if [ -e "$FACTORYRESET_FIT" ]; then + FACTORYRESET_SHA256="$(sha256sum "$FACTORYRESET_FIT" | awk '{print $1}')" + + BROKEN_STABLE_FITS=( + "7ca056ba02c24f882283d16a0c0ee4cc2c0a92cd509fabb89021cb5305b61a3a" + "9ef0b4ac68d0c839a6ee59788a6230a3a21988472b006a6e37f4f1b6cfe73cc7" + "82618e593e59fa571c298d64e596188df5877ead0207a9611eee1a5c4f5036d9" + "b5e21070b69a0a258471c12f199f5f52c4d455b0cc5fbed7c4d2b055b21beccb" + ) + + BROKEN_TESTING_FITS=( + "edd8d2735dbd3d7b616eea64fab6ff4acf7c3729e27a4085576d60c843b280b1" + ) + + download_fixed_fit() { + URL="$1" + shift + for broken in "$@"; do + if [[ "$FACTORYRESET_SHA256" == "$broken" ]]; then + echo "Broken factory FIT found, downloading a working one" + wget -O "${FACTORYRESET_FIT}.new" "${URL}?broken&from=${FACTORYRESET_SHA256}&serial=$(wb-gen-serial -s)" + mv "${FACTORYRESET_FIT}.new" "$FACTORYRESET_FIT" + sync + break + fi + done + } + + STABLE_FIT_URL="https://fw-releases.wirenboard.com/fit_image/stable/7x/latest.fit" + download_fixed_fit "$STABLE_FIT_URL" "${BROKEN_STABLE_FITS[@]}" + + TESTING_FIT_URL="https://fw-releases.wirenboard.com/fit_image/testing/7x/latest.fit" + download_fixed_fit "$TESTING_FIT_URL" "${BROKEN_TESTING_FITS[@]}" + fi fi exit 0