2 # Copyright (C) 2016 lede-project.org
8 if read cmdline
< /proc
/cmdline
; then
11 rootfsdev
="${cmdline##*root=}"
12 rootfsdev
="${rootfsdev%% *}"
25 # keep sure its unbound
26 losetup
--detach-all ||
{
27 echo Failed to detach all loop devices. Skip this try.
31 # use the first found directory in the tar archive
32 local board_dir
=$
(tar tf
$tar_file |
grep -m 1 '^sysupgrade-.*/$')
33 board_dir
=${board_dir%/}
35 echo "flashing kernel to $kernel"
36 tar xf
$tar_file ${board_dir}/kernel
-O >$kernel
38 echo "flashing rootfs to ${rootfs}"
39 tar xf
$tar_file ${board_dir}/root
-O >"${rootfs}"
41 # a padded rootfs is needed for overlay fs creation
42 local offset
=$
(tar xf
$tar_file ${board_dir}/root
-O |
wc -c)
43 [ $offset -lt 65536 ] && {
44 echo Wrong size
for rootfs
: $offset
49 # Mount loop for rootfs_data
50 losetup
-o $offset /dev
/loop0
"${rootfs}" ||
{
51 echo "Failed to mount looped rootfs_data."
56 echo "Format new rootfs_data at position ${offset}."
57 mkfs.ext4
-F -L rootfs_data
/dev
/loop0
59 mount
-t ext4
/dev
/loop0
/tmp
/new_root
&& {
60 echo "Saving config to rootfs_data at position ${offset}."
61 cp -v /tmp
/sysupgrade.tgz
/tmp
/new_root
/
66 losetup
-d /dev
/loop0
>/dev
/null
2>&1
74 local board
=$
(board_name
)
75 local rootfs
="$(zyxel_get_rootfs)"
78 [ -b "${rootfs}" ] ||
return 1
83 kernel
="/dev/mmcblk0p4"
86 kernel
="/dev/mmcblk0p7"
98 zyxel_do_flash
$tar_file $kernel $rootfs