diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-03-31 14:19:16 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-03-31 16:54:14 +0100 |
commit | 7043e4334f0e751143b128dd695dc196d044fc1f (patch) | |
tree | e8a0a3de6c168fd21840f748618e7056ebf3fc03 /target | |
parent | bb107ad9c13d244bf4aed255da913d6000c28833 (diff) | |
download | upstream-7043e4334f0e751143b128dd695dc196d044fc1f.tar.gz upstream-7043e4334f0e751143b128dd695dc196d044fc1f.tar.bz2 upstream-7043e4334f0e751143b128dd695dc196d044fc1f.zip |
mediatek: mt7622: improve sysupgrade on MMC
Use generic functions to acquire rootdev.
Make sure to wipe rootfs_data in case of '-n'.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target')
-rwxr-xr-x | target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh | 61 |
1 files changed, 12 insertions, 49 deletions
diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh index 97a492c7fb..2c1460650f 100755 --- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh @@ -2,59 +2,24 @@ REQUIRE_IMAGE_METADATA=1 RAMFS_COPY_BIN='fw_printenv fw_setenv blockdev' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' -get_cmdline_var() { - local var=$1 - local cmdlinevar tmp - local cmdline="$(cat /proc/cmdline)" - - for cmdlinevar in $cmdline; do - tmp=${cmdlinevar##${var}} - [ "=" = "${tmp:0:1}" ] && echo ${tmp:1} - done -} - -get_rootdev() { - local rootvol rootdev - rootvol=$(get_cmdline_var root) - rootvol=$(basename $rootvol) - [ -e /sys/class/block/$rootvol ] || { - rootvol=${rootvol%%[0-9]} - [ -e /sys/class/block/$rootvol ] && echo $rootvol - rootvol=${rootvol%%p} - [ -e /sys/class/block/$rootvol ] && echo $rootvol - return - } - [ -e /sys/class/block/$rootvol/partition ] || { - echo $rootvol - return - } - rootdev=$(busybox readlink -f /sys/class/block/$rootvol) - rootdev=$(basename ${rootdev%%/${rootvol}}) - [ -e /sys/class/block/$rootdev ] && echo $rootdev -} - -get_partition() { - for partname in /sys/class/block/$1/*/name; do - [ "$(cat ${partname})" = "$2" ] && { - basename ${partname%%/name} - break - } - done -} - platform_do_upgrade() { local board=$(board_name) local file_type=$(identify $1) case "$board" in bananapi,bpi-r64) - local rootdev=$(get_rootdev) - local fitpart=$(get_partition $rootdev production) - [ "$fitpart" ] || exit 1 + export_bootdevice + export_partdevice rootdev 0 + local fitpart=$(get_partition_by_name $rootdev "production") + [ "$fitpart" ] || return 1 dd if=/dev/zero of=/dev/$fitpart bs=4096 count=1 2>/dev/null blockdev --rereadpt /dev/$rootdev get_image "$1" | dd of=/dev/$fitpart - echo $rootdev > /tmp/sysupgrade.rootdev + blockdev --rereadpt /dev/$rootdev + local datapart=$(get_partition_by_name $rootdev "rootfs_data") + [ "$datapart" ] || return 0 + dd if=/dev/zero of=/dev/$datapart bs=4096 count=1 2>/dev/null + echo $datapart > /tmp/sysupgrade.datapart ;; buffalo,wsr-2533dhp2) local magic="$(get_magic_long "$1")" @@ -113,11 +78,9 @@ platform_check_image() { platform_copy_config_mmc() { [ -e "$UPGRADE_BACKUP" ] || return - local rootdev=$(cat /tmp/sysupgrade.rootdev) - blockdev --rereadpt /dev/$rootdev - local datadev=$(get_partition $rootdev rootfs_data) - [ "$datadev" ] || echo "no rootfs_data partition, cannot keep configuration." >&2 - dd if="$UPGRADE_BACKUP" of=/dev/$datadev + local datapart=$(cat /tmp/sysupgrade.datapart) + [ "$datapart" ] || echo "no rootfs_data partition, cannot keep configuration." >&2 + dd if="$UPGRADE_BACKUP" of=/dev/$datapart sync } |