1 DEVICE_VARS
+= SENAO_IMGNAME
3 # This needs to make /tmp/_sys/sysupgrade.tgz an empty file prior to
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
11 touch
$@.tmp
/failsafe.bin
&& \
12 echo
'#!/bin/sh' > $@.tmp
/before-upgrade.sh
&& \
13 echo
': > /tmp/_sys/sysupgrade.tgz' >> $@.tmp
/before-upgrade.sh
&& \
14 echo
-n
$$(( $$(cat
$@ | wc
-c
) / 4096 * 4096 )) > $@.len
&& \
15 dd if
=$@ bs
=$$(cat
$@.len
) count
=1 | md5sum
- | cut
-d
' ' -f
1 > $@.md5
&& \
16 echo
'#!/bin/sh' > $@.tmp
/after-upgrade.sh
&& \
17 printf
'fw_setenv rootfs_size 0x%08x\n' $$(cat
$@.len
) >> $@.tmp
/after-upgrade.sh
&& \
18 printf
'fw_setenv rootfs_checksum %s\n' $$(cat
$@.md5
) >> $@.tmp
/after-upgrade.sh
&& \
19 $(CP
) $(KDIR
)/loader-
$(DEVICE_NAME
).uImage \
20 $@.tmp
/openwrt-
$(word 1,$(1))-uImage-lzma.bin
&& \
21 $(CP
) $@
$@.tmp
/openwrt-
$(word 1,$(1))-root.squashfs
&& \
22 $(TAR
) -cp
--numeric-owner
--owner
=0 --group
=0 --mode
=a-s
--sort=name \
23 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)") \
24 -C
$@.tmp . | gzip
-9n
> $@
&& \
25 rm -rf
$@.tmp
$@.len
$@.md5
28 define Device
/senao_loader_okli
29 KERNEL
:= kernel-bin | append-dtb | lzma | uImage lzma
-M
0x73714f4b
30 LOADER_KERNEL_MAGIC
:= 0x73714f4b
32 COMPILE
:= loader-
$(1).bin loader-
$(1).uImage
33 COMPILE
/loader-
$(1).bin
:= loader-okli-compile
34 COMPILE
/loader-
$(1).uImage
:= append-loader-okli
$(1) | pad-to
64k | lzma | \
37 IMAGE
/factory.bin
:= append-kernel | pad-to
$$$$(BLOCKSIZE
) | append-rootfs | pad-rootfs | \
38 check-size | senao-tar-gz
$$$$(SENAO_IMGNAME
)
39 IMAGE
/sysupgrade.bin
:= $$(IMAGE
/factory.bin
) | append-metadata