ar71xx: image: fix size verification in the CatFiles macro
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / image / Makefile
index 801fb4cf434a91212ae175d3721fc8e902951382..39e935d11b77b5bac96c08e4af7f90fa8ab09a1b 100644 (file)
@@ -141,13 +141,21 @@ define CatFiles
                        echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
                        rm -f $(5); \
                fi; \
-       else if [ $(2) -gt 262144 -a `stat -c%s "$(1)"` -gt $(2) ]; then \
-               echo "Warning: $(1) is too big (> $(2) bytes)" >&2; \
-       else if [ `stat -c%s $(3)` -gt $(4) ]; then \
-               echo "Warning: $(3) is too big (> $(4) bytes)" >&2; \
+       else if [ $(2) -gt 262144 ]; then \
+               if [ `stat -c%s "$(1)"` -gt $(2) ]; then \
+                       echo "Warning: $(1) is too big (> $(2) bytes)" >&2; \
+               else if [ `stat -c%s $(3)` -gt $(4) ]; then \
+                       echo "Warning: $(3) is too big (> $(4) bytes)" >&2; \
+               else \
+                       ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
+               fi; fi; \
        else \
                ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
-       fi; fi; fi
+               if [ `stat -c%s $(5)` -gt $(4) ]; then \
+                       echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
+                       rm -f $(5); \
+               fi; \
+       fi; fi
 endef
 
 Sysupgrade/KR=$(call CatFiles,$(2),$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(5)))
@@ -193,6 +201,7 @@ alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmw
 all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art)
 all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro
 ap81_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,5120k(rootfs),2688k(kernel),64k(art)ro,7808k@0x50000(firmware)
+ap83_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,4096k(rootfs),3648k(kernel),64k(art)ro,7744k@0x60000(firmware)
 ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k@0x40000(firmware)
 ap113_mtd_layout=mtdparts=spi0.0:64k(u-boot),3008k(rootfs),896k(uImage),64k(NVRAM),64k(ART),3904k@0x10000(firmware)
 ap121_mtdlayout_2M=mtdparts=spi0.0:64k(u-boot)ro,1216k(rootfs),704k(kernel),64k(art)ro,1920k@0x10000(firmware)
@@ -878,7 +887,7 @@ $(eval $(call SingleProfile,ALFA,64k,ALFANX,alfa-nx,ALFA-NX,ttyS0,115200,$$(alfa
 $(eval $(call SingleProfile,ALFA,64k,HORNETUB,hornet-ub,HORNET-UB,ttyATH0,115200,$$(alfa_mtdlayout_8M),1638400,6291456,kernel_image,rootfs_image))
 
 $(eval $(call SingleProfile,AthGzip,64k,AP81,ap81,AP81,ttyS0,115200,$$(ap81_mtdlayout),2752512,5242880,RKuImage))
-$(eval $(call SingleProfile,AthGzip,64k,AP83,ap83,AP83,ttyS0,115200,,1310720,6619136,KRuImage))
+$(eval $(call SingleProfile,AthGzip,64k,AP83,ap83,AP83,ttyS0,115200,$$(ap83_mtdlayout),3735552,4194304,RKuImage))
 $(eval $(call SingleProfile,AthGzip,64k,AP96,ap96,AP96,ttyS0,115200,$$(ap96_mtdlayout),1769472,6291456,RKuImage))
 
 $(eval $(call SingleProfile,AthLzma,64k,ALFAAP96,alfa-ap96,ALFA-AP96,ttyS0,115200,$$(alfa_ap96_mtdlayout),2097152,13631488,RKuImage))