summaryrefslogtreecommitdiff
path: root/share/spack/qa/check_dependencies
blob: 292eac7dd32aaefa4ddad1c1dbc4f4a743ac538c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
#
# Description:
#     Check to see if dependencies are installed.
#     If not, warn the user and tell them how to
#     install these dependencies.
#
# Usage:
#     check-deps <dep> ...
#
# Options:
#     One or more dependencies. Must use name of binary.

for dep in "$@"; do
    if ! which $dep &> /dev/null; then
        # Map binary name to package name
        case $dep in
            sphinx-apidoc|sphinx-build)
                spack_package=py-sphinx
                pip_package=sphinx
                ;;
            coverage)
                spack_package=py-coverage
                pip_package=coverage
                ;;
            flake8)
                spack_package=py-flake8
                pip_package=flake8
                ;;
            hg)
                spack_package=py-mercurial
                pip_package=mercurial
                ;;
            *)
                spack_package=$dep
                pip_package=$dep
                ;;
        esac

        cat << EOF
ERROR: $dep is required to run this script.

To install with Spack, run:
    $ spack install $spack_package
or, to install with pip, run:
    $ pip install $pip_package
Then add the bin directory to your PATH.
EOF
        exit 1
    fi
done

echo "Dependencies found."