base-files: improve lib/upgrade/common.sh
authorKlaus Kudielka <klaus.kudielka@gmail.com>
Wed, 8 May 2019 18:40:50 +0000 (20:40 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sat, 11 May 2019 14:37:11 +0000 (16:37 +0200)
commitad62247800a10654ab7a3d94ea9c6b43a834f301
treeb70b1d866bb558d5fd6e550408f81d1a935981c7
parent6411eac5da19359c45fdd9543725369ba9526384
base-files: improve lib/upgrade/common.sh

Recently, upgrade device autodetection has been added to the mvebu target.
This exposes some shortcomings of the generic export_bootdevice function,
e.g. on the Turris Omnia: export_bootdevice silently reports the root
partition to be the boot device. This makes the sysupgrade process fail at
several places.

Fix this by clearly distinguishing between /proc/cmdline arguments which
specify the boot disk, and those which specify the root partition. Only in
the latter case, strip off the partition, and do it consistently.
root=PARTUUID=<pseudo PARTUUID for MBR> (any partition) and root=/dev/*
(any partition) are accepted.

The root of the problem is that the *existing* export_bootdevice in
/lib/upgrade/common.sh behaves differently, if the kernel is booted with
root=/dev/..., or if it is booted with root=PARTUUID=...

In the former case, it reports back major/minor of the root partition,
in the latter case it reports back major/minor of the complete boot disk.

Targets, which boot with root=/dev/... *and* use export_bootdevice /
export_partdevice, have added workarounds to this behaviour, by specifying
*negative* increments to the export_partdevice function.

Consequently, those targets have to be adapted to use positive increments,
otherwise they are broken by the change to export_bootdevice.

Fixes: 4e8345ff68 ("mvebu: base-files: autodetect upgrade device")
Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
Tested-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
package/base-files/files/lib/upgrade/common.sh
target/linux/apm821xx/base-files/lib/upgrade/wdbook.sh
target/linux/brcm2708/base-files/lib/upgrade/platform.sh
target/linux/omap/base-files/lib/preinit/79_move_config
target/linux/omap/base-files/lib/upgrade/platform.sh
target/linux/sunxi/base-files/lib/preinit/79_move_config
target/linux/sunxi/base-files/lib/upgrade/platform.sh