Skip to content

Commit

Permalink
x86: preinit: make name rewrite into reusable function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pprindeville authored and jow- committed Jan 4, 2018
1 parent 6c76dec commit 445f980
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions target/linux/x86/base-files/lib/preinit/01_sysinfo
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit 445f980

Please sign in to comment.