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