diff mbox series

[2/2] check-toolchain-clean.sh: workaround stray rebuilds

Message ID 20220225104544.23933-2-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series [1/2] check-toolchain-clean.sh: fix shellcheck warnings | expand

Commit Message

Petr Štetiar Feb. 25, 2022, 10:45 a.m. UTC
It seems, that there are currently some unhandled corner cases in which
`.toolchain_build_ver` results in empty file and thus forcing rebuilds,
even if the toolchain was build correctly just a few moments ago. Until
proper fix is found, workaround that by checking for this corner case
and simply populate `.toolchain_build_ver` file.

While at it, improve the UX and display version mismatch, so it's more
clear what has forced the rebuild:

 "Toolchain build version changed (11.2.0-1 != ), running make targetclean"

References: https://gitlab.com/ynezz/openwrt/-/jobs/2133332533/raw
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 scripts/check-toolchain-clean.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/check-toolchain-clean.sh b/scripts/check-toolchain-clean.sh
index 34b82dec5d22..455cfb0449f3 100755
--- a/scripts/check-toolchain-clean.sh
+++ b/scripts/check-toolchain-clean.sh
@@ -2,8 +2,13 @@ 
 eval "$(grep CONFIG_GCC_VERSION .config)"
 CONFIG_TOOLCHAIN_BUILD_VER="$CONFIG_GCC_VERSION-$(cat toolchain/build_version)"
 touch .toolchain_build_ver
-[ "$CONFIG_TOOLCHAIN_BUILD_VER" = "$(cat .toolchain_build_ver)" ] && exit 0
-echo "Toolchain build version changed, running make targetclean"
+CURRENT_TOOLCHAIN_BUILD_VER="$(cat .toolchain_build_ver)"
+[ -z "$CURRENT_TOOLCHAIN_BUILD_VER" ] && {
+	echo "$CONFIG_TOOLCHAIN_BUILD_VER" > .toolchain_build_ver
+	exit 0
+}
+[ "$CONFIG_TOOLCHAIN_BUILD_VER" = "$CURRENT_TOOLCHAIN_BUILD_VER" ] && exit 0
+echo "Toolchain build version changed ($CONFIG_TOOLCHAIN_BUILD_VER != $CURRENT_TOOLCHAIN_BUILD_VER), running make targetclean"
 make targetclean
 echo "$CONFIG_TOOLCHAIN_BUILD_VER" > .toolchain_build_ver
 exit 0