[openwrt/openwrt] x86: preinit: make name rewrite into reusable function

LEDE Commits lede-commits at lists.infradead.org
Thu Jan 4 04:46:12 PST 2018


jow pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/445f980a386960840414898af17fbac2fda82779

commit 445f980a386960840414898af17fbac2fda82779
Author: Philip Prindeville <philipp at redfish-solutions.com>
AuthorDate: Mon Oct 30 12:31:04 2017 -0600

    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 at redfish-solutions.com>
---
 target/linux/x86/base-files/lib/preinit/01_sysinfo | 16 ++++++++++------
 1 file 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 cb63a04..3c21c07 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



More information about the lede-commits mailing list