source: common/libs/func_check_version.sh@ de63126

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since de63126 was 0850553, checked in by George Boudreau <georgeb@…>, 16 years ago

LFS has new build method. Added new vars to LFS/master.sh (JHuntwork)

  • Property mode set to 100644
File size: 6.7 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 declare -r spaceSTR=" "
26
27 ref_version=$1
28 tst_version=$2
29 TXT=$3
30
31 # This saves us the save/restore hassle of the system IFS value
32 local IFS
33
34 write_error_and_die() {
35 echo -e "\n\t\t$TXT version -->${tst_version}<-- is too old.
36 This script requires ${ref_version} or greater\n"
37 # Ask the user instead of bomb, to make happy that packages which version
38 # ouput don't follow our expectations
39 echo "If you are sure that you have instaled a proper version of ${BOLD}$TXT${OFF}"
40 echo "but jhalfs has failed to detect it, press 'c' and 'ENTER' keys to continue,"
41 echo -n "otherwise press 'ENTER' key to stop jhalfs. "
42 read ANSWER
43 if [ x$ANSWER != "xc" ] ; then
44 echo "${nl_}Please, install a proper $TXT version.${nl_}"
45 exit 1
46 else
47 minor=$ref_minor
48 revision=$ref_revision
49 fi
50 }
51
52 echo -ne "${TXT}${dotSTR:${#TXT}} ${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
53
54# echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
55 IFS=".-(pa" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
56 set -- $ref_version # set postional parameters to minimum ver values
57 ref_major=$1; ref_minor=$2; ref_revision=$3
58 #
59 set -- $tst_version # Set postional parameters to test version values
60 major=$1; minor=$2; revision=$3
61 #
62 # Compare against minimum acceptable version..
63 (( major > ref_major )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
64 (( major < ref_major )) && write_error_and_die
65 # major=ref_major
66 (( minor < ref_minor )) && write_error_and_die
67 (( minor > ref_minor )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
68 # minor=ref_minor
69 (( revision >= ref_revision )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
70
71 # oops.. write error msg and die
72 write_error_and_die
73}
74# local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
75
76#----------------------------#
77check_prerequisites() { #
78#----------------------------#
79
80 # Avoid translation of version strings
81 local LC_ALL=C
82 export LC_ALL
83
84 # LFS/HLFS/CLFS prerequisites
85 check_version "2.6.2" "`uname -r`" "KERNEL"
86 check_version "3.0" "$BASH_VERSION" "BASH"
87 check_version "3.0.1" "`gcc -dumpversion`" "GCC"
88 libcVer="`/lib/libc.so.6 | head -n1`"
89 libcVer="${libcVer##*version }"
90 check_version "2.2.5" ${libcVer%%,*} "GLIBC"
91 check_version "2.12" "$(ld --version | head -n1 | awk '{print $NF}')" "BINUTILS"
92 check_version "1.15" "$(tar --version | head -n1 | cut -d" " -f4)" "TAR"
93 bzip2Ver="$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f8)"
94 check_version "1.0.2" "${bzip2Ver%%,*}" "BZIP2"
95 check_version "1.875" "$(bison --version | head -n1 | cut -d" " -f4)" "BISON"
96 check_version "5.2.1" "$(chown --version | head -n1 | cut -d")" -f2)" "COREUTILS"
97 check_version "2.8" "$(diff --version | head -n1 | cut -d" " -f4)" "DIFF"
98 check_version "4.1.20" "$(find --version | head -n1 | cut -d" " -f4)" "FIND"
99 check_version "3.0" "$(gawk --version | head -n1 | cut -d" " -f3)" "GAWK"
100 check_version "2.5" "$(grep --version | head -n1 | awk '{print $NF}')" "GREP"
101 check_version "1.2.4" "$(gzip --version 2>&1 | head -n1 | cut -d" " -f2)" "GZIP"
102 check_version "1.4" "$(m4 --version 2>&1 | head -n1 | awk '{print $NF}')" "M4"
103 check_version "3.79.1" "$(make --version | head -n1 | cut -d " " -f3 | cut -c1-4)" "MAKE"
104 check_version "2.5.4" "$(patch --version | head -n1 | cut -d" " -f2)" "PATCH"
105 check_version "5.6.0" "$(perl -V:version | cut -f2 -d\')" "PERL"
106 check_version "3.0.2" "$(sed --version | head -n1 | cut -d" " -f4)" "SED"
107 check_version "4.8" "$(makeinfo --version | head -n1 | awk '{ print$NF }')" "TEXINFO"
108
109 # Check for minimum sudo version
110 SUDO_LOC="$(whereis -b sudo | cut -d" " -f2)"
111 if [ -x $SUDO_LOC ]; then
112 sudoVer="$(sudo -V | head -n1 | cut -d" " -f3)"
113 check_version "1.6.8" "${sudoVer}" "SUDO"
114 else
115 echo "${nl_}\"${RED}sudo${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
116 exit 1
117 fi
118
119 # Check for minimum libxml2 and libxslt versions
120 xsltprocVer=$(xsltproc -V | head -n1 )
121 libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
122 libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
123
124 # Version numbers are packed strings not xx.yy.zz format.
125 check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
126 check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
127
128 # The next versions checks are required only when BLFS_TOOL is set and
129 # this dependencies has not be selected for installation
130 if [[ "$BLFS_TOOL" = "y" ]] ; then
131
132 if [[ -z "$DEP_TIDY" ]] ; then
133 tidyVer=$(tidy -V | cut -d " " -f9)
134 check_version "2004" "${tidyVer}" "TIDY"
135 fi
136
137 # Check if the proper DocBook-XML-DTD and DocBook-XSL are correctly installed
138XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
139<?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/1.69.1/xhtml/docbook.xsl'?>
140<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
141 'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'>
142<article>
143 <title>Test file</title>
144 <sect1>
145 <title>Some title</title>
146 <para>Some text</para>
147 </sect1>
148</article>"
149
150 if [[ -z "$DEP_DBXML" ]] ; then
151 if `echo $XML_FILE | xmllint -noout -postvalid - 2>/dev/null` ; then
152 check_version "4.5" "4.5" "DocBook XML DTD"
153 else
154 echo "Warning: not found a working DocBook XML DTD 4.5 installation"
155 exit 2
156 fi
157 fi
158
159# if [[ -z "$DEP_DBXSL" ]] ; then
160# if `echo $XML_FILE | xsltproc --noout - 2>/dev/null` ; then
161# check_version "1.69.1" "1.69.1" "DocBook XSL"
162# else
163# echo "Warning: not found a working DocBook XSL 1.69.1 installation"
164# exit 2
165# fi
166# fi
167
168 fi # end BLFS_TOOL=Y
169
170}
Note: See TracBrowser for help on using the repository browser.