- dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs bs=1024k conv=sync; \
- dd if=$(KDIR)/root.$(1) bs=64k; \
- ) > $(call imgname,$(1),$(2))-sysupgrade.bin
- $(STAGING_DIR_HOST)/bin/mkdniimg \
- -B WNDR3700 -v OpenWrt.$(REVISION) \
- -i $(call imgname,$(1),$(2))-sysupgrade.bin \
- -o $(call imgname,$(1),$(2))-factory.img
+ set -e; \
+ kk=`echo '$(3)' | sed -e 's/.*[:,]\([0-9]*\)k(kernel).*/\1/'`; \
+ rk=`echo '$(3)' | sed -e 's/.*[:,]\([0-9]*\)k(rootfs).*/\1/'`; \
+ let 'tk = kk + rk'; \
+ s=`stat -c'%s' '$(KDIR)/vmlinux-$(1)_est.uImage.squashfs'`; \
+ c=`echo '$(3)' | wc -c`; \
+ let 'kk = (((s + c) / (64 * 1024) + 1) * 64)'; \
+ let 'rk = tk - kk'; \
+ echo '$(3)' | sed -e "s/[0-9]*k(kernel)/$$$${kk}k(kernel)/" \
+ -e "s/[0-9]*k(rootfs)/$$$${rk}k(rootfs)/" > \
+ '$(KDIR)/$(1)_mtdparts'; \
+ let 'k = kk * 1024'; \
+ echo "$$$${k}" > '$(KDIR)/$(1)_kernel_maxsize'; \
+ let 'r = rk * 1024'; \
+ echo "$$$${r}" > '$(KDIR)/$(1)_rootfs_maxsize'; \
+ )
+ -rm -f $(KDIR)/vmlinux-$(1)_est \
+ $(KDIR)/vmlinux-$(1)_est.bin.lzma \
+ $(KDIR)/vmlinux-$(1)_est.uImage \
+ $(KDIR)/vmlinux-$(1)_est.uImage.squashfs
+endef
+
+define Image/Build/Netgear
+ $(call Image/Build/Netgear/Estimate_uImage,$(2),$(3),$(4),$(5))
+ $(call Image/Build/Netgear/Build_uImage,$(2),$(3),`cat $(KDIR)/$(2)_mtdparts`,$(5))
+ if [ `stat -c%s '$(KDIR)/vmlinux-$(2).uImage.squashfs'` -gt \
+ `cat '$(KDIR)/$(2)_kernel_maxsize'` ]; then \
+ echo "$(KDIR)/vmlinux-$(2).uImage.squashfs is too big" >& 2; \
+ else if [ `stat -c%s '$(KDIR)/root.$(1)'` -gt \
+ `cat '$(KDIR)/$(2)_rootfs_maxsize'` ]; then \
+ echo "$(KDIR)/root.$(1) is too big" >& 2; \
+ else \
+ ( \
+ set -e; \
+ dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs \
+ bs=`cat '$(KDIR)/$(2)_kernel_maxsize'` conv=sync; \
+ dd if=$(KDIR)/root.$(1) bs=64k; \
+ ) > $(call sysupname,$(1),$(2)); \
+ for r in $(7) ; do \
+ [ -n "$$$$r" ] && dashr="-$$$$r" || dashr= ; \
+ $(STAGING_DIR_HOST)/bin/mkdniimg \
+ -B $(6) -v OpenWrt.$(REVISION) -r "$$$$r" $(8) \
+ -i $(call sysupname,$(1),$(2)) \
+ -o $(call imgname,$(1),$(2))-factory$$$$dashr.img; \
+ done; \
+ fi; fi
+endef
+
+define Image/Build/Netgear/initramfs
+ $(call MkuImageLzma,$(2),$(3) $($(4)))
+ $(STAGING_DIR_HOST)/bin/wndr3700 \
+ $(KDIR)/vmlinux-$(2).uImage \
+ $(call imgname,$(1),$(2))-uImage.bin \
+ $(5)