Increment ota
This commit is contained in:
parent
26d1df1466
commit
12888c8abf
2
package/third-party/swupdate/swupdate.config
vendored
2
package/third-party/swupdate/swupdate.config
vendored
@ -107,7 +107,7 @@ CONFIG_PARSERROOT=""
|
|||||||
# CONFIG_DISKPART is not set
|
# CONFIG_DISKPART is not set
|
||||||
CONFIG_RAW=y
|
CONFIG_RAW=y
|
||||||
# CONFIG_RDIFFHANDLER is not set
|
# CONFIG_RDIFFHANDLER is not set
|
||||||
# CONFIG_SHELLSCRIPTHANDLER is not set
|
CONFIG_SHELLSCRIPTHANDLER=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# archive support needs libarchive
|
# archive support needs libarchive
|
||||||
|
|||||||
Binary file not shown.
@ -266,6 +266,13 @@ function swupdate_pack_swu()
|
|||||||
|
|
||||||
mk_info "Pack swu ..."
|
mk_info "Pack swu ..."
|
||||||
|
|
||||||
|
# 生成 data 增量更新包(tar.gz),替代全量 ubifs 写入
|
||||||
|
local DATA_DIR="${TARGET_BOARD_DIR}/data"
|
||||||
|
if [ -d "$DATA_DIR" ]; then
|
||||||
|
mk_info "Generating data_update.tar.gz ..."
|
||||||
|
tar -czf "${BINARIES_DIR}/data_update.tar.gz" -C "$DATA_DIR" .
|
||||||
|
fi
|
||||||
|
|
||||||
. $SWU_IMAGES
|
. $SWU_IMAGES
|
||||||
|
|
||||||
cp "$SWU_IMAGES" "$SWU_DIR"
|
cp "$SWU_IMAGES" "$SWU_DIR"
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
demo128_nand-ota-marker=2026-04-27_v1001
|
demo128_nand-ota-marker=2026-06-03_v1003
|
||||||
|
|||||||
@ -104,10 +104,18 @@ software =
|
|||||||
sha256 = "@system";
|
sha256 = "@system";
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filename = "data";
|
filename = "data_update.tar.gz";
|
||||||
volume = "data";
|
type = "rawfile";
|
||||||
installed-directly = true;
|
path = "/tmp/data_update.tar.gz";
|
||||||
sha256 = "@data";
|
sha256 = "@data_update.tar.gz";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
scripts: (
|
||||||
|
{
|
||||||
|
filename = "update_data.sh";
|
||||||
|
type = "shellscript";
|
||||||
|
sha256 = "@update_data.sh";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,8 @@ ${BINARIES_DIR}/kernel.itb:kernel
|
|||||||
${BINARIES_DIR}/logo.itb:logo
|
${BINARIES_DIR}/logo.itb:logo
|
||||||
${BINARIES_DIR}/rootfs_page_2k_block_128k.ubifs:rootfs
|
${BINARIES_DIR}/rootfs_page_2k_block_128k.ubifs:rootfs
|
||||||
${BINARIES_DIR}/system_page_2k_block_128k.ubifs:system
|
${BINARIES_DIR}/system_page_2k_block_128k.ubifs:system
|
||||||
${BINARIES_DIR}/data_page_2k_block_128k.ubifs:data
|
${BINARIES_DIR}/data_update.tar.gz:data_update.tar.gz
|
||||||
|
${TARGET_BOARD_DIR}/swupdate/update_data.sh:update_data.sh
|
||||||
#${BINARIES_DIR}/rootfs_page_4k_block_256k.ubifs:rootfs
|
#${BINARIES_DIR}/rootfs_page_4k_block_256k.ubifs:rootfs
|
||||||
#${BINARIES_DIR}/system_page_4k_block_256k.ubifs:system
|
#${BINARIES_DIR}/system_page_4k_block_256k.ubifs:system
|
||||||
#${BINARIES_DIR}/data_page_4k_block_256k.ubifs:data
|
#${BINARIES_DIR}/data_page_4k_block_256k.ubifs:data
|
||||||
|
|||||||
63
target/d211/demo128_nand/swupdate/update_data.sh
Normal file
63
target/d211/demo128_nand/swupdate/update_data.sh
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# 增量更新 /data 分区
|
||||||
|
# swupdate 已将 data_update.tar.gz 写到 /tmp/data_update.tar.gz
|
||||||
|
|
||||||
|
# 只在 postinst 阶段执行(此时 rawfile 已经复制完成)
|
||||||
|
if [ "$1" = "preinst" ]; then
|
||||||
|
echo "[update_data] preinst: skip"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAR="/tmp/data_update.tar.gz"
|
||||||
|
SRC="/tmp/data_update_src"
|
||||||
|
DST="/mnt/data_update"
|
||||||
|
|
||||||
|
if [ ! -f "$TAR" ]; then
|
||||||
|
echo "[update_data] ERROR: $TAR not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 挂载 data 分区到临时挂载点
|
||||||
|
mkdir -p "$DST"
|
||||||
|
if ! mount -t ubifs ubi2:data "$DST"; then
|
||||||
|
echo "[update_data] ERROR: failed to mount ubi2:data"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "[update_data] mounted ubi2:data on $DST"
|
||||||
|
|
||||||
|
# 解压到临时目录
|
||||||
|
mkdir -p "$SRC"
|
||||||
|
tar -xzf "$TAR" -C "$SRC"
|
||||||
|
|
||||||
|
# 遍历升级包中的所有文件,只覆盖不一样的
|
||||||
|
find "$SRC" -type f | while read src_file; do
|
||||||
|
rel_path="${src_file#$SRC/}"
|
||||||
|
dst_file="$DST/$rel_path"
|
||||||
|
|
||||||
|
# 目标目录不存在则创建
|
||||||
|
dst_dir=$(dirname "$dst_file")
|
||||||
|
[ -d "$dst_dir" ] || mkdir -p "$dst_dir"
|
||||||
|
|
||||||
|
if [ -f "$dst_file" ]; then
|
||||||
|
src_md5=$(md5sum "$src_file" | cut -d' ' -f1)
|
||||||
|
dst_md5=$(md5sum "$dst_file" | cut -d' ' -f1)
|
||||||
|
if [ "$src_md5" = "$dst_md5" ]; then
|
||||||
|
echo "[update_data] unchanged: $rel_path"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp "$src_file" "$dst_file"
|
||||||
|
echo "[update_data] updated: $rel_path"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 清理临时文件
|
||||||
|
rm -rf "$SRC" "$TAR"
|
||||||
|
|
||||||
|
# 卸载 data 分区
|
||||||
|
sync
|
||||||
|
umount "$DST"
|
||||||
|
echo "[update_data] unmounted $DST"
|
||||||
|
|
||||||
|
echo "[update_data] done"
|
||||||
|
exit 0
|
||||||
Loading…
Reference in New Issue
Block a user