treewide: populate boardname and model earlier
authorMathias Kresin <dev@kresin.me>
Fri, 7 Apr 2017 16:09:08 +0000 (18:09 +0200)
committerMathias Kresin <dev@kresin.me>
Sat, 15 Jul 2017 21:13:34 +0000 (23:13 +0200)
For targets using the generic board detection and board specific
settings in diag.sh, the board name is still unset at the time the
set_state() provided by diag.sh is called by 10_indicate_preinit.

Change the execution order to ensure the boardname is populated before
required the first time. Do the target specific board detection as
early as possible, directly followed by the generic one to allow a
seamless switch to the generic function for populating /tmp/sysinfo/.

Signed-off-by: Mathias Kresin <dev@kresin.me>
34 files changed:
package/base-files/files/lib/preinit/02_sysinfo [new file with mode: 0644]
package/base-files/files/lib/preinit/10_sysinfo [deleted file]
target/linux/adm5120/base-files/lib/preinit/01_preinit_do_adm5120.sh [new file with mode: 0644]
target/linux/adm5120/base-files/lib/preinit/05_preinit_do_adm5120.sh [deleted file]
target/linux/apm821xx/base-files/lib/preinit/01_preinit_do_apm821xx.sh [new file with mode: 0644]
target/linux/apm821xx/base-files/lib/preinit/03_preinit_do_apm821xx.sh [deleted file]
target/linux/ar71xx/base-files/lib/preinit/01_preinit_do_ar71xx.sh [new file with mode: 0644]
target/linux/ar71xx/base-files/lib/preinit/03_preinit_do_ar71xx.sh [deleted file]
target/linux/at91/base-files/lib/preinit/01_preinit_do_at91.sh [new file with mode: 0644]
target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh [deleted file]
target/linux/brcm2708/base-files/lib/preinit/01_preinit_do_brcm2708.sh [new file with mode: 0644]
target/linux/brcm2708/base-files/lib/preinit/03_preinit_do_brcm2708.sh [deleted file]
target/linux/brcm63xx/base-files/lib/preinit/01_do_brcm63xx.sh [new file with mode: 0644]
target/linux/brcm63xx/base-files/lib/preinit/03_do_brcm63xx.sh [deleted file]
target/linux/ipq806x/base-files/lib/preinit/01_preinit_do_ipq806x.sh [new file with mode: 0644]
target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh [deleted file]
target/linux/lantiq/base-files/lib/preinit/01_preinit_board.sh [new file with mode: 0755]
target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh [deleted file]
target/linux/mcs814x/base-files/lib/preinit/01_preinit_do_mcs814x.sh [new file with mode: 0755]
target/linux/mcs814x/base-files/lib/preinit/03_preinit_do_mcs814x.sh [deleted file]
target/linux/mpc85xx/base-files/lib/preinit/01_preinit_do_mpc85xx.sh [new file with mode: 0644]
target/linux/mpc85xx/base-files/lib/preinit/03_preinit_do_mpc85xx.sh [deleted file]
target/linux/mxs/base-files/lib/preinit/01_preinit_do_mxs.sh [new file with mode: 0644]
target/linux/mxs/base-files/lib/preinit/03_preinit_do_mxs.sh [deleted file]
target/linux/octeon/base-files/lib/preinit/01_sysinfo [new file with mode: 0644]
target/linux/octeon/base-files/lib/preinit/20_sysinfo [deleted file]
target/linux/oxnas/base-files/lib/preinit/01_preinit_do_oxnas.sh [new file with mode: 0644]
target/linux/oxnas/base-files/lib/preinit/03_preinit_do_oxnas.sh [deleted file]
target/linux/ramips/base-files/lib/preinit/01_preinit_do_ramips.sh [new file with mode: 0644]
target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh [deleted file]
target/linux/rb532/base-files/lib/preinit/01_sysinfo [new file with mode: 0644]
target/linux/rb532/base-files/lib/preinit/10_sysinfo [deleted file]
target/linux/x86/base-files/lib/preinit/01_sysinfo [new file with mode: 0644]
target/linux/x86/base-files/lib/preinit/20_sysinfo [deleted file]

diff --git a/package/base-files/files/lib/preinit/02_sysinfo b/package/base-files/files/lib/preinit/02_sysinfo
new file mode 100644 (file)
index 0000000..65b5096
--- /dev/null
@@ -0,0 +1,10 @@
+do_sysinfo_generic() {
+       [ -d /proc/device-tree ] || return
+       mkdir -p /tmp/sysinfo
+       [ -e /tmp/sysinfo/board_name ] || \
+               echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
+       [ ! -e /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
+               echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
+}
+
+boot_hook_add preinit_main do_sysinfo_generic
diff --git a/package/base-files/files/lib/preinit/10_sysinfo b/package/base-files/files/lib/preinit/10_sysinfo
deleted file mode 100644 (file)
index 65b5096..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-do_sysinfo_generic() {
-       [ -d /proc/device-tree ] || return
-       mkdir -p /tmp/sysinfo
-       [ -e /tmp/sysinfo/board_name ] || \
-               echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
-       [ ! -e /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
-               echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
-}
-
-boot_hook_add preinit_main do_sysinfo_generic
diff --git a/target/linux/adm5120/base-files/lib/preinit/01_preinit_do_adm5120.sh b/target/linux/adm5120/base-files/lib/preinit/01_preinit_do_adm5120.sh
new file mode 100644 (file)
index 0000000..4fca1e7
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+do_adm5120() {
+       . /lib/adm5120.sh
+}
+
+boot_hook_add preinit_main do_adm5120
diff --git a/target/linux/adm5120/base-files/lib/preinit/05_preinit_do_adm5120.sh b/target/linux/adm5120/base-files/lib/preinit/05_preinit_do_adm5120.sh
deleted file mode 100644 (file)
index 4fca1e7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-do_adm5120() {
-       . /lib/adm5120.sh
-}
-
-boot_hook_add preinit_main do_adm5120
diff --git a/target/linux/apm821xx/base-files/lib/preinit/01_preinit_do_apm821xx.sh b/target/linux/apm821xx/base-files/lib/preinit/01_preinit_do_apm821xx.sh
new file mode 100644 (file)
index 0000000..5675357
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_apm821xx() {
+       . /lib/apm821xx.sh
+
+       apm821xx_board_detect
+}
+
+boot_hook_add preinit_main do_apm821xx
diff --git a/target/linux/apm821xx/base-files/lib/preinit/03_preinit_do_apm821xx.sh b/target/linux/apm821xx/base-files/lib/preinit/03_preinit_do_apm821xx.sh
deleted file mode 100644 (file)
index 5675357..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_apm821xx() {
-       . /lib/apm821xx.sh
-
-       apm821xx_board_detect
-}
-
-boot_hook_add preinit_main do_apm821xx
diff --git a/target/linux/ar71xx/base-files/lib/preinit/01_preinit_do_ar71xx.sh b/target/linux/ar71xx/base-files/lib/preinit/01_preinit_do_ar71xx.sh
new file mode 100644 (file)
index 0000000..ff5407a
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_ar71xx() {
+       . /lib/ar71xx.sh
+
+       ar71xx_board_detect
+}
+
+boot_hook_add preinit_main do_ar71xx
diff --git a/target/linux/ar71xx/base-files/lib/preinit/03_preinit_do_ar71xx.sh b/target/linux/ar71xx/base-files/lib/preinit/03_preinit_do_ar71xx.sh
deleted file mode 100644 (file)
index ff5407a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_ar71xx() {
-       . /lib/ar71xx.sh
-
-       ar71xx_board_detect
-}
-
-boot_hook_add preinit_main do_ar71xx
diff --git a/target/linux/at91/base-files/lib/preinit/01_preinit_do_at91.sh b/target/linux/at91/base-files/lib/preinit/01_preinit_do_at91.sh
new file mode 100644 (file)
index 0000000..5c98101
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_at91() {
+       . /lib/at91.sh
+
+       at91_board_detect
+}
+
+boot_hook_add preinit_main do_at91
diff --git a/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh b/target/linux/at91/base-files/lib/preinit/03_preinit_do_at91.sh
deleted file mode 100644 (file)
index 5c98101..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_at91() {
-       . /lib/at91.sh
-
-       at91_board_detect
-}
-
-boot_hook_add preinit_main do_at91
diff --git a/target/linux/brcm2708/base-files/lib/preinit/01_preinit_do_brcm2708.sh b/target/linux/brcm2708/base-files/lib/preinit/01_preinit_do_brcm2708.sh
new file mode 100644 (file)
index 0000000..2943648
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2015 OpenWrt.org
+
+do_brcm2708() {
+       . /lib/brcm2708.sh
+
+       brcm2708_detect
+}
+
+boot_hook_add preinit_main do_brcm2708
diff --git a/target/linux/brcm2708/base-files/lib/preinit/03_preinit_do_brcm2708.sh b/target/linux/brcm2708/base-files/lib/preinit/03_preinit_do_brcm2708.sh
deleted file mode 100644 (file)
index 2943648..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2015 OpenWrt.org
-
-do_brcm2708() {
-       . /lib/brcm2708.sh
-
-       brcm2708_detect
-}
-
-boot_hook_add preinit_main do_brcm2708
diff --git a/target/linux/brcm63xx/base-files/lib/preinit/01_do_brcm63xx.sh b/target/linux/brcm63xx/base-files/lib/preinit/01_do_brcm63xx.sh
new file mode 100644 (file)
index 0000000..4179695
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_brcm63xx() {
+       . /lib/brcm63xx.sh
+
+       brcm63xx_detect
+}
+
+boot_hook_add preinit_main do_brcm63xx
diff --git a/target/linux/brcm63xx/base-files/lib/preinit/03_do_brcm63xx.sh b/target/linux/brcm63xx/base-files/lib/preinit/03_do_brcm63xx.sh
deleted file mode 100644 (file)
index 4179695..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_brcm63xx() {
-       . /lib/brcm63xx.sh
-
-       brcm63xx_detect
-}
-
-boot_hook_add preinit_main do_brcm63xx
diff --git a/target/linux/ipq806x/base-files/lib/preinit/01_preinit_do_ipq806x.sh b/target/linux/ipq806x/base-files/lib/preinit/01_preinit_do_ipq806x.sh
new file mode 100644 (file)
index 0000000..785f1eb
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 The Linux Foundation. All rights reserved.
+#
+
+do_ipq806x() {
+       . /lib/ipq806x.sh
+
+       ipq806x_board_detect
+}
+
+boot_hook_add preinit_main do_ipq806x
diff --git a/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh b/target/linux/ipq806x/base-files/lib/preinit/03_preinit_do_ipq806x.sh
deleted file mode 100644 (file)
index 785f1eb..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2014 The Linux Foundation. All rights reserved.
-#
-
-do_ipq806x() {
-       . /lib/ipq806x.sh
-
-       ipq806x_board_detect
-}
-
-boot_hook_add preinit_main do_ipq806x
diff --git a/target/linux/lantiq/base-files/lib/preinit/01_preinit_board.sh b/target/linux/lantiq/base-files/lib/preinit/01_preinit_board.sh
new file mode 100755 (executable)
index 0000000..aef9460
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+lantiq_board_detect() {
+       name=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/\(.*\) - .*/\1/g"`
+       model=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/.* - \(.*\)/\1/g"`
+       [ -z "$name" ] && name="unknown"
+       [ -z "$model" ] && model="unknown"
+       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+       echo $name > /tmp/sysinfo/board_name
+       echo $model > /tmp/sysinfo/model
+}
+
+do_lantiq() {
+       . /lib/functions/lantiq.sh
+
+       lantiq_board_detect
+}
+
+boot_hook_add preinit_main do_lantiq
diff --git a/target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh b/target/linux/lantiq/base-files/lib/preinit/03_preinit_board.sh
deleted file mode 100755 (executable)
index aef9460..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-lantiq_board_detect() {
-       name=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/\(.*\) - .*/\1/g"`
-       model=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/.* - \(.*\)/\1/g"`
-       [ -z "$name" ] && name="unknown"
-       [ -z "$model" ] && model="unknown"
-       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
-       echo $name > /tmp/sysinfo/board_name
-       echo $model > /tmp/sysinfo/model
-}
-
-do_lantiq() {
-       . /lib/functions/lantiq.sh
-
-       lantiq_board_detect
-}
-
-boot_hook_add preinit_main do_lantiq
diff --git a/target/linux/mcs814x/base-files/lib/preinit/01_preinit_do_mcs814x.sh b/target/linux/mcs814x/base-files/lib/preinit/01_preinit_do_mcs814x.sh
new file mode 100755 (executable)
index 0000000..d509770
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_mcs814x() {
+       . /lib/mcs814x.sh
+
+       mcs814x_board_detect
+}
+
+boot_hook_add preinit_main do_mcs814x
diff --git a/target/linux/mcs814x/base-files/lib/preinit/03_preinit_do_mcs814x.sh b/target/linux/mcs814x/base-files/lib/preinit/03_preinit_do_mcs814x.sh
deleted file mode 100755 (executable)
index d509770..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_mcs814x() {
-       . /lib/mcs814x.sh
-
-       mcs814x_board_detect
-}
-
-boot_hook_add preinit_main do_mcs814x
diff --git a/target/linux/mpc85xx/base-files/lib/preinit/01_preinit_do_mpc85xx.sh b/target/linux/mpc85xx/base-files/lib/preinit/01_preinit_do_mpc85xx.sh
new file mode 100644 (file)
index 0000000..88ba608
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_mpc85xx() {
+       . /lib/mpc85xx.sh
+
+       mpc85xx_board_detect
+}
+
+boot_hook_add preinit_main do_mpc85xx
diff --git a/target/linux/mpc85xx/base-files/lib/preinit/03_preinit_do_mpc85xx.sh b/target/linux/mpc85xx/base-files/lib/preinit/03_preinit_do_mpc85xx.sh
deleted file mode 100644 (file)
index 88ba608..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_mpc85xx() {
-       . /lib/mpc85xx.sh
-
-       mpc85xx_board_detect
-}
-
-boot_hook_add preinit_main do_mpc85xx
diff --git a/target/linux/mxs/base-files/lib/preinit/01_preinit_do_mxs.sh b/target/linux/mxs/base-files/lib/preinit/01_preinit_do_mxs.sh
new file mode 100644 (file)
index 0000000..692078d
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_mxs() {
+       . /lib/mxs.sh
+
+       mxs_board_detect
+}
+
+boot_hook_add preinit_main do_mxs
diff --git a/target/linux/mxs/base-files/lib/preinit/03_preinit_do_mxs.sh b/target/linux/mxs/base-files/lib/preinit/03_preinit_do_mxs.sh
deleted file mode 100644 (file)
index 692078d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_mxs() {
-       . /lib/mxs.sh
-
-       mxs_board_detect
-}
-
-boot_hook_add preinit_main do_mxs
diff --git a/target/linux/octeon/base-files/lib/preinit/01_sysinfo b/target/linux/octeon/base-files/lib/preinit/01_sysinfo
new file mode 100644 (file)
index 0000000..d8f467e
--- /dev/null
@@ -0,0 +1,31 @@
+do_sysinfo_octeon() {
+       local machine
+       local name
+
+       machine=$(grep "^system type" /proc/cpuinfo | sed "s/system type.*: \(.*\)/\1/g")
+
+       case "$machine" in
+       "UBNT_E100"*)
+               name="erlite"
+               ;;
+
+       "UBNT_E200"*)
+               name="er"
+               ;;
+
+       "UBNT_E220"*)
+               name="erpro"
+               ;;
+
+       *)
+               name="generic"
+               ;;
+       esac
+
+       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
+
+       echo "$name" > /tmp/sysinfo/board_name
+       echo "$machine" > /tmp/sysinfo/model
+}
+
+boot_hook_add preinit_main do_sysinfo_octeon
diff --git a/target/linux/octeon/base-files/lib/preinit/20_sysinfo b/target/linux/octeon/base-files/lib/preinit/20_sysinfo
deleted file mode 100644 (file)
index d8f467e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-do_sysinfo_octeon() {
-       local machine
-       local name
-
-       machine=$(grep "^system type" /proc/cpuinfo | sed "s/system type.*: \(.*\)/\1/g")
-
-       case "$machine" in
-       "UBNT_E100"*)
-               name="erlite"
-               ;;
-
-       "UBNT_E200"*)
-               name="er"
-               ;;
-
-       "UBNT_E220"*)
-               name="erpro"
-               ;;
-
-       *)
-               name="generic"
-               ;;
-       esac
-
-       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
-
-       echo "$name" > /tmp/sysinfo/board_name
-       echo "$machine" > /tmp/sysinfo/model
-}
-
-boot_hook_add preinit_main do_sysinfo_octeon
diff --git a/target/linux/oxnas/base-files/lib/preinit/01_preinit_do_oxnas.sh b/target/linux/oxnas/base-files/lib/preinit/01_preinit_do_oxnas.sh
new file mode 100644 (file)
index 0000000..ca7bce1
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_oxnas() {
+       . /lib/oxnas.sh
+
+       oxnas_board_detect
+}
+
+boot_hook_add preinit_main do_oxnas
diff --git a/target/linux/oxnas/base-files/lib/preinit/03_preinit_do_oxnas.sh b/target/linux/oxnas/base-files/lib/preinit/03_preinit_do_oxnas.sh
deleted file mode 100644 (file)
index ca7bce1..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_oxnas() {
-       . /lib/oxnas.sh
-
-       oxnas_board_detect
-}
-
-boot_hook_add preinit_main do_oxnas
diff --git a/target/linux/ramips/base-files/lib/preinit/01_preinit_do_ramips.sh b/target/linux/ramips/base-files/lib/preinit/01_preinit_do_ramips.sh
new file mode 100644 (file)
index 0000000..31ef5f8
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+do_ramips() {
+       . /lib/ramips.sh
+
+       ramips_board_detect
+}
+
+boot_hook_add preinit_main do_ramips
diff --git a/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh b/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh
deleted file mode 100644 (file)
index 31ef5f8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-do_ramips() {
-       . /lib/ramips.sh
-
-       ramips_board_detect
-}
-
-boot_hook_add preinit_main do_ramips
diff --git a/target/linux/rb532/base-files/lib/preinit/01_sysinfo b/target/linux/rb532/base-files/lib/preinit/01_sysinfo
new file mode 100644 (file)
index 0000000..4c932fd
--- /dev/null
@@ -0,0 +1,11 @@
+get_model_rb532() {
+       grep system\ type /proc/cpuinfo | awk -F ": " '{print $2}'
+}
+
+do_sysinfo_rb532() {
+       mkdir -p /tmp/sysinfo
+       echo rb532 > /tmp/sysinfo/board_name
+       get_model_rb532 > /tmp/sysinfo/model
+}
+
+boot_hook_add preinit_main do_sysinfo_rb532
diff --git a/target/linux/rb532/base-files/lib/preinit/10_sysinfo b/target/linux/rb532/base-files/lib/preinit/10_sysinfo
deleted file mode 100644 (file)
index 4c932fd..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-get_model_rb532() {
-       grep system\ type /proc/cpuinfo | awk -F ": " '{print $2}'
-}
-
-do_sysinfo_rb532() {
-       mkdir -p /tmp/sysinfo
-       echo rb532 > /tmp/sysinfo/board_name
-       get_model_rb532 > /tmp/sysinfo/model
-}
-
-boot_hook_add preinit_main do_sysinfo_rb532
diff --git a/target/linux/x86/base-files/lib/preinit/01_sysinfo b/target/linux/x86/base-files/lib/preinit/01_sysinfo
new file mode 100644 (file)
index 0000000..cb63a04
--- /dev/null
@@ -0,0 +1,28 @@
+do_sysinfo_x86() {
+       local vendor product file
+
+       for file in sys_vendor board_vendor; do
+               vendor="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
+               [ -n "$vendor" ] && break
+       done
+
+       for file in product_name board_name; do
+               product="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
+               [ -n "$product" ] && break
+       done
+
+       [ -n "$vendor" -a -n "$product" ] || return
+
+       mkdir -p /tmp/sysinfo
+
+       echo "$vendor $product" > /tmp/sysinfo/model
+
+       sed -e '
+               y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
+               s/[^a-z0-9_-]\+/-/g;
+               s/^-//;
+               s/-$//;
+       ' /tmp/sysinfo/model > /tmp/sysinfo/board_name
+}
+
+boot_hook_add preinit_main do_sysinfo_x86
diff --git a/target/linux/x86/base-files/lib/preinit/20_sysinfo b/target/linux/x86/base-files/lib/preinit/20_sysinfo
deleted file mode 100644 (file)
index cb63a04..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-do_sysinfo_x86() {
-       local vendor product file
-
-       for file in sys_vendor board_vendor; do
-               vendor="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
-               [ -n "$vendor" ] && break
-       done
-
-       for file in product_name board_name; do
-               product="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)"
-               [ -n "$product" ] && break
-       done
-
-       [ -n "$vendor" -a -n "$product" ] || return
-
-       mkdir -p /tmp/sysinfo
-
-       echo "$vendor $product" > /tmp/sysinfo/model
-
-       sed -e '
-               y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
-               s/[^a-z0-9_-]\+/-/g;
-               s/^-//;
-               s/-$//;
-       ' /tmp/sysinfo/model > /tmp/sysinfo/board_name
-}
-
-boot_hook_add preinit_main do_sysinfo_x86