target/linux/*/base-files/lib/upgrade/platform.sh - wrong check for ARGC
ARGC is a 'C-ism', but not known/valid in shell-syntax - insert the correct var $# (=number of args) here. under normal conditions this had no impact, but we should at least correct it. the error was observable like this: root@box:~ [ -e "/etc/functions.sh" ] && . /etc/functions.sh root@box:~ [ -e "/lib/functions.sh" ] && . /lib/functions.sh root@box:~ . /lib/upgrade/platform.sh root@box:~ . /lib/upgrade/common.sh root@box:~ platform_check_image /tmp/myfirmware.bin ash: bad number root@box:~ echo $? 0 Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com> SVN-Revision: 40915
This commit is contained in:
		@@ -10,7 +10,7 @@ RAMFS_COPY_DATA=/lib/adm5120.sh
 | 
				
			|||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	local magic="$(get_magic_word "$1")"
 | 
						local magic="$(get_magic_word "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board_name" in
 | 
						case "$board_name" in
 | 
				
			||||||
	"ZyXEL"*|"Compex WP54 family")
 | 
						"ZyXEL"*|"Compex WP54 family")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
PART_NAME=linux
 | 
					PART_NAME=linux
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		# u-boot
 | 
							# u-boot
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -111,7 +111,7 @@ platform_check_image() {
 | 
				
			|||||||
	local magic="$(get_magic_word "$1")"
 | 
						local magic="$(get_magic_word "$1")"
 | 
				
			||||||
	local magic_long="$(get_magic_long "$1")"
 | 
						local magic_long="$(get_magic_long "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	all0315n | \
 | 
						all0315n | \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ platform_find_kernelpart() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		# Combined Image
 | 
							# Combined Image
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ KERNEL_IMG="openwrt-au1000-au1500-vmlinux.bin"
 | 
				
			|||||||
ROOTFS_IMG="openwrt-au1000-au1500-root.fs"
 | 
					ROOTFS_IMG="openwrt-au1000-au1500-root.fs"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		6f70)
 | 
							6f70)
 | 
				
			||||||
			( get_image "$1" | tar -tf - $KERNEL_IMG >/dev/null && \
 | 
								( get_image "$1" | tar -tf - $KERNEL_IMG >/dev/null && \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ PART_NAME=firmware
 | 
				
			|||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	local magic="$(get_magic_long "$1")"
 | 
						local magic="$(get_magic_long "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$magic" != "27051956" ] && {
 | 
						[ "$magic" != "27051956" ] && {
 | 
				
			||||||
		echo "Invalid image type."
 | 
							echo "Invalid image type."
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
PART_NAME=firmware
 | 
					PART_NAME=firmware
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		# .trx files
 | 
							# .trx files
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
PART_NAME=linux
 | 
					PART_NAME=linux
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		3600|3700|3800)
 | 
							3600|3700|3800)
 | 
				
			||||||
			# 6348GW-11 boards use openwrt-96348GW-11-squashfs-cfe.bin files
 | 
								# 6348GW-11 boards use openwrt-96348GW-11-squashfs-cfe.bin files
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ platform_check_image() {
 | 
				
			|||||||
	local board=$(get_board_name)
 | 
						local board=$(get_board_name)
 | 
				
			||||||
	local magic="$(get_magic_word "$1")"
 | 
						local magic="$(get_magic_word "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	nsb3ast)
 | 
						nsb3ast)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,7 @@ platform_check_image() {
 | 
				
			|||||||
	local magic="$(get_magic_word "$1")"
 | 
						local magic="$(get_magic_word "$1")"
 | 
				
			||||||
	local magic_long="$(get_magic_long "$1")"
 | 
						local magic_long="$(get_magic_long "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	laguna)
 | 
						laguna)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,7 +93,7 @@ platform_check_image() {
 | 
				
			|||||||
	local kern_part_size=0x$(platform_find_part_size "$kernelpart")
 | 
						local kern_part_size=0x$(platform_find_part_size "$kernelpart")
 | 
				
			||||||
	local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
 | 
						local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	avila | cambria )
 | 
						avila | cambria )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
PART_NAME=firmware
 | 
					PART_NAME=firmware
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		# uImage
 | 
							# uImage
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ platform_check_image() {
 | 
				
			|||||||
	local board=$(mpc85xx_board_name)
 | 
						local board=$(mpc85xx_board_name)
 | 
				
			||||||
	local magic="$(get_magic_long "$1")"
 | 
						local magic="$(get_magic_long "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case $board in
 | 
						case $board in
 | 
				
			||||||
	tl-wdr4900-v1)
 | 
						tl-wdr4900-v1)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ platform_check_image() {
 | 
				
			|||||||
	local board=$(ppc40x_board_name)
 | 
						local board=$(ppc40x_board_name)
 | 
				
			||||||
	local magic="$(get_magic_word "$1")"
 | 
						local magic="$(get_magic_word "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	kilauea | openrb | magicbox)
 | 
						kilauea | openrb | magicbox)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ platform_check_image() {
 | 
				
			|||||||
	local board=$(ramips_board_name)
 | 
						local board=$(ramips_board_name)
 | 
				
			||||||
	local magic="$(get_magic_long "$1")"
 | 
						local magic="$(get_magic_long "$1")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$board" in
 | 
						case "$board" in
 | 
				
			||||||
	3g-6200n | \
 | 
						3g-6200n | \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ x86_get_rootfs() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		eb48|eb63) return 0;;
 | 
							eb48|eb63) return 0;;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		48eb) return 0;;
 | 
							48eb) return 0;;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ x86_get_rootfs() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
platform_check_image() {
 | 
					platform_check_image() {
 | 
				
			||||||
	[ "$ARGC" -gt 1 ] && return 1
 | 
						[ "$#" -gt 1 ] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case "$(get_magic_word "$1")" in
 | 
						case "$(get_magic_word "$1")" in
 | 
				
			||||||
		eb48|eb63) return 0;;
 | 
							eb48|eb63) return 0;;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user