contrib/package/sysupgrade-atheros: add more sanity checks
This commit is contained in:
parent
c6a29c1a08
commit
35874fad2b
2 changed files with 23 additions and 11 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,6 +27,7 @@ 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%% *}"
|
||||
|
||||
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"
|
||||
|
||||
|
@ -29,4 +40,5 @@ platform_do_upgrade() {
|
|||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue