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