hostreq: Minor script adjustment

- Remove an extra whitespace breaking shebang (though our instruction
  does not use the shebang).
- Adjust the regex to allow several letters after the version number,
  and match grep version to the text.
- Raise Coreutils to 7.0 (for the host requirement script itself).  It
  was released in 2008 so I don't think it's a problem.
- Add a colon after the text "Compiler check" to match "Aliases:".
- Use grep -o instead of sed to make kernel version check simpler.
This commit is contained in:
Xi Ruoyao 2023-03-05 10:01:40 +08:00
parent 73e2b9c189
commit b789d88195
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3

View File

@ -55,7 +55,7 @@
</listitem> </listitem>
<listitem> <listitem>
<para><emphasis role="strong">Coreutils-6.9</emphasis></para> <para><emphasis role="strong">Coreutils-7.0</emphasis></para>
</listitem> </listitem>
<listitem> <listitem>
@ -165,7 +165,7 @@
the ability to compile programs, run the following commands:</para> the ability to compile programs, run the following commands:</para>
<screen role="nodump"><userinput>cat &gt; version-check.sh &lt;&lt; "EOF" <screen role="nodump"><userinput>cat &gt; version-check.sh &lt;&lt; "EOF"
<literal> #!/bin/bash <literal>#!/bin/bash
# A script to list version numbers of critical development tools # A script to list version numbers of critical development tools
# If you have tools installed in other directories, adjust PATH here AND # If you have tools installed in other directories, adjust PATH here AND
@ -185,7 +185,7 @@ ver_check()
then then
echo "ERROR: Cannot find $2 ($1)"; return 1; echo "ERROR: Cannot find $2 ($1)"; return 1;
fi fi
v=$($2 --version 2>&amp;1 | grep -E -o '[0-9]+\.[0-9\.]+' | head -n1) v=$($2 --version 2>&amp;1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1)
if printf '%s\n' $3 $v | sort --version-sort --check &amp;>/dev/null if printf '%s\n' $3 $v | sort --version-sort --check &amp;>/dev/null
then then
printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0; printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0;
@ -197,7 +197,7 @@ ver_check()
ver_kernel() ver_kernel()
{ {
kver=$(uname -r | sed -E 's/^([0-9\.]+).*/\1/') kver=$(uname -r | grep -E -o '[0-9\.]+')
if printf '%s\n' $1 $kver | sort --version-sort --check &amp;>/dev/null if printf '%s\n' $1 $kver | sort --version-sort --check &amp;>/dev/null
then then
printf "OK: Linux Kernel $kver >= $1\n"; return 0; printf "OK: Linux Kernel $kver >= $1\n"; return 0;
@ -217,7 +217,7 @@ ver_check Findutils find 4.2.31
ver_check Gawk gawk 4.0.1 ver_check Gawk gawk 4.0.1
ver_check GCC gcc 5.1 ver_check GCC gcc 5.1
ver_check "GCC (C++)" g++ 5.1 ver_check "GCC (C++)" g++ 5.1
ver_check Grep grep 2.6.1 ver_check Grep grep 2.5.1a
ver_check Gzip gzip 1.3.12 ver_check Gzip gzip 1.3.12
ver_check M4 m4 1.4.10 ver_check M4 m4 1.4.10
ver_check Make make 4.0 ver_check Make make 4.0
@ -241,7 +241,7 @@ alias_check awk GNU
alias_check yacc Bison alias_check yacc Bison
alias_check sh Bash alias_check sh Bash
echo "Compiler check" echo "Compiler check:"
if printf "int main(){}" | g++ -x c++ - if printf "int main(){}" | g++ -x c++ -
then echo "OK: g++ works"; then echo "OK: g++ works";
else echo "ERROR: g++ does NOT work"; fi else echo "ERROR: g++ does NOT work"; fi