common-senao.mk 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. DEVICE_VARS += SENAO_IMGNAME WATCHGUARD_MAGIC
  2. # This needs to make OEM config archive 'sysupgrade.tgz' an empty file prior to OEM
  3. # sysupgrade, as otherwise it will implant the old configuration from
  4. # OEM firmware when writing rootfs from factory.bin
  5. # rootfs size and checksum is taken from a squashfs header
  6. # the header does not exist, therefore, supply the size and md5
  7. define Build/senao-tar-gz
  8. -[ -f "$@" ] && \
  9. mkdir -p [email protected] && \
  10. touch [email protected]/failsafe.bin && \
  11. touch [email protected]/FWINFO-$(word 1,$(1))-$(REVISION) && \
  12. echo '#!/bin/sh' > [email protected]/before-upgrade.sh && \
  13. echo ': > /tmp/sysupgrade.tgz' >> [email protected]/before-upgrade.sh && \
  14. echo ': > /tmp/_sys/sysupgrade.tgz' >> [email protected]/before-upgrade.sh && \
  15. echo -n $$(( $$(cat $@ | wc -c) / 4096 * 4096 )) > [email protected] && \
  16. dd if=$@ bs=$$(cat [email protected]) count=1 | md5sum - | cut -d ' ' -f 1 > [email protected] && \
  17. echo '#!/bin/sh' > [email protected]/after-upgrade.sh && \
  18. printf 'fw_setenv rootfs_size 0x%08x\n' $$(cat [email protected]) >> [email protected]/after-upgrade.sh && \
  19. printf 'fw_setenv rootfs_checksum %s\n' $$(cat [email protected]) >> [email protected]/after-upgrade.sh && \
  20. $(CP) $(KDIR)/loader-$(DEVICE_NAME).uImage \
  21. [email protected]/openwrt-$(word 1,$(1))-uImage-lzma.bin && \
  22. $(CP) $@ [email protected]/openwrt-$(word 1,$(1))-root.squashfs && \
  23. $(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
  24. $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
  25. -C [email protected] . | gzip -9n > $@ && \
  26. rm -rf [email protected] [email protected] [email protected]
  27. endef
  28. define Build/watchguard-cksum
  29. -echo -n $(word 1,$(1)) | cat $@ - | md5sum | \
  30. cut -d ' ' -f1 | tr -d '\n' > [email protected] && \
  31. cat [email protected] >> $@ && \
  32. rm -rf [email protected]
  33. endef
  34. define Device/senao_loader_okli
  35. $(Device/loader-okli-uimage)
  36. KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x73714f4b
  37. KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
  38. LOADER_KERNEL_MAGIC := 0x73714f4b
  39. IMAGES += factory.bin
  40. IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \
  41. check-size | senao-tar-gz $$$$(SENAO_IMGNAME)
  42. IMAGE/sysupgrade.bin := $$(IMAGE/factory.bin) | append-metadata
  43. endef