[877cc6a] | 1 | # $Id$
|
---|
| 2 |
|
---|
| 3 | check_version() {
|
---|
| 4 | : <<inline_doc
|
---|
[045b2dc] | 5 | Tests for a minimum version level. Compares to version numbers and forces an
|
---|
[877cc6a] | 6 | exit if minimum level not met.
|
---|
| 7 | NOTE: This test will fail on versions containing alpha chars. ie. jpeg 6b
|
---|
[045b2dc] | 8 |
|
---|
[877cc6a] | 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
|
---|
[045b2dc] | 25 | declare -r spaceSTR=" "
|
---|
[877cc6a] | 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 | exit 1
|
---|
| 38 | }
|
---|
| 39 |
|
---|
[045b2dc] | 40 | echo -ne "${TXT}${dotSTR:${#TXT}} ${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
|
---|
| 41 |
|
---|
| 42 | # echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
|
---|
[020f4dc] | 43 | IFS=".-(pa" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
|
---|
[877cc6a] | 44 | set -- $ref_version # set postional parameters to minimum ver values
|
---|
| 45 | ref_major=$1; ref_minor=$2; ref_revision=$3
|
---|
| 46 | #
|
---|
| 47 | set -- $tst_version # Set postional parameters to test version values
|
---|
| 48 | major=$1; minor=$2; revision=$3
|
---|
| 49 | #
|
---|
| 50 | # Compare against minimum acceptable version..
|
---|
[045b2dc] | 51 | (( major > ref_major )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
|
---|
[877cc6a] | 52 | (( major < ref_major )) && write_error_and_die
|
---|
| 53 | # major=ref_major
|
---|
| 54 | (( minor < ref_minor )) && write_error_and_die
|
---|
[045b2dc] | 55 | (( minor > ref_minor )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
|
---|
[877cc6a] | 56 | # minor=ref_minor
|
---|
[045b2dc] | 57 | (( revision >= ref_revision )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
|
---|
[877cc6a] | 58 |
|
---|
| 59 | # oops.. write error msg and die
|
---|
| 60 | write_error_and_die
|
---|
| 61 | }
|
---|
[045b2dc] | 62 | # local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 63 |
|
---|
| 64 | #----------------------------#
|
---|
| 65 | check_prerequisites() { #
|
---|
| 66 | #----------------------------#
|
---|
| 67 |
|
---|
| 68 | # LFS/HLFS/CLFS prerequisites
|
---|
| 69 | if [ ! "${PROGNAME}" = "hlfs" ]; then
|
---|
| 70 | check_version "2.6.2" "`uname -r`" "KERNEL"
|
---|
| 71 | check_version "2.0.5" "$BASH_VERSION" "BASH"
|
---|
[020f4dc] | 72 | check_version "3.0.1" "`gcc -dumpversion`" "GCC"
|
---|
[045b2dc] | 73 | libcVer="`/lib/libc.so.6 | head -n1`"
|
---|
| 74 | libcVer="${libcVer##*version }"
|
---|
| 75 | check_version "2.2.5" ${libcVer%%,*} "GLIBC"
|
---|
| 76 | check_version "2.12" "$(ld --version | head -n1 | cut -d" " -f4)" "BINUTILS"
|
---|
| 77 | check_version "1.14" "$(tar --version | head -n1 | cut -d" " -f4)" "TAR"
|
---|
| 78 | bzip2Ver="$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f8)"
|
---|
| 79 | check_version "1.0.2" "${bzip2Ver%%,*}" "BZIP2"
|
---|
[020f4dc] | 80 | check_version "1.26a" "$(bison --version | head -n1 | cut -d" " -f4)" "BISON"
|
---|
[045b2dc] | 81 | check_version "5.0" "$(chown --version | head -n1 | cut -d")" -f2)" "COREUTILS"
|
---|
| 82 | check_version "2.8" "$(diff --version | head -n1 | cut -d" " -f4)" "DIFF"
|
---|
| 83 | check_version "4.1.20" "$(find --version | head -n1 | cut -d" " -f4)" "FIND"
|
---|
| 84 | check_version "3.0" "$(gawk --version | head -n1 | cut -d" " -f3)" "GAWK"
|
---|
| 85 | check_version "2.5" "$(grep --version | head -n1 | cut -d" " -f4)" "GREP"
|
---|
| 86 | check_version "1.2.4" "$(gzip --version 2>&1 | head -n1 | cut -d" " -f2)" "GZIP"
|
---|
[ae3966e] | 87 | check_version "3.79.1" "$(make --version | head -n1 | cut -d " " -f3 | cut -c1-4)" "MAKE"
|
---|
[045b2dc] | 88 | check_version "2.5.4" "$(patch --version | head -n1 | cut -d" " -f2)" "PATCH"
|
---|
| 89 | check_version "3.0.2" "$(sed --version | head -n1 | cut -d" " -f4)" "SED"
|
---|
| 90 | else
|
---|
| 91 | # HLFS prerequisites
|
---|
| 92 | check_version "2.6.2" "$(uname -r)" "KERNEL"
|
---|
| 93 | check_version "3.0" "$BASH_VERSION" "BASH"
|
---|
| 94 | check_version "3.0" "$(gcc -dumpversion)" "GCC"
|
---|
| 95 | check_version "1.14" "$(tar --version | head -n1 | cut -d" " -f4)" "TAR"
|
---|
| 96 | fi
|
---|
| 97 |
|
---|
| 98 | # Check for minimum sudo version
|
---|
| 99 | SUDO_LOC="$(whereis -b sudo | cut -d" " -f2)"
|
---|
| 100 | if [ -x $SUDO_LOC ]; then
|
---|
| 101 | sudoVer="$(sudo -V | head -n1 | cut -d" " -f3)"
|
---|
| 102 | check_version "1.6.8" "${sudoVer}" "SUDO"
|
---|
| 103 | else
|
---|
| 104 | echo "${nl_}\"${RED}sudo${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
|
---|
| 105 | exit 1
|
---|
| 106 | fi
|
---|
| 107 |
|
---|
| 108 | # Check for minimum libxml2 and libxslt versions
|
---|
| 109 | xsltprocVer=$(xsltproc -V | head -n1 )
|
---|
| 110 | libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
|
---|
| 111 | libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
|
---|
| 112 |
|
---|
| 113 | # Version numbers are packed strings not xx.yy.zz format.
|
---|
| 114 | check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
|
---|
| 115 | check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
|
---|
| 116 |
|
---|
| 117 | # The next versions checks are required only when BLFS_TOOL is set and
|
---|
| 118 | # this dependencies has not be selected for installation
|
---|
| 119 | if [[ "$BLFS_TOOL" = "y" ]] ; then
|
---|
| 120 |
|
---|
| 121 | if [[ -z "$DEP_TIDY" ]] ; then
|
---|
| 122 | tidyVer=$(tidy -V | cut -d " " -f9)
|
---|
| 123 | check_version "2004" "${tidyVer}" "TIDY"
|
---|
| 124 | fi
|
---|
| 125 |
|
---|
| 126 | # Check if the proper DocBook-XML-DTD and DocBook-XSL are correctly installed
|
---|
| 127 | XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
|
---|
| 128 | <?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/1.69.1/xhtml/docbook.xsl'?>
|
---|
| 129 | <!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'
|
---|
| 130 | 'http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd'>
|
---|
| 131 | <article>
|
---|
| 132 | <title>Test file</title>
|
---|
| 133 | <sect1>
|
---|
| 134 | <title>Some title</title>
|
---|
| 135 | <para>Some text</para>
|
---|
| 136 | </sect1>
|
---|
| 137 | </article>"
|
---|
| 138 |
|
---|
| 139 | if [[ -z "$DEP_DBXML" ]] ; then
|
---|
| 140 | if `echo $XML_FILE | xmllint -noout -postvalid - 2>/dev/null` ; then
|
---|
| 141 | check_version "4.4" "4.4" "DocBook XML DTD"
|
---|
| 142 | else
|
---|
| 143 | echo "Warning: not found a working DocBook XML DTD 4.4 installation"
|
---|
| 144 | exit 2
|
---|
| 145 | fi
|
---|
| 146 | fi
|
---|
| 147 |
|
---|
| 148 | if [[ -z "$DEP_DBXSL" ]] ; then
|
---|
| 149 | if `echo $XML_FILE | xsltproc --noout - 2>/dev/null` ; then
|
---|
| 150 | check_version "1.69.1" "1.69.1" "DocBook XSL"
|
---|
| 151 | else
|
---|
| 152 | echo "Warning: not found a working DocBook XSL 1.69.1 installation"
|
---|
| 153 | exit 2
|
---|
| 154 | fi
|
---|
| 155 | fi
|
---|
| 156 |
|
---|
| 157 | fi # end BLFS_TOOL=Y
|
---|
[877cc6a] | 158 |
|
---|
[045b2dc] | 159 | } |
---|