source: common/func_check_version.sh@ 3f1d46c

experimental
Last change on this file since 3f1d46c was 3f1d46c, checked in by George Boudreau <georgeb@…>, 18 years ago

Update test for book prerequisites

  • Property mode set to 100644
File size: 5.9 KB
Line 
1# $Id$
2
3check_version() {
4: <<inline_doc
5 Tests for a minimum version level. Compares to version numbers and forces an
6 exit if minimum level not met.
7 NOTE: This test will fail on versions containing alpha chars. ie. jpeg 6b
8
9 usage: check_version "2.6.2" "`uname -r`" "KERNEL"
10 check_version "3.0" "$BASH_VERSION" "BASH"
11 check_version "3.0" "`gcc -dumpversion`" "GCC"
12
13 input vars: $1=min acceptable version
14 $2=version to check
15 $3=app name
16 externals: --
17 modifies: --
18 returns: nothing
19 on error: write text to console and dies
20 on success: write text to console and returns
21inline_doc
22
23 declare -i major minor revision change
24 declare -i ref_major ref_minor ref_revision ref_change
25
26 ref_version=$1
27 tst_version=$2
28 TXT=$3
29
30 # This saves us the save/restore hassle of the system IFS value
31 local IFS
32
33 write_error_and_die() {
34 echo -e "\n\t\t$TXT version -->${tst_version}<-- is too old.
35 This script requires ${ref_version} or greater\n"
36 exit 1
37 }
38
39 echo -ne "${TXT}${dotSTR:${#TXT}}${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
40
41# echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
42 IFS=".-(p" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
43 set -- $ref_version # set postional parameters to minimum ver values
44 ref_major=$1; ref_minor=$2; ref_revision=$3
45 #
46 set -- $tst_version # Set postional parameters to test version values
47 major=$1; minor=$2; revision=$3
48 #
49 # Compare against minimum acceptable version..
50 (( major > ref_major )) && echo " ..${GREEN}OK${OFF}" && return
51 (( major < ref_major )) && write_error_and_die
52 # major=ref_major
53 (( minor < ref_minor )) && write_error_and_die
54 (( minor > ref_minor )) && echo " ..${GREEN}OK${OFF}" && return
55 # minor=ref_minor
56 (( revision >= ref_revision )) && echo " ..${GREEN}OK${OFF}" && return
57
58 # oops.. write error msg and die
59 write_error_and_die
60}
61
62#----------------------------#
63check_prerequisites() { #
64#----------------------------#
65
66 # LFS/HLFS/CLFS prerequisites
67 if [ ! "${PROGNAME}" = "hlfs" ]; then
68 check_version "2.6.2" "`uname -r`" "KERNEL"
69 check_version "2.0.5" "$BASH_VERSION" "BASH"
70 check_version "3.0.0" "`gcc -dumpversion`" "GCC"
71 check_version "1.14" "`tar --version | head -n1 | cut -d \" \" -f4`" "TAR"
72 check_version "1.12" "`ld --version | head -n1 | cut -d\" \" -f4`" "BINUTILS"
73 bzip2Ver="`bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d\" \" -f8`"
74 check_version "1.0.3" "${bzip2Ver%%,*}" "BZIP2"
75 check_version "5.0" "`chown --version | head -n1 | cut -d\")\" -f2`" "COREUTILS"
76 check_version "2.8" "`diff --version | head -n1 | cut -d \" \" -f4`" "DIFF"
77 check_version "4.1.20" "`find --version | head -n1 | cut -d \" \" -f4`" "FIND"
78 check_version "3.0" "`gawk --version | head -n1 | cut -d \" \" -f3`" "GAWK"
79# /lib/libc.so.6 | head -n1 | cut -d" " -f1-7
80 check_version "2.5" "`grep --version | head -n1 | cut -d \" \" -f4`" "GREP"
81# #echo -n "gzip: "; gzip --version | head -n1
82 check_version "3.79.1" "`make --version | head -n1 | cut -d \" \" -f3`" "MAKE"
83 check_version "2.5.4" "`patch --version | head -n1 | cut -d \" \" -f2`" "PATCH"
84 check_version "3.0.2" "`sed --version | head -n1 | cut -d \" \" -f4`" "SED"
85 else
86 # LFS/HLFS/CLFS prerequisites
87 check_version "2.6.2" "`uname -r`" "KERNEL"
88 check_version "3.0" "$BASH_VERSION" "BASH"
89 check_version "3.0" "`gcc -dumpversion`" "GCC"
90 check_version "1.1" "`tar --version | head -n1 | cut -d \" \" -f4`" "TAR"
91 fi
92
93 # Check for minimum sudo version
94 SUDO_LOC="`whereis -b sudo | cut -d " " -f2`"
95 if [ -x $SUDO_LOC ]; then
96 sudoVer=`sudo -V | head -n1 | cut -d " " -f3`
97 check_version "1.6.8" "${sudoVer}" "SUDO"
98 else
99 echo "${nl_}\"${RED}sudo${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
100 exit 1
101 fi
102
103 # Check for minimum libxml2 and libxslt versions
104 xsltprocVer=`xsltproc -V | head -n1 `
105 libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
106 libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
107
108 # Version numbers are packed strings not xx.yy.zz format.
109 check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
110 check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
111
112 # The next versions checks are required only when BLFS_TOOL is set and
113 # this dependencies has not be selected for installation
114 if [[ "$BLFS_TOOL" = "y" ]] ; then
115
116 if [[ -z "$DEP_TIDY" ]] ; then
117 tidyVer=`tidy -V | cut -d " " -f9`
118 check_version "2004" "${tidyVer}" "TIDY"
119 fi
120
121 # Check if the proper DocBook-XML-DTD and DocBook-XSL are correctly installed
122XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
123<?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/1.69.1/xhtml/docbook.xsl'?>
124<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'
125 'http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd'>
126<article>
127 <title>Test file</title>
128 <sect1>
129 <title>Some title</title>
130 <para>Some text</para>
131 </sect1>
132</article>"
133
134 if [[ -z "$DEP_DBXML" ]] ; then
135 if `echo $XML_FILE | xmllint -noout -postvalid - 2>/dev/null` ; then
136 check_version "4.4" "4.4" "DocBook XML DTD"
137 else
138 echo "Warning: not found a working DocBook XML DTD 4.4 installation"
139 exit 2
140 fi
141 fi
142
143 if [[ -z "$DEP_DBXSL" ]] ; then
144 if `echo $XML_FILE | xsltproc --noout - 2>/dev/null` ; then
145 check_version "1.69.1" "1.69.1" "DocBook XSL"
146 else
147 echo "Warning: not found a working DocBook XSL 1.69.1 installation"
148 exit 2
149 fi
150 fi
151
152 fi # end BLFS_TOOL=Y
153
154}
Note: See TracBrowser for help on using the repository browser.