summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-06-23 19:17:53 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-06-23 19:17:53 +0000
commit35874fad2b140e7bab2609051dc9ed3eb27848f1 (patch)
tree252e4ff13718bb93eec5dd2935fd2a70a0029d43 /contrib
parentc6a29c1a08f3e6bfcf5550a8428d7f444b2c1498 (diff)
contrib/package/sysupgrade-atheros: add more sanity checks
Diffstat (limited to 'contrib')
-rw-r--r--contrib/package/sysupgrade-atheros/Makefile2
-rw-r--r--contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh32
2 files changed, 23 insertions, 11 deletions
diff --git a/contrib/package/sysupgrade-atheros/Makefile b/contrib/package/sysupgrade-atheros/Makefile
index 7b20d8537..1a76c02d4 100644
--- a/contrib/package/sysupgrade-atheros/Makefile
+++ b/contrib/package/sysupgrade-atheros/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sysupgrade-atheros
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
diff --git a/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh
index 87a324810..2a8c31def 100644
--- a/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh
+++ b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh
@@ -3,7 +3,17 @@ platform_check_image() {
case "$(get_magic_word "$1")" in
# Freifunk .img files
- 4646) return 0;;
+ 4646)
+ local kern_name=$(dd if="$1" bs=2 skip=5 count=8 2>/dev/null); kern_name="${kern_name%% *}"
+ local root_name=$(dd if="$1" bs=2 skip=17 count=8 2>/dev/null); root_name="${root_name%% *}"
+
+ if grep -q '"'$kern_name'"' /proc/mtd && grep -q '"'$root_name'"' /proc/mtd; then
+ return 0
+ else
+ echo "Invalid image. Missing the '$kern_name' or '$root_name' partition"
+ return 1
+ fi
+ ;;
*)
echo "Invalid image. Use Freifunk .img files on this platform"
return 1
@@ -17,16 +27,18 @@ platform_do_upgrade() {
local root_length=$((0x$(dd if="$1" bs=2 skip=13 count=4 2>/dev/null)/65536))
local root_name=$(dd if="$1" bs=2 skip=17 count=8 2>/dev/null); root_name="${root_name%% *}"
- local append=""
- [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
+ if grep -q '"'$kern_name'"' /proc/mtd && grep -q '"'$root_name'"' /proc/mtd; then
+ local append=""
+ [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
- if [ -n "$kern_name" -a -n "$root_name" ] && \
- [ ${kern_length:-0} -gt 0 -a ${root_length:-0} -gt ${kern_length:-0} ];
- then
- dd if="$1" bs=65536 skip=1 count=$kern_length 2>/dev/null | \
- mtd -e $kern_name write - $kern_name
+ if [ -n "$kern_name" -a -n "$root_name" ] && \
+ [ ${kern_length:-0} -gt 0 -a ${root_length:-0} -gt ${kern_length:-0} ];
+ then
+ dd if="$1" bs=65536 skip=1 count=$kern_length 2>/dev/null | \
+ mtd -e $kern_name write - $kern_name
- dd if="$1" bs=65536 skip=$((1+$kern_length)) count=$root_length 2>/dev/null | \
- mtd -e $root_name $append write - $root_name
+ dd if="$1" bs=65536 skip=$((1+$kern_length)) count=$root_length 2>/dev/null | \
+ mtd -e $root_name $append write - $root_name
+ fi
fi
}