Skip to content

Instantly share code, notes, and snippets.

@mcprat
Created May 23, 2020 18:56
Show Gist options
  • Save mcprat/8e38ada88b3a7d8bd6d406621e13982d to your computer and use it in GitHub Desktop.
Save mcprat/8e38ada88b3a7d8bd6d406621e13982d to your computer and use it in GitHub Desktop.
factory.bin common image commands idea
For device profile:
IMAGE/factory.bin := append-squashfs-fakeroot-be | pad-to $$$$(BLOCKSIZE) | \
$$(IMAGE/sysupgrade.bin) | tmpdir tmp | \
tmpdir-loader $(1) tmp/openwrt-senao-ens202ext-uImage-lzma.bin | \
tmpdir-cp tmp/openwrt-senao-ens202ext-root.squashfs | \
tmpdir-tar tmp | tmpdir-rm tmp | gzip
in include/image-commands.mk:
define Build/tmpdir
mkdir -p $@.$(1)
endef
define Build/tmpdir-rm
rm -rf $@.$(1)
endef
define Build/tmpdir-touch
touch $@.$(1)
endef
define Build/tmpdir-loader
$(CP) $(KDIR)/loader-$(word 1, $(1)).uImage $@.$(word 2, $(1))
endef
define Build/tmpdir-kernel
$(CP) $(IMAGE_KERNEL) $@.$(1)
endef
define Build/tmpdir-rootfs
$(CP) $(IMAGE_ROOTFS) $@.$(1)
endef
define Build/tmpdir-cp
$(CP) $@ $@.$(1)
endef
define Build/tmpdir-tar
$(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
-C $@.$(1) . > [email protected]
@mv [email protected] $@
endef
define Build/prepend-header
$(CP) $@ [email protected]
$(CP) $(1) [email protected]
cat [email protected] >> [email protected]
@mv [email protected] $@
endef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment