aboutsummaryrefslogtreecommitdiffstats
path: root/chapter02/hostreqs.xml
diff options
context:
space:
mode:
authorBruce Dubbs <bdubbs@linuxfromscratch.org>2023-03-04 16:26:31 -0600
committerBruce Dubbs <bdubbs@linuxfromscratch.org>2023-03-04 16:26:31 -0600
commit140e9a445dd1321d5bb617a1058c3a1ccd0a5953 (patch)
tree7877b233517998cb6e63468b07df3c6b6f38e52f /chapter02/hostreqs.xml
parent779b798e5fd717b603d34c882d0faf563ef0ffe6 (diff)
q
Diffstat (limited to 'chapter02/hostreqs.xml')
-rw-r--r--chapter02/hostreqs.xml150
1 files changed, 81 insertions, 69 deletions
diff --git a/chapter02/hostreqs.xml b/chapter02/hostreqs.xml
index 52ccc97ed..d8e6f06d2 100644
--- a/chapter02/hostreqs.xml
+++ b/chapter02/hostreqs.xml
@@ -165,78 +165,90 @@
the ability to compile programs, run the following commands:</para>
<screen role="nodump"><userinput>cat &gt; version-check.sh &lt;&lt; "EOF"
-<literal>#!/bin/bash
-# Simple script to list version numbers of critical development tools
-export LC_ALL=C
-bash --version | head -n1 | cut -d" " -f2-4
-MYSH=$(readlink -f /bin/sh)
-echo "/bin/sh -&gt; $MYSH"
-echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
-unset MYSH
-
-echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
-bison --version | head -n1
-
-if [ -h /usr/bin/yacc ]; then
- echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
-elif [ -x /usr/bin/yacc ]; then
- echo yacc is `/usr/bin/yacc --version | head -n1`
-else
- echo "yacc not found"
-fi
-
-echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
-diff --version | head -n1
-find --version | head -n1
-gawk --version | head -n1
-
-if [ -h /usr/bin/awk ]; then
- echo "/usr/bin/awk -&gt; `readlink -f /usr/bin/awk`";
-elif [ -x /usr/bin/awk ]; then
- echo awk is `/usr/bin/awk --version | head -n1`
-else
- echo "awk not found"
-fi
-
-gcc --version | head -n1
-g++ --version | head -n1
-grep --version | head -n1
-gzip --version | head -n1
-cat /proc/version
-m4 --version | head -n1
-make --version | head -n1
-patch --version | head -n1
-echo Perl `perl -V:version`
-python3 --version
-sed --version | head -n1
-tar --version | head -n1
-makeinfo --version | head -n1 # texinfo version
-xz --version | head -n1
-
-echo 'int main(){}' &gt; dummy.c &amp;&amp; g++ -o dummy dummy.c
-if [ -x dummy ]
- then echo "g++ compilation OK";
- else echo "g++ compilation failed"; fi
-rm -f dummy.c dummy</literal>
+<literal> #!/bin/bash
+# A script to list version numbers of critical development tools
+
+# If you have tools installed in other directories, adjust PATH here AND
+# in ~lfs/.bashrc (section 4.4) as well.
+
+LC_ALL=C
+PATH=/usr/bin:/bin
+
+bail() { echo "FATAL: $1"; exit 1; }
+grep --version > /dev/null 2> /dev/null || bail "grep does not work"
+sed '' /dev/null || bail "sed does not work"
+sort /dev/null || bail "sort does not work"
+
+ver_check()
+{
+ if ! type -p $2 &amp;>/dev/null
+ then
+ echo "ERROR: Cannot find $2 ($1)"; return 1;
+ fi
+ v=$($2 --version 2>&amp;1 | grep -E -o '[0-9]+\.[0-9\.]+' | head -n1)
+ if printf '%s\n' $3 $v | sort --version-sort --check &amp;>/dev/null
+ then
+ printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0;
+ else
+ printf "ERROR: %-9s is TOO OLD ($3 or later required)\n" "$1";
+ return 1;
+ fi
+}
+
+ver_kernel()
+{
+ kver=$(uname -r | sed -E 's/^([0-9\.]+).*/\1/')
+ if printf '%s\n' $1 $kver | sort --version-sort --check &amp;>/dev/null
+ then
+ printf "OK: Linux Kernel $kver >= $1\n"; return 0;
+ else
+ printf "ERROR: Linux Kernel ($kver) is TOO OLD ($1 or later required)\n" "$kver";
+ return 1;
+ fi
+}
+
+# Coreutils first because-sort needs Coreutils >= 7.0
+ver_check Coreutils sort 7.0 || bail "--version-sort unsupported"
+ver_check Bash bash 3.2
+ver_check Binutils ld 2.13.1
+ver_check Bison bison 2.7
+ver_check Diffutils diff 2.8.1
+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 Gzip gzip 1.3.12
+ver_check M4 m4 1.4.10
+ver_check Make make 4.0
+ver_check Patch patch 2.5.4
+ver_check Perl perl 5.8.8
+ver_check Python python3 3.4
+ver_check Sed sed 4.1.5
+ver_check Tar tar 1.22
+ver_check Texinfo texi2any 4.7
+ver_check Xz xz 5.0.0
+#ver_check "Linux Kernel" "" 3.2 'cat /proc/version'
+ver_kernel 3.2
+
+alias_check() {
+ if $1 --version 2>&amp;1 | grep -qi $2
+ then printf "OK: %-4s is $2\n" "$1";
+ else printf "ERROR: %-4s is NOT $2\n" "$1"; fi
+}
+echo "Aliases:"
+alias_check awk GNU
+alias_check yacc Bison
+alias_check sh Bash
+
+echo "Compiler check"
+if printf "int main(){}" | g++ -x c++ -
+then echo "OK: g++ works";
+else echo "ERROR: g++ does NOT work"; fi
+rm -f a.out</literal>
EOF
bash version-check.sh</userinput></screen>
-<!--
- <para>Also check for some library consistency:</para>
-
-<screen role="nodump"><userinput>cat &gt; library-check.sh &lt;&lt; "EOF"
-<literal>#!/bin/bash
-for lib in lib{gmp,mpfr,mpc}.la; do
- echo $lib: $(if find /usr/lib* -name $lib|
- grep -q $lib;then :;else echo not;fi) found
-done
-unset lib</literal>
-EOF
-
-bash library-check.sh</userinput></screen>
-<para>The files identified by this script should be all present
-or all absent, but not only one or two present.</para>
--->
</sect2>
</sect1>