X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=package%2Fbase-files%2Ffiles%2Flib%2Fupgrade%2Fcommon.sh;h=a13a6aaf5aefbfcf9178340506c32e71439d9d50;hb=ea4e1dac71dfa015c0da10e68149478fa25878f9;hp=9e9144cba4e9bbe0d95b77b5b3bec716e1403fb0;hpb=56b8ac1e86eb5b0c500cbf8db60ce00aff01bcec;p=oweals%2Fopenwrt.git diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index 9e9144cba4..a13a6aaf5a 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -101,35 +101,41 @@ get_magic_long() { } export_bootdevice() { - local cmdline uuid disk uevent line + local cmdline bootdisk rootpart uuid blockdev uevent line local MAJOR MINOR DEVNAME DEVTYPE if read cmdline < /proc/cmdline; then case "$cmdline" in *block2mtd=*) - disk="${cmdline##*block2mtd=}" - disk="${disk%%,*}" + bootdisk="${cmdline##*block2mtd=}" + bootdisk="${bootdisk%%,*}" ;; *root=*) - disk="${cmdline##*root=}" - disk="${disk%% *}" + rootpart="${cmdline##*root=}" + rootpart="${rootpart%% *}" ;; esac - case "$disk" in - PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-02) - uuid="${disk#PARTUUID=}" - uuid="${uuid%-02}" - for disk in $(find /dev -type b); do - set -- $(dd if=$disk bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "') + case "$bootdisk" in + /dev/*) + uevent="/sys/class/block/${bootdisk##*/}/uevent" + ;; + esac + + case "$rootpart" in + PARTUUID=[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]-[a-f0-9][a-f0-9]) + uuid="${rootpart#PARTUUID=}" + uuid="${uuid%-[a-f0-9][a-f0-9]}" + for blockdev in $(find /dev -type b); do + set -- $(dd if=$blockdev bs=1 skip=440 count=4 2>/dev/null | hexdump -v -e '4/1 "%02x "') if [ "$4$3$2$1" = "$uuid" ]; then - uevent="/sys/class/block/${disk##*/}/uevent" + uevent="/sys/class/block/${blockdev##*/}/uevent" break fi done ;; /dev/*) - uevent="/sys/class/block/${disk##*/}/uevent" + uevent="/sys/class/block/${rootpart##*/}/../uevent" ;; esac @@ -164,7 +170,7 @@ export_partdevice() { } hex_le32_to_cpu() { - [ "$(echo 01 | hexdump -v -n 2 -e '/2 "%x"')" == "3031" ] && { + [ "$(echo 01 | hexdump -v -n 2 -e '/2 "%x"')" = "3031" ] && { echo "${1:0:2}${1:8:2}${1:6:2}${1:4:2}${1:2:2}" return } @@ -201,16 +207,6 @@ get_partitions() { # fi } -jffs2_copy_config() { - if grep rootfs_data /proc/mtd >/dev/null; then - # squashfs+jffs2 - mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data - else - # jffs2 - mtd jffs2write "$CONF_TAR" rootfs - fi -} - indicate_upgrade() { . /etc/diag.sh set_state upgrade @@ -223,18 +219,16 @@ indicate_upgrade() { default_do_upgrade() { sync if [ "$SAVE_CONFIG" -eq 1 ]; then - get_image "$1" "$2" | mtd $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}" + get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}" else - get_image "$1" "$2" | mtd write - "${PART_NAME:-image}" + get_image "$1" "$2" | mtd $MTD_ARGS write - "${PART_NAME:-image}" fi [ $? -ne 0 ] && exit 1 } do_upgrade_stage2() { v "Performing system upgrade..." - if [ -n "$do_upgrade" ]; then - eval "$do_upgrade" - elif type 'platform_do_upgrade' >/dev/null 2>/dev/null; then + if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then platform_do_upgrade "$IMAGE" else default_do_upgrade "$IMAGE"