build: add image makefile helper function for pading with an offset
authorFelix Fietkau <nbd@openwrt.org>
Sat, 17 Jan 2015 21:19:24 +0000 (21:19 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 17 Jan 2015 21:19:24 +0000 (21:19 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 44012

include/image.mk

index e64020132fac4c428b0377b5ba64d11c3be34bc8..06feef55163d22c129e6152f335cdbaaeba2e7c4 100644 (file)
@@ -307,6 +307,17 @@ define Build/pad-rootfs
        $(call prepare_generic_squashfs,$@)
 endef
 
+define Build/pad-offset
+       let \
+               size="$$(stat -c%s $@)" \
+               pad="$(word 1, $(1))" \
+               offset="$(word 2, $(1))" \
+               pad="(pad - ((size + offset) % pad)) % pad" \
+               newsize='size + pad'; \
+               dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync
+       mv $@.new $@
+endef
+
 define Build/check-size
        @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -gt "$$(stat -c%s $@)" ] || { \
                echo "WARNING: Image file $@ is too big"; \