[OpenWrt-Devel] base-files: exit if mtd write command fails during sysupgrade

Message ID 20180611105242.31637-1-zajec5@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series
  • [OpenWrt-Devel] base-files: exit if mtd write command fails during sysupgrade
Related show

Commit Message

Rafał Miłecki June 11, 2018, 10:52 a.m.
From: Rafał Miłecki <rafal@milecki.pl>

It avoids confusing situations like:
> Could not get image magic
> Image check failed.
> Upgrade completed
> Rebooting system...

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 package/base-files/files/lib/upgrade/common.sh | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index 5f5c9dc8a3..2305bbea19 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -222,6 +222,7 @@  default_do_upgrade() {
 	else
 		get_image "$1" "$2" | mtd write - "${PART_NAME:-image}"
 	fi
+	[ $? -ne 0 ] && exit 1
 }
 
 do_upgrade_stage2() {