diff options
author | Mathias Kresin <dev@kresin.me> | 2017-07-09 13:00:36 +0200 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-07-15 23:13:34 +0200 |
commit | e4e984f2a07d2cd96d8e5e90955bc268eb5d4e5a (patch) | |
tree | a4534355402283a176866ce6b03f774d8cf98769 /target | |
parent | e0b9ec8e969e1c37c284cfa2f252e9b0a71157db (diff) | |
download | mtk-20170518-e4e984f2a07d2cd96d8e5e90955bc268eb5d4e5a.zip mtk-20170518-e4e984f2a07d2cd96d8e5e90955bc268eb5d4e5a.tar.gz mtk-20170518-e4e984f2a07d2cd96d8e5e90955bc268eb5d4e5a.tar.bz2 |
treewide: use only board_name function to get name
Do not parse /tmp/sysinfo/board_name, /proc/cpuinfo or the device tree
compatible string directly. Always use the board_name function to get
the board name.
The admswconfig package still reads /proc/cpuinfo directly. The code
looks somehow broken and the whole adm5120 which uses this package
looks unmaintained. Leave it as it is for now.
Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'target')
20 files changed, 35 insertions, 38 deletions
diff --git a/target/linux/apm821xx/base-files/lib/preinit/79_move_config b/target/linux/apm821xx/base-files/lib/preinit/79_move_config index f45619f..3ca8b0a 100644 --- a/target/linux/apm821xx/base-files/lib/preinit/79_move_config +++ b/target/linux/apm821xx/base-files/lib/preinit/79_move_config @@ -3,7 +3,9 @@ BOOTPART=/dev/sda1 move_config() { - grep -q 'MyBook Live' /proc/cpuinfo || return + . /lib/functions.sh + + [ "$(board_name)" = "mbl" ] || return if [ -b $BOOTPART ]; then mkdir -p /boot mount -t ext4 -o rw,noatime $BOOTPART /boot diff --git a/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh index f025082..fb961b8 100755 --- a/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh @@ -52,7 +52,7 @@ merakinand_do_platform_check() { merakinand_do_upgrade() { local tar_file="$1" - local board_name="$(cat /tmp/sysinfo/board_name)" + local board_name="$(board_name)" # Do we need to do any platform tweaks? case "$board_name" in diff --git a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh index 78cde20..dfc57b2 100644 --- a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh @@ -51,7 +51,7 @@ merakinand_copy_caldata() { local cal_src=$1 local cal_dst=$2 local ubidev="$(nand_find_ubi $CI_UBIPART)" - local board_name="$(cat /tmp/sysinfo/board_name)" + local board_name="$(board_name)" local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')" # Setup partitions using board name, in case of future platforms @@ -143,7 +143,7 @@ merakinand_do_platform_check() { merakinand_do_upgrade() { local tar_file="$1" - local board_name="$(cat /tmp/sysinfo/board_name)" + local board_name="$(board_name)" # Do we need to do any platform tweaks? case "$board_name" in diff --git a/target/linux/bcm53xx/base-files/etc/board.d/01_leds b/target/linux/bcm53xx/base-files/etc/board.d/01_leds index ebfe363..80f799d 100755 --- a/target/linux/bcm53xx/base-files/etc/board.d/01_leds +++ b/target/linux/bcm53xx/base-files/etc/board.d/01_leds @@ -4,9 +4,7 @@ board_config_update -board=$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1) - -case "$board" in +case "$(board_name)" in netgear,r8000) ucidef_set_led_usbport "usb2" "USB 2.0" "bcm53xx:white:usb2" "usb1-port2" "usb2-port2" ucidef_set_led_usbport "usb3" "USB 3.0" "bcm53xx:white:usb3" "usb1-port1" "usb2-port1" "usb4-port1" diff --git a/target/linux/bcm53xx/base-files/etc/board.d/02_network b/target/linux/bcm53xx/base-files/etc/board.d/02_network index 89bd544..dc17af4 100755 --- a/target/linux/bcm53xx/base-files/etc/board.d/02_network +++ b/target/linux/bcm53xx/base-files/etc/board.d/02_network @@ -8,7 +8,7 @@ board_config_update -board=$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1) +board=$(board_name) case "$board" in tenda,ac9) diff --git a/target/linux/brcm47xx/base-files/etc/board.d/01_detect b/target/linux/brcm47xx/base-files/etc/board.d/01_detect index 357cc7f..f1022dc 100755 --- a/target/linux/brcm47xx/base-files/etc/board.d/01_detect +++ b/target/linux/brcm47xx/base-files/etc/board.d/01_detect @@ -175,7 +175,7 @@ detect_by_model() { } -model="$(sed -ne 's/^machine[ \t]*: //p' /proc/cpuinfo)" +model="$(board_name)" boardtype="$(nvram get boardtype)" boardnum="$(nvram get boardnum)" diff --git a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh index fc48cb1..166bc05 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh @@ -68,7 +68,7 @@ zyxel_do_flash() { zyxel_do_upgrade() { local tar_file="$1" - local board=$(cat /tmp/sysinfo/board_name) + local board=$(board_name) local rootfs="$(zyxel_get_rootfs)" local kernel= diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh index 9a844bc..7e936c4 100755 --- a/target/linux/mediatek/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh @@ -4,7 +4,7 @@ platform_do_upgrade() { local tar_file="$1" - local board="$(cat /tmp/sysinfo/board_name)" + local board="$(board_name)" echo "flashing kernel" tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel @@ -17,7 +17,7 @@ platform_do_upgrade() { platform_check_image() { local tar_file="$1" - local board=$(cat /tmp/sysinfo/board_name) + local board=$(board_name) case "$board" in mediatek,mt7623-rfb-nand-ephy |\ @@ -45,8 +45,7 @@ platform_check_image() { } platform_pre_upgrade() { - local board=$(cat /tmp/sysinfo/board_name) - case "$board" in + case "$(board_name)" in mediatek,mt7623-rfb-nand-ephy |\ mediatek,mt7623-rfb-nand) nand_do_upgrade $1 diff --git a/target/linux/octeon/base-files/etc/board.d/01_network b/target/linux/octeon/base-files/etc/board.d/01_network index 851b7e8..79e5089 100755 --- a/target/linux/octeon/base-files/etc/board.d/01_network +++ b/target/linux/octeon/base-files/etc/board.d/01_network @@ -7,7 +7,7 @@ board_config_update -case "$(cat /tmp/sysinfo/board_name)" in +case "$(board_name)" in erlite) ucidef_set_interfaces_lan_wan "eth0" "eth1" ;; diff --git a/target/linux/octeon/base-files/lib/preinit/79_move_config b/target/linux/octeon/base-files/lib/preinit/79_move_config index 4ab321b..ec63d9f 100644 --- a/target/linux/octeon/base-files/lib/preinit/79_move_config +++ b/target/linux/octeon/base-files/lib/preinit/79_move_config @@ -2,7 +2,9 @@ # Copyright (C) 2014 OpenWrt.org move_config() { - case "$(cat /tmp/sysinfo/board_name)" in + . /lib/functions.sh + + case "$(board_name)" in erlite) mount -t vfat /dev/sda1 /mnt [ -f /mnt/sysupgrade.tgz ] && mv -f /mnt/sysupgrade.tgz / diff --git a/target/linux/octeon/base-files/lib/upgrade/platform.sh b/target/linux/octeon/base-files/lib/upgrade/platform.sh index 91763ce..cd49c0d 100755 --- a/target/linux/octeon/base-files/lib/upgrade/platform.sh +++ b/target/linux/octeon/base-files/lib/upgrade/platform.sh @@ -22,9 +22,7 @@ platform_get_rootfs() { } platform_copy_config() { - local board="$(cat /tmp/sysinfo/board_name)" - - case "$board" in + case "$(board_name)" in erlite) mount -t vfat /dev/sda1 /mnt cp -af "$CONF_TAR" /mnt/ @@ -58,7 +56,7 @@ platform_do_flash() { platform_do_upgrade() { local tar_file="$1" - local board=$(cat /tmp/sysinfo/board_name) + local board=$(board_name) local rootfs="$(platform_get_rootfs)" local kernel= @@ -81,7 +79,7 @@ platform_do_upgrade() { } platform_check_image() { - local board=$(cat /tmp/sysinfo/board_name) + local board=$(board_name) case "$board" in erlite | \ diff --git a/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/10-bme-pmm-image b/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/10-bme-pmm-image index d03c9de..26d367d 100644 --- a/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/10-bme-pmm-image +++ b/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/10-bme-pmm-image @@ -7,8 +7,10 @@ n810_cal_bme_pmm_extract() { } } +. /lib/functions.sh + [ "$FIRMWARE" = "n810-cal-bme-pmm.fw" ] && { - [ -z "$(grep -e 'Nokia N810' /proc/cpuinfo)" ] || { + [ "$(board_name)" != "nokia,n810" ] || { [ -e /lib/firmware/n810-cal-bme-pmm.fw ] ||\ n810_cal_bme_pmm_extract } diff --git a/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/20-p54spi-eeprom b/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/20-p54spi-eeprom index ca92f80..c535747 100644 --- a/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/20-p54spi-eeprom +++ b/target/linux/omap24xx/base-files/etc/hotplug.d/firmware/20-p54spi-eeprom @@ -22,8 +22,10 @@ p54spi_eeprom_extract() { } } +. /lib/functions.sh + [ "$FIRMWARE" = "3826.eeprom" ] && { - [ -z "$(grep -e 'Nokia N810' /proc/cpuinfo)" ] || { + [ "$(board_name)" != "nokia,n810" ] || { [ -e /lib/firmware/3826.eeprom ] ||\ p54spi_eeprom_extract } diff --git a/target/linux/orion/base-files/etc/hotplug.d/usb/10-usb b/target/linux/orion/base-files/etc/hotplug.d/usb/10-usb index 5572dae..2ae0f73 100644 --- a/target/linux/orion/base-files/etc/hotplug.d/usb/10-usb +++ b/target/linux/orion/base-files/etc/hotplug.d/usb/10-usb @@ -30,9 +30,9 @@ usb_led_off() { } get_usb_led() { - local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` + . /lib/functions.sh - case "${hardware}" in + case "$(board_name)" in 'Linksys WRT350N v2') usb_led='wrt350nv2:green:usb' usb_device='1-1:1.0' diff --git a/target/linux/orion/generic/base-files/etc/uci-defaults/09_hardware b/target/linux/orion/generic/base-files/etc/uci-defaults/09_hardware index 5b30f27..751749d 100644 --- a/target/linux/orion/generic/base-files/etc/uci-defaults/09_hardware +++ b/target/linux/orion/generic/base-files/etc/uci-defaults/09_hardware @@ -10,7 +10,7 @@ # This script sets system defaults for the hardware on firstboot # -hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` +. /lib/functions.sh wrt350nv2_default() { # leds @@ -47,7 +47,7 @@ __EOF } } -case "${hardware}" in +case "$(board_name)" in 'Linksys WRT350N v2') wrt350nv2_default ;; diff --git a/target/linux/orion/generic/base-files/lib/upgrade/platform.sh b/target/linux/orion/generic/base-files/lib/upgrade/platform.sh index 9c9967e..db23306 100644 --- a/target/linux/orion/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/orion/generic/base-files/lib/upgrade/platform.sh @@ -8,7 +8,7 @@ platform_check_image() { [ "${ARGC}" -gt 1 ] && { echo 'Too many arguments. Only flash file expected.'; return 1; } - local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` + local hardware="$(board_name)" local magic="$(get_magic_word "$1")" local magic_long="$(get_magic_long "$1")" diff --git a/target/linux/rb532/base-files/lib/upgrade/platform.sh b/target/linux/rb532/base-files/lib/upgrade/platform.sh index bfa73a7..2beccc5 100644 --- a/target/linux/rb532/base-files/lib/upgrade/platform.sh +++ b/target/linux/rb532/base-files/lib/upgrade/platform.sh @@ -15,10 +15,8 @@ platform_pre_upgrade() { } platform_nand_pre_upgrade() { - local board_name="$(cat /tmp/sysinfo/board_name)" - mtd erase kernel - tar xf "$1" sysupgrade-$board_name/kernel -O | nandwrite -o /dev/mtd0 - + tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 - } platform_do_upgrade() { diff --git a/target/linux/x86/base-files/etc/board.d/01_leds b/target/linux/x86/base-files/etc/board.d/01_leds index 6a5ff03..04e1170 100755 --- a/target/linux/x86/base-files/etc/board.d/01_leds +++ b/target/linux/x86/base-files/etc/board.d/01_leds @@ -7,9 +7,7 @@ board_config_update -board=$(cat /tmp/sysinfo/board_name) 2>/dev/null - -case "$board" in +case "$(board_name)" in pc-engines-apu|pc-engines-apu2) ucidef_set_led_netdev "wan" "WAN" "apu2:green:led3" "eth0" ucidef_set_led_netdev "lan" "LAN" "apu2:green:led2" "br-lan" diff --git a/target/linux/x86/base-files/etc/board.d/02_network b/target/linux/x86/base-files/etc/board.d/02_network index 5bfe609..bea696d 100755 --- a/target/linux/x86/base-files/etc/board.d/02_network +++ b/target/linux/x86/base-files/etc/board.d/02_network @@ -8,9 +8,7 @@ board_config_update -board="$(cat /tmp/sysinfo/board_name)" 2>/dev/null - -case "$board" in +case "$(board_name)" in pc-engines-apu|pc-engines-apu2) ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0" ;; diff --git a/target/linux/zynq/base-files/etc/board.d/02_network b/target/linux/zynq/base-files/etc/board.d/02_network index 9659673..ff90763 100755 --- a/target/linux/zynq/base-files/etc/board.d/02_network +++ b/target/linux/zynq/base-files/etc/board.d/02_network @@ -5,7 +5,7 @@ board_config_update -case "$(cat /tmp/sysinfo/board_name)" in +case "$(board_name)" in xlnx,zynq-zc702|xlnx,zynq-zed|xlnx,zynq-zybo) ucidef_set_interface_lan 'eth0' ;; |