From b789d881957ec03daee8455a49953f5645ae080a Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sun, 5 Mar 2023 10:01:40 +0800 Subject: [PATCH] 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. --- chapter02/hostreqs.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chapter02/hostreqs.xml b/chapter02/hostreqs.xml index d8e6f06d2..6c74986a0 100644 --- a/chapter02/hostreqs.xml +++ b/chapter02/hostreqs.xml @@ -55,7 +55,7 @@ - Coreutils-6.9 + Coreutils-7.0 @@ -165,7 +165,7 @@ the ability to compile programs, run the following commands: cat > version-check.sh << "EOF" - #!/bin/bash +#!/bin/bash # A script to list version numbers of critical development tools # If you have tools installed in other directories, adjust PATH here AND @@ -185,7 +185,7 @@ ver_check() then echo "ERROR: Cannot find $2 ($1)"; return 1; fi - v=$($2 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+' | head -n1) + v=$($2 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1) if printf '%s\n' $3 $v | sort --version-sort --check &>/dev/null then printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0; @@ -197,7 +197,7 @@ ver_check() 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 &>/dev/null then 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 GCC gcc 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 M4 m4 1.4.10 ver_check Make make 4.0 @@ -241,7 +241,7 @@ alias_check awk GNU alias_check yacc Bison alias_check sh Bash -echo "Compiler check" +echo "Compiler check:" if printf "int main(){}" | g++ -x c++ - then echo "OK: g++ works"; else echo "ERROR: g++ does NOT work"; fi