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