aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/scripts/install_prereq
blob: bbcd212fac73599848b8b089ed56d34ff4d7ef6f (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#! /bin/sh
#
# $Id$
#

# install_prereq: a script to install distribution-specific
# prerequirements

set -e

usage() {
  echo "$0: a script to install distribution-specific prerequirement"
  echo 'Revision: $Id$'
  echo ""
  echo "Usage: $0:                    Shows this message."
  echo "Usage: $0 test                Prints commands it is about to run."
  echo "Usage: $0 install             Really install."
  echo "Usage: $0 install-unpackaged  Really install unpackaged requirements."
}

# Basic build system:
PACKAGES_DEBIAN="build-essential"
# Asterisk: basic requirements:
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev"
# Asterisk: for addons:
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev"
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"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libopenais-dev"

PACKAGES_RH="gcc gcc-c++ ncurses-devel openssl-devel"

PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"

KVERS=`uname -r`

case "$1" in
test)    testcmd=echo ;;
install) testcmd='' ;;
install-unpackaged) unpackaged="yes" ;;
'') usage; exit 0 ;;
*) usage; exit 1 ;;
esac

in_test_mode() {
  test "$testcmd" != ''
}

check_installed_debs() {
	aptitude -F '%c %p' search "$@" 2>/dev/null \
	| awk '/^p/{print $2}'
}

# parsing the output of yum is close to impossible.
# We'll use rpm and hope for the best:
check_installed_rpms() {
	for pack in "$@"
	do
		if ! rpm -q $pack >/dev/null 2>/dev/null
		then echo $pack
		fi
	done
}

check_installed_pkgs() {
	for pack in "$@"
	do
		if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
		echo $pack
		fi
	done
}

handle_debian() {
	# echo "# Distribution is Debian or compatible"
	extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
	$testcmd aptitude install -y $extra_packs
}

handle_rh() {
	# echo "# Distribution is RedHat-based or compatible"
	extra_packs=`check_installed_rpms $PACKAGES_RH`
        # FIXME: is there yum with RHEL 4?
	$testcmd yum install -y $extra_packs
}

handle_obsd() {
	# echo "# Distribution is OpenBSD or compatible"
	extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
	$testcmd pkg_add $extra_packs
}

install_unpackaged() {
	echo "*** Installing NBS (Network Broadcast Sound) ***"
	svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
	cd nbs-trunk
	make && make install
	cd ..

	echo "*** Installing libresample ***"
	svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
	cd libresample-trunk
	./configure && make && make install
	cd ..
}

if in_test_mode; then
	echo "#############################################"
	echo "## $1: test mode."
	echo "## Use the commands here to install your system."
	echo "#############################################"
elif test "${unpackaged}" = "yes" ; then
	install_unpackaged
	exit 0
fi

OS=`uname -s`
unsupported_distro=''

# A number of distributions we don't (yet?) support.
if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
  echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
  exit 1
fi

if [ -f /etc/gentoo-release ]; then
  unsupported_distro='Gentoo'
fi

if [ -f /etc/mandrake-release ]; then
  unsupported_distro='Mandriva'
fi

if [ -f /etc/SuSE-release ]; then
  unsupported_distro='SUSE'
fi

if [ -f /etc/slackware-version ]; then
  unsupported_distro='Slackware'
fi

if [ "$unsupported_distro" != '' ]; then
  echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
  exit 1
fi

# The distributions we do support:
if [ -r /etc/debian_version ]; then
  handle_debian
elif [ -r /etc/redhat-release ]; then
  handle_rh
elif [ "$OS" = 'OpenBSD' ]; then
  handle_obsd
fi

if ! in_test_mode; then
  echo "#############################################"
  echo "## $1 completed successfully"
  echo "#############################################"
fi