Add libjack-dev to install_prereq.
[asterisk/asterisk.git] / contrib / scripts / install_prereq
1 #! /bin/sh
2 #
3 # $Id$
4 #
5
6 # install_prereq: a script to install distribution-specific
7 # prerequirements
8
9 set -e
10
11 usage() {
12   echo "$0: a script to install distribution-specific prerequirement"
13   echo 'Revision: $Id$'
14   echo ""
15   echo "Usage: $0:                    Shows this message."
16   echo "Usage: $0 test                Prints commands it is about to run."
17   echo "Usage: $0 install             Really install."
18   echo "Usage: $0 install-unpackaged  Really install unpackaged requirements."
19 }
20
21 # Basic build system:
22 PACKAGES_DEBIAN="build-essential"
23 # Asterisk: basic requirements:
24 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev"
25 # Asterisk: for addons:
26 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev"
27 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libsqlite3-dev libmysqlclient15-dev libneon27-dev libgmime-2.0-2-dev libusb-dev liblua5.1-0-dev"
28 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev"
29 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libopenais-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
30
31 PACKAGES_RH="gcc gcc-c++ ncurses-devel openssl-devel"
32
33 PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"
34
35 KVERS=`uname -r`
36
37 case "$1" in
38 test)    testcmd=echo ;;
39 install) testcmd='' ;;
40 install-unpackaged) unpackaged="yes" ;;
41 '') usage; exit 0 ;;
42 *) usage; exit 1 ;;
43 esac
44
45 in_test_mode() {
46   test "$testcmd" != ''
47 }
48
49 check_installed_debs() {
50         aptitude -F '%c %p' search "$@" 2>/dev/null \
51         | awk '/^p/{print $2}'
52 }
53
54 # parsing the output of yum is close to impossible.
55 # We'll use rpm and hope for the best:
56 check_installed_rpms() {
57         for pack in "$@"
58         do
59                 if ! rpm -q $pack >/dev/null 2>/dev/null
60                 then echo $pack
61                 fi
62         done
63 }
64
65 check_installed_pkgs() {
66         for pack in "$@"
67         do
68                 if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
69                 echo $pack
70                 fi
71         done
72 }
73
74 handle_debian() {
75         # echo "# Distribution is Debian or compatible"
76         extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
77         $testcmd aptitude install -y $extra_packs
78 }
79
80 handle_rh() {
81         # echo "# Distribution is RedHat-based or compatible"
82         extra_packs=`check_installed_rpms $PACKAGES_RH`
83         # FIXME: is there yum with RHEL 4?
84         $testcmd yum install -y $extra_packs
85 }
86
87 handle_obsd() {
88         # echo "# Distribution is OpenBSD or compatible"
89         extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
90         $testcmd pkg_add $extra_packs
91 }
92
93 install_unpackaged() {
94         echo "*** Installing NBS (Network Broadcast Sound) ***"
95         svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
96         cd nbs-trunk
97         make && make install
98         cd ..
99
100         echo "*** Installing libresample ***"
101         svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
102         cd libresample-trunk
103         ./configure && make && make install
104         cd ..
105 }
106
107 if in_test_mode; then
108         echo "#############################################"
109         echo "## $1: test mode."
110         echo "## Use the commands here to install your system."
111         echo "#############################################"
112 elif test "${unpackaged}" = "yes" ; then
113         install_unpackaged
114         exit 0
115 fi
116
117 OS=`uname -s`
118 unsupported_distro=''
119
120 # A number of distributions we don't (yet?) support.
121 if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
122   echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
123   exit 1
124 fi
125
126 if [ -f /etc/gentoo-release ]; then
127   unsupported_distro='Gentoo'
128 fi
129
130 if [ -f /etc/mandrake-release ]; then
131   unsupported_distro='Mandriva'
132 fi
133
134 if [ -f /etc/SuSE-release ]; then
135   unsupported_distro='SUSE'
136 fi
137
138 if [ -f /etc/slackware-version ]; then
139   unsupported_distro='Slackware'
140 fi
141
142 if [ "$unsupported_distro" != '' ]; then
143   echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
144   exit 1
145 fi
146
147 # The distributions we do support:
148 if [ -r /etc/debian_version ]; then
149   handle_debian
150 elif [ -r /etc/redhat-release ]; then
151   handle_rh
152 elif [ "$OS" = 'OpenBSD' ]; then
153   handle_obsd
154 fi
155
156 if ! in_test_mode; then
157   echo "#############################################"
158   echo "## $1 completed successfully"
159   echo "#############################################"
160 fi