aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/x86
diff options
context:
space:
mode:
authorPhilip Prindeville <philipp@redfish-solutions.com>2017-10-30 12:31:04 -0600
committerJo-Philipp Wich <jo@mein.io>2018-01-04 13:44:42 +0100
commit445f980a386960840414898af17fbac2fda82779 (patch)
tree657fee9a44966b41e7146062e97759000caec707 /target/linux/x86
parent6c76decd61ab062bfb7fce78da5de89a2b9fcc72 (diff)
downloadupstream-445f980a386960840414898af17fbac2fda82779.tar.gz
upstream-445f980a386960840414898af17fbac2fda82779.tar.bz2
upstream-445f980a386960840414898af17fbac2fda82779.zip
x86: preinit: make name rewrite into reusable function
There might be other places (such as vendor-supplied preinit scripts) where we wish to take a DMI name and clean it up in a consistent way, so make the sed command into a function. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Diffstat (limited to 'target/linux/x86')
-rw-r--r--target/linux/x86/base-files/lib/preinit/01_sysinfo16
1 files changed, 10 insertions, 6 deletions
diff --git a/target/linux/x86/base-files/lib/preinit/01_sysinfo b/target/linux/x86/base-files/lib/preinit/01_sysinfo
index cb63a04014..3c21c07615 100644
--- a/target/linux/x86/base-files/lib/preinit/01_sysinfo
+++ b/target/linux/x86/base-files/lib/preinit/01_sysinfo
@@ -1,3 +1,12 @@
+sanitize_name_x86() {
+ sed -e '
+ y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
+ s/[^a-z0-9_-]\+/-/g;
+ s/^-//;
+ s/-$//;
+ ' "$@"
+}
+
do_sysinfo_x86() {
local vendor product file
@@ -17,12 +26,7 @@ do_sysinfo_x86() {
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
+ sanitize_name_x86 /tmp/sysinfo/model > /tmp/sysinfo/board_name
}
boot_hook_add preinit_main do_sysinfo_x86