base-files: functions: introduce new helper functions

Introduce cmdline_get_var() to /lib/function.sh and make use of it in
export_rootdev() in /lib/upgrade/common.sh, making the code more
simple and removing one level of indentation.
Introduce get_partition_by_name() to /lib/upgrade/common.sh which is
useful on non-EFI GPT platforms like mt7622.
Remove some dead-code while at it.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle
2021-03-31 13:47:35 +01:00
parent 0bc5ecf2d0
commit bb107ad9c1
2 changed files with 67 additions and 62 deletions

View File

@@ -384,4 +384,14 @@ board_name() {
[ -e /tmp/sysinfo/board_name ] && cat /tmp/sysinfo/board_name || echo "generic"
}
cmdline_get_var() {
local var=$1
local cmdlinevar tmp
for cmdlinevar in $(cat /proc/cmdline); do
tmp=${cmdlinevar##${var}}
[ "=" = "${tmp:0:1}" ] && echo ${tmp:1}
done
}
[ -z "$IPKG_INSTROOT" ] && [ -f /lib/config/uci.sh ] && . /lib/config/uci.sh