Add libradiusclient-ng-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 }
19
20 # Basic build system:
21 PACKAGES_DEBIAN="build-essential"
22 # Asterisk: basic requirements:
23 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev"
24 # Asterisk: for addons:
25 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev"
26 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"
27 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev"
28 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev "
29
30 PACKAGES_RH="gcc gcc-c++ ncurses-devel openssl-devel"
31
32 PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"
33
34 KVERS=`uname -r`
35
36 case "$1" in
37 test)    testcmd=echo ;;
38 install) testcmd='' ;;
39 '') usage; exit 0 ;;
40 *) usage; exit 1 ;;
41 esac
42
43 in_test_mode() {
44   test "$testcmd" != ''
45 }
46
47 check_installed_debs() {
48         aptitude -F '%c %p' search "$@" 2>/dev/null \
49         | awk '/^p/{print $2}'
50 }
51
52 # parsing the output of yum is close to impossible.
53 # We'll use rpm and hope for the best:
54 check_installed_rpms() {
55         for pack in "$@"
56         do
57                 if ! rpm -q $pack >/dev/null 2>/dev/null
58                 then echo $pack
59                 fi
60         done
61 }
62
63 check_installed_pkgs() {
64         for pack in "$@"
65         do
66                 if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
67                 echo $pack
68                 fi
69         done
70 }
71
72 handle_debian() {
73         # echo "# Distribution is Debian or compatible"
74         extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
75         $testcmd aptitude install -y $extra_packs
76 }
77
78 handle_rh() {
79         # echo "# Distribution is RedHat-based or compatible"
80         extra_packs=`check_installed_rpms $PACKAGES_RH`
81         # FIXME: is there yum with RHEL 4?
82         $testcmd yum install -y $extra_packs
83 }
84
85 handle_obsd() {
86         # echo "# Distribution is OpenBSD or compatible"
87         extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
88         $testcmd pkg_add $extra_packs
89 }
90
91 if in_test_mode; then
92         echo "#############################################"
93         echo "## $1: test mode."
94         echo "## Use the commands here to install your system."
95         echo "#############################################"
96 fi
97
98 OS=`uname -s`
99 unsupported_distro=''
100
101 # A number of distributions we don't (yet?) support.
102 if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
103   echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
104   exit 1
105 fi
106
107 if [ -f /etc/gentoo-release ]; then
108   unsupported_distro='Gentoo'
109 fi
110
111 if [ -f /etc/mandrake-release ]; then
112   unsupported_distro='Mandriva'
113 fi
114
115 if [ -f /etc/SuSE-release ]; then
116   unsupported_distro='SUSE'
117 fi
118
119 if [ -f /etc/slackware-version ]; then
120   unsupported_distro='Slackware'
121 fi
122
123 if [ "$unsupported_distro" != '' ]; then
124   echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
125   exit 1
126 fi
127
128 # The distributions we do support:
129 if [ -r /etc/debian_version ]; then
130   handle_debian
131 elif [ -r /etc/redhat-release ]; then
132   handle_rh
133 elif [ "$OS" = 'OpenBSD' ]; then
134   handle_obsd
135 fi
136
137 if ! in_test_mode; then
138   echo "#############################################"
139   echo "## $1 completed successfully"
140   echo "#############################################"
141 fi