|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Apache 2.0. Copyright 2011-2016 Johns Hopkins University (author: Daniel |
| 4 | +# Povey) |
| 5 | + |
| 6 | +# this script is based on the check_dependencies.sh script in Kaldi. |
| 7 | + |
| 8 | +# at some point we could try to add packages for Cywgin or macports(?) to this |
| 9 | +# script. |
| 10 | +redhat_packages= |
| 11 | +debian_packages= |
| 12 | +opensuse_packages= |
| 13 | + |
| 14 | +function add_packages { |
| 15 | + redhat_packages="$redhat_packages $1"; |
| 16 | + debian_packages="$debian_packages $2"; |
| 17 | + opensuse_packages="$opensuse_packages $3"; |
| 18 | +} |
| 19 | + |
| 20 | +if ! which g++ >&/dev/null; then |
| 21 | + echo "$0: g++ is not installed." |
| 22 | + add_packages gcc-c++ g++ gcc-c++ |
| 23 | +fi |
| 24 | + |
| 25 | +for f in make gcc grep gzip git; do |
| 26 | + if ! which $f >&/dev/null; then |
| 27 | + echo "$0: $f is not installed." |
| 28 | + add_packages $f $f $f |
| 29 | + fi |
| 30 | +done |
| 31 | + |
| 32 | +if ! which svn >&/dev/null; then |
| 33 | + echo "$0: subversion is not installed" |
| 34 | + add_packages subversion subversion subversion |
| 35 | +fi |
| 36 | + |
| 37 | +if ! which awk >&/dev/null; then |
| 38 | + echo "$0: awk is not installed" |
| 39 | + add_packages gawk gawk gawk |
| 40 | +fi |
| 41 | + |
| 42 | +if which python >&/dev/null ; then |
| 43 | + version=`python 2>&1 --version | awk '{print $2}' ` |
| 44 | + if [[ $version != "2."* ]] ; then |
| 45 | + if which python2.7 >&/dev/null || which python2 >&/dev/null ; then |
| 46 | + echo "$0: python 2.x is not the default python. You should either make it" |
| 47 | + echo "$0: default or create an bash alias for kaldi scripts to run correctly" |
| 48 | + else |
| 49 | + echo "$0: python 2.x is not installed" |
| 50 | + add_packages python2.7 python2.7 python2.7 |
| 51 | + fi |
| 52 | + fi |
| 53 | +else |
| 54 | + echo "$0: python 2.7 is not installed" |
| 55 | + add_packages python2.7 python2.7 python2.7 |
| 56 | +fi |
| 57 | + |
| 58 | +if ! python -c 'import numpy' >&/dev/null; then |
| 59 | + echo "$0: python-numpy is not installed" |
| 60 | + # I'm not sure if this package name is OK for all distributions, this is what |
| 61 | + # it seems to be called on Debian. We'll have to investigate this. |
| 62 | + add_packages python-numpy python-numpy python-numpy |
| 63 | +fi |
| 64 | + |
| 65 | +printed=false |
| 66 | +status=0 |
| 67 | + |
| 68 | +if which apt-get >&/dev/null && ! which zypper >/dev/null; then |
| 69 | + # if we're using apt-get [but we're not OpenSuse, which uses zypper as the |
| 70 | + # primary installer, but sometimes installs apt-get for some compatibility |
| 71 | + # reason without it really working]... |
| 72 | + if [ ! -z "$debian_packages" ]; then |
| 73 | + echo "$0: we recommend that you run (our best guess):" |
| 74 | + echo " sudo apt-get install $debian_packages" |
| 75 | + printed=true |
| 76 | + status=1 |
| 77 | + fi |
| 78 | + if ! dpkg -l | grep -E 'libatlas3gf|libatlas3-base' >/dev/null; then |
| 79 | + echo "You should probably do: " |
| 80 | + echo " sudo apt-get install libatlas3-base" |
| 81 | + printed=true |
| 82 | + fi |
| 83 | + # Debian systems generally link /bin/sh to dash, which doesn't work |
| 84 | + # with some scripts as it doesn't expand x.{1,2}.y to x.1.y x.2.y |
| 85 | + if [ $(readlink /bin/sh) == "dash" ]; then |
| 86 | + echo "/bin/sh is linked to dash, and currently some of the scripts will not run" |
| 87 | + echo "properly. We recommend to run:" |
| 88 | + echo " sudo ln -s -f bash /bin/sh" |
| 89 | + printed=true |
| 90 | + fi |
| 91 | +fi |
| 92 | + |
| 93 | +if which yum >&/dev/null; then |
| 94 | + if [ ! -z "$redhat_packages" ]; then |
| 95 | + echo "$0: we recommend that you run (our best guess):" |
| 96 | + echo " sudo yum install $redhat_packages" |
| 97 | + printed=true |
| 98 | + status=1 |
| 99 | + fi |
| 100 | + if ! rpm -qa| grep atlas >/dev/null; then |
| 101 | + echo "You should probably do something like: " |
| 102 | + echo "sudo yum install atlas.x86_64" |
| 103 | + printed=true |
| 104 | + fi |
| 105 | +fi |
| 106 | + |
| 107 | +if which zypper >&/dev/null; then |
| 108 | + if [ ! -z "$opensuse_packages" ]; then |
| 109 | + echo "$0: we recommend that you run (our best guess):" |
| 110 | + echo " sudo zypper install $opensuse_packages" |
| 111 | + printed=true |
| 112 | + status=1 |
| 113 | + fi |
| 114 | + if ! zypper search -i | grep -E 'libatlas3|libatlas3-devel' >/dev/null; then |
| 115 | + echo "You should probably do: " |
| 116 | + echo "sudo zypper install libatlas3-devel" |
| 117 | + printed=true |
| 118 | + fi |
| 119 | +fi |
| 120 | + |
| 121 | +if [ ! -z "$debian_packages" ]; then |
| 122 | + # If the list of packages to be installed is nonempty, |
| 123 | + # we'll exit with error status. Check this outside of |
| 124 | + # hecking for yum or apt-get, as we want it to exit with |
| 125 | + # error even if we're not on Debian or red hat. |
| 126 | + status=1 |
| 127 | +fi |
| 128 | + |
| 129 | + |
| 130 | +if [ $(pwd | wc -w) -gt 1 ]; then |
| 131 | + echo "*** $0: Warning: pocolm scripts may fail if the directory name contains a space." |
| 132 | + echo "*** (it's OK if you just want to compile a few tools -> disable this check)." |
| 133 | + status=1; |
| 134 | +fi |
| 135 | + |
| 136 | +if ! $printed && [ $status -eq 0 ]; then |
| 137 | + echo "$0: all OK." |
| 138 | +fi |
| 139 | + |
| 140 | + |
| 141 | +exit $status |
0 commit comments