[Asterisk-code-review] Files changed; (asterisk[master])
Martin McCarthy
asteriskteam at digium.com
Mon Mar 6 12:07:41 CST 2023
Martin McCarthy has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19939 )
Change subject: Files changed;
......................................................................
Files changed;
contrib/scripts/install_prereq.sh
List of Changes;
- Reimagining of the install_prereq.sh script.
- Error handling.
- Reformatting of the script.
- Tighter logic control.
ASTERISK-30359 #close
Change-Id: I4bd53ae429e113a76d13a23b48da714a8eefad26
---
M contrib/scripts/install_prereq
1 file changed, 730 insertions(+), 304 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/19939/1
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 5843853..1dd2a0a 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -1,437 +1,843 @@
-#! /bin/sh
-#
-# $Id$
-#
-
-# install_prereq: a script to install distribution-specific
-# prerequirements
-
+#!/bin/sh
+# ============================================
+# Prerequisite Installer for Asterisk
+# Revision: 2
+# Amended by Martin McCarthy
+# 01/11/22
+# This script will help prepare your system for installing Asterisk by installing prerequisite packages required to run it.
+# - Supported distros;
+# - DragonFly
+# - FreeBSD
+# - OpenBSD
+# - NetBSD
+# - Gentoo
+# - Arch Linux
+# - openSUSE
+# - Red Hat Enterprise Linux
+# - Debian
+# ============================================
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."
+# ============================================
+# Functions - Start
+# ============================================
+# ============================================
+# Function name: handle_debian
+# Date: 01/11/22
+# Function description: this function will handle installation of Debian packages
+# ============================================
+handle_debian() {
+ if ! [ -x "$(command -v aptitude)" ] ; then
+ # Inform the user
+ echo ""
+ echo "Installing aptitude..."
+
+ apt-get install -y aptitude
+ fi
+
+ extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
+
+ $testcmd aptitude update
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd aptitude install -y $extra_packs
+ fi
+
+ # We're done!
+ return
}
-# Basic build system:
+# ============================================
+# Function name: handle_rh
+# Date: 01/11/22
+# Function description: this function will handle installation of Red Hat packages
+# ============================================
+handle_rh() {
+ extra_packs=`check_installed_rpms $PACKAGES_RH`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd yum install --skip-broken --assumeyes $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_gentoo
+# Date: 01/11/22
+# Function description: this function will handle installation of Gentoo packages
+# ============================================
+handle_gentoo() {
+ extra_packs=`check_installed_equery $PACKAGES_GENTOO`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+
+ $testcmd emerge $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_arch
+# Date: 01/11/22
+# Function description: this function will handle installation of Arch Linux packages
+# ============================================
+handle_arch() {
+ extra_packs=`check_installed_pacman $PACKAGES_ARCH`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+
+ $testcmd pacman -S --asexplicit --noconfirm $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_nbsd
+# Date: 01/11/22
+# Function description: this function will handle installation of NetBSD packages
+# ============================================
+handle_nbsd() {
+ extra_packs=`check_installed_pkgs $PACKAGES_NBSD`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ if [ -z "$PKG_PATH" ] ; then
+ # See NetBSD Problem Report #48177 (http://gnats.netbsd.org/48177)
+ export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -p)/$(uname -r)/All"
+ fi
+
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd pkg_add $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_obsd
+# Date: 01/11/22
+# Function description: this function will handle installation of OpenBSD packages
+# ============================================
+handle_obsd() {
+ extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd pkg_add $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_fbsd
+# Date: 01/11/22
+# Function description: this function will handle installation of FreeBSD packages
+# ============================================
+handle_fbsd() {
+ extra_packs=`check_installed_fpkgs $PACKAGES_FBSD`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd pkg install -y $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_dbsd
+# Date: 01/11/22
+# Function description: this function will handle installation of DragonFlyBSD packages
+# ============================================
+handle_dbsd() {
+ extra_packs=`check_installed_fpkgs $PACKAGES_DBSD`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd pkg install -y $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: handle_SUSE
+# Date: 01/11/22
+# Function description: this function will handle installation of openSUSE packages
+# ============================================
+handle_SUSE() {
+ extra_packs=`check_installed_zypper $PACKAGES_SUSE`
+
+ if [ x"$extra_packs" != "x" ] ; then
+ echo ""
+ echo "Installing extra packs...please wait..."
+
+ $testcmd zypper install --no-confirm $extra_packs
+ fi
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: usage
+# Date: 01/11/22
+# Function description: display help information on how to use the script.
+# ============================================
+usage() {
+ # Display help to the user
+ echo "======================================"
+ echo "!!! No command line arguments were passed !!!"
+ echo ""
+ echo "Here are some examples of valid arguments;"
+ echo ""
+ echo "$0: will display this help text."
+ echo "$0 test prints commands to be run but does not run them."
+ echo "$0 install will install the prerequisite packages."
+ echo "$0 install-unpackaged will install the unpackaged requirements."
+ echo ""
+ echo "This script will now exit"
+ echo "======================================"
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: in_test_mode
+# Date: 01/11/22
+# Function description: activate test mode
+# ============================================
+in_test_mode() {
+ test "$testcmd" != ''
+
+ # We're done!
+ return
+}
+
+# ============================================
+# Function name: check_installed_debs
+# Date: 01/11/22
+# Function description: check if Debian packages are installed.
+# ============================================
+check_installed_debs() {
+ for pack in "$@" ; do
+ tocheck="${tocheck} ^${pack}$ ~P^${pack}$"
+ done
+
+ echo ""
+ echo "Checking installed packages...please wait..."
+
+ pkgs=$(aptitude -F '%c %p' search ${tocheck} 2>/dev/null | awk '/^p/{print $2}')
+
+ if [ ${#pkgs} -ne 0 ] ; then
+ echo $pkgs | sed -r -e "s/ ?[^ :]+:i386//g"
+ fi
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_rpms
+# Date: 01/11/22
+# Function description: check if RPM packages are installed.
+# Parsing the output of YUM is close to impossible
+# so 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
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_equery
+# Date: 01/11/22
+# Function description: Check if Gentoo packages are installed.
+# ==========================================
+check_installed_equery() {
+ for pack in "$@"
+ do
+ # equery --quiet list $pack
+ # is slower and would require the optional app-portage/gentoolkit
+ # /var/lib/portage/world would be the non-dep list
+ pack_with_version=${pack/:/-} # replace a possible version with '-'
+
+ if ! ls -d /var/db/pkg/${pack_with_version}* >/dev/null 2>/dev/null
+ then
+ echo $pack
+ fi
+ done
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_pacman
+# Date: 01/11/22
+# Function description: check if Arch Linux packages are installed.
+# ==========================================
+check_installed_pacman() {
+ for pack in "$@"
+ do
+ if ! pacman -Q --explicit $pack >/dev/null 2>/dev/null
+ then
+ echo $pack
+ fi
+ done
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_pkgs
+# Date: 01/11/22
+# Function description: check installed packages.
+# ==========================================
+check_installed_pkgs() {
+ for pack in "$@"
+ do
+ if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
+ echo $pack
+ fi
+ done
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_fpkgs
+# Date: 01/11/22
+# Function description: check installed packages.
+# ==========================================
+check_installed_fpkgs() {
+ for pack in "$@"
+ do
+ if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
+ echo $pack
+ fi
+ done
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: check_installed_zypper
+# Date: 01/11/22
+# Function description: check installed packages.
+# ==========================================
+check_installed_zypper() {
+ for pack in "$@"
+ do
+ if ! zypper se -ixnC $pack >/dev/null 2>/dev/null
+ then
+ echo $pack
+ fi
+ done
+
+ # We're done!
+ return
+}
+
+# ==========================================
+# Function name: install_unpackaged
+# Date: 01/11/22
+# Function description: install optional extra packages for Asterisk
+# ==========================================
+install_unpackaged() {
+ echo "*** Installing NBS (Network Broadcast Sound) ***"
+
+ svn co https://svn.digium.com/svn/nbs/trunk nbs-trunk
+ cd nbs-trunk
+ make all install
+ cd ..
+
+ # Only install libresample if it wasn't installed via package
+ if ! test -f /usr/include/libresample.h; then
+ echo "*** Installing libresample ***"
+ svn co https://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
+ cd libresample-trunk
+ ./configure
+ make all install
+ cd ..
+ fi
+
+ # Only install Jansson if it wasn't installed via package
+ if ! test -f /usr/include/jansson.h; then
+ echo "*** Installing jansson ***"
+ wget -O - http://www.digip.org/jansson/releases/jansson-${JANSSON_VER}.tar.gz | zcat | tar -xf -
+ cd jansson-${JANSSON_VER}
+ ./configure
+ make all install
+ cd ..
+ if test -d /etc/ld.so.conf.d; then
+ echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
+ else # for example: Slackware 14.2
+ echo "/usr/local/lib" > /etc/ld.so.conf
+ fi
+ /sbin/ldconfig
+ fi
+
+ # Only install libsrtp2 if it wasn't installed via package
+ if ! test -f /usr/include/srtp/srtp.h; then
+ if ! test -f /usr/include/srtp2/srtp.h; then
+ echo "*** Installing libsrtp2 ***"
+ wget -O - http://github.com/cisco/libsrtp/archive/v2.tar.gz | zcat | tar -xf -
+ cd libsrtp-2
+ ./configure --enable-openssl
+ make shared_library install
+ cd ..
+ if test -d /etc/ld.so.conf.d; then
+ echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
+ else # for example: Slackware 14.2
+ echo "/usr/local/lib" > /etc/ld.so.conf
+ fi
+ /sbin/ldconfig
+ fi
+ fi
+
+ if ! test -f /usr/include/pjlib.h; then
+ echo "PJProject not installed, yet. Therefore, please, run"
+ echo "./configure --with-pjproject-bundled"
+ fi
+
+ # We're done!
+ return
+}
+# ============================================
+# Functions - End
+# ============================================
+
+# ============================================
+# Global Variables - Start
+# ============================================
+##################
+# DEBIAN PACKAGES
+##################
+# Basic build system
PACKAGES_DEBIAN="build-essential pkg-config"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev"
-# Asterisk: for addons:
+
+# Asterisk - addon packages
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev xmlstarlet bison flex"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libneon27-dev libgmime-2.6-dev libgmime-3.0-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev"
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libjack-jackd2-dev bash libcap-dev"
+PACKAGES_DEBIAN="$PACKAGES_DEBIAN libvpb-dev libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libosptk-dev libjack-jackd2-dev bash libcap-dev"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-common-dev libcpg-dev libcfg-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample1-dev libc-client2007e-dev binutils-dev libsrtp0-dev libsrtp2-dev libgsm1-dev doxygen graphviz zlib1g-dev libldap2-dev"
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcodec2-dev libfftw3-dev libsndfile1-dev libunbound-dev"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_DEBIAN="$PACKAGES_DEBIAN wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch"
-# Basic build system:
+##################
+# RED HAT PACKAGES
+##################
+# Basic build system
PACKAGES_RH="make gcc gcc-c++ pkgconfig"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_RH="$PACKAGES_RH libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel"
-# Asterisk: for addons:
-PACKAGES_RH="$PACKAGES_RH speex-devel speexdsp-devel libogg-devel libvorbis-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
+
+# Asterisk - addon packages
+PACKAGES_RH="$PACKAGES_RH speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel"
PACKAGES_RH="$PACKAGES_RH mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel bash libcap-devel"
PACKAGES_RH="$PACKAGES_RH net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel"
PACKAGES_RH="$PACKAGES_RH libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard"
PACKAGES_RH="$PACKAGES_RH codec2-devel fftw-devel libsndfile-devel unbound-devel"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_RH="$PACKAGES_RH wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_RH="$PACKAGES_RH bzip2 patch"
-# Basic build system:
+##################
+# OpenSUSE PACKAGES
+##################
+# Basic build system
PACKAGES_SUSE="make gcc gcc-c++ pkg-config"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_SUSE="$PACKAGES_SUSE libedit-devel libjansson-devel libuuid-devel sqlite3-devel libxml2-devel"
-# Asterisk: for addons:
-PACKAGES_SUSE="$PACKAGES_SUSE speex-devel speexdsp-devel libogg-devel libvorbis-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
+
+# Asterisk - addon packages
+PACKAGES_SUSE="$PACKAGES_SUSE speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
PACKAGES_SUSE="$PACKAGES_SUSE postgresql-devel unixODBC-devel libneon-devel gmime-devel lua-devel liburiparser-devel libxslt-devel libopenssl-devel"
PACKAGES_SUSE="$PACKAGES_SUSE libmysqlclient-devel bluez-devel freeradius-client-devel freetds-devel bash libcap-devel"
PACKAGES_SUSE="$PACKAGES_SUSE net-snmp-devel iksemel-devel libcorosync-devel newt-devel popt-devel libical-devel spandsp-devel"
PACKAGES_SUSE="$PACKAGES_SUSE imap-devel libsrtp2-devel libgsm-devel doxygen graphviz zlib-devel openldap2-devel"
PACKAGES_SUSE="$PACKAGES_SUSE codec2-devel fftw3-devel libsndfile-devel unbound-devel"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_SUSE="$PACKAGES_SUSE wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_SUSE="$PACKAGES_SUSE bzip2 patch"
-# Basic build system:
+##################
+# ARCH PACKAGES
+##################
+# Basic build system
PACKAGES_ARCH="make gcc pkg-config"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_ARCH="$PACKAGES_ARCH libedit jansson libutil-linux libxml2 sqlite"
-# Asterisk: for addons:
-PACKAGES_ARCH="$PACKAGES_ARCH speex speexdsp libogg libvorbis portaudio curl xmlstarlet bison flex"
+
+# Asterisk - addon packages
+PACKAGES_ARCH="$PACKAGES_ARCH speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
PACKAGES_ARCH="$PACKAGES_ARCH postgresql-libs unixodbc neon gmime lua uriparser libxslt openssl"
PACKAGES_ARCH="$PACKAGES_ARCH libmariadbclient bluez-libs radcli freetds bash libcap"
PACKAGES_ARCH="$PACKAGES_ARCH net-snmp libnewt popt libical spandsp"
PACKAGES_ARCH="$PACKAGES_ARCH c-client binutils libsrtp gsm doxygen graphviz zlib libldap"
PACKAGES_ARCH="$PACKAGES_ARCH fftw libsndfile unbound"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_ARCH="$PACKAGES_ARCH wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_ARCH="$PACKAGES_ARCH bzip2 patch"
-# Basic build system:
+##################
+# GENTOO PACKAGES
+##################
+# Basic build system
PACKAGES_GENTOO="sys-devel/make sys-devel/gcc dev-util/pkgconfig"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_GENTOO="$PACKAGES_GENTOO dev-libs/libedit dev-libs/jansson sys-libs/e2fsprogs-libs dev-libs/libxml2 dev-db/sqlite"
-# Asterisk: for addons:
-PACKAGES_GENTOO="$PACKAGES_GENTOO media-libs/speex media-libs/speexdsp media-libs/libogg media-libs/libvorbis media-libs/portaudio net-misc/curl app-text/xmlstarlet sys-devel/bison sys-devel/flex"
+
+# Asterisk - addon packages
+PACKAGES_GENTOO="$PACKAGES_GENTOO media-libs/speex media-libs/speexdsp media-libs/libogg media-libs/libvorbis media-libs/alsa-lib media-libs/portaudio net-misc/curl app-text/xmlstarlet sys-devel/bison sys-devel/flex"
PACKAGES_GENTOO="$PACKAGES_GENTOO dev-db/postgresql dev-db/unixODBC net-libs/neon dev-libs/gmime dev-lang/lua dev-libs/uriparser dev-libs/libxslt dev-libs/openssl"
PACKAGES_GENTOO="$PACKAGES_GENTOO virtual/libmysqlclient net-wireless/bluez net-dialup/radiusclient-ng dev-db/freetds app-shells/bash sys-libs/libcap"
PACKAGES_GENTOO="$PACKAGES_GENTOO net-analyzer/net-snmp dev-libs/iksemel sys-cluster/corosync dev-libs/newt dev-libs/popt dev-libs/libical media-libs/spandsp"
PACKAGES_GENTOO="$PACKAGES_GENTOO net-libs/c-client sys-devel/binutils net-libs/libsrtp media-sound/gsm media-libs/libilbc app-doc/doxygen sys-libs/zlib net-nds/openldap"
PACKAGES_GENTOO="$PACKAGES_GENTOO sci-libs/fftw media-libs/libsndfile net-dns/unbound"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_GENTOO="$PACKAGES_GENTOO net-misc/wget dev-vcs/subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_GENTOO="$PACKAGES_GENTOO app-arch/bzip2 sys-devel/patch"
-# Basic build system:
+##################
+# NetBSD PACKAGES
+##################
+# Basic build system
PACKAGES_NBSD="gmake pkg-config"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_NBSD="$PACKAGES_NBSD editline jansson sqlite3 libuuid libxml2"
-# Asterisk: for addons:
-PACKAGES_NBSD="$PACKAGES_NBSD speex speexdsp libogg libvorbis portaudio-devel curl bison flex"
+
+# Asterisk - addon packages
+PACKAGES_NBSD="$PACKAGES_NBSD speex speexdsp libogg libvorbis alsa-lib portaudio-devel curl bison flex"
PACKAGES_NBSD="$PACKAGES_NBSD postgresql10-client unixodbc neon gmime lua52 uriparser libxslt openssl"
PACKAGES_NBSD="$PACKAGES_NBSD mysql-client radiusclient-ng freetds bash"
PACKAGES_NBSD="$PACKAGES_NBSD net-snmp iksemel popt libical spandsp"
PACKAGES_NBSD="$PACKAGES_NBSD imap-uw srtp gsm doxygen graphviz libzip openldap-client"
PACKAGES_NBSD="$PACKAGES_NBSD codec2 fftw libsndfile unbound"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_NBSD="$PACKAGES_NBSD wget subversion-base"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_NBSD="$PACKAGES_NBSD bzip2 patch"
-# Basic build system:
+##################
+# OpenBSD PACKAGES
+##################
+# Basic build system
PACKAGES_OBSD="gmake"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_OBSD="$PACKAGES_OBSD libxml sqlite3 e2fsprogs jansson"
-# Asterisk: for addons:
+
+# Asterisk - addon packages
PACKAGES_OBSD="$PACKAGES_OBSD speex speexdsp libogg libvorbis portaudio-svn curl xmlstarlet bison"
PACKAGES_OBSD="$PACKAGES_OBSD postgresql-client iodbc neon gmime lua%5.2 uriparser libxslt"
PACKAGES_OBSD="$PACKAGES_OBSD mariadb-client radcli freetds"
PACKAGES_OBSD="$PACKAGES_OBSD net-snmp iksemel popt libical spandsp"
PACKAGES_OBSD="$PACKAGES_OBSD c-client libsrtp gsm doxygen graphviz"
PACKAGES_OBSD="$PACKAGES_OBSD fftw3 libsndfile"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_OBSD="$PACKAGES_OBSD wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_OBSD="$PACKAGES_OBSD bzip2"
-# Basic build system:
+##################
+# FreeBSD PACKAGES
+##################
+# Basic build system
PACKAGES_FBSD="gmake pkgconf"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_FBSD="$PACKAGES_FBSD libedit jansson e2fsprogs-libuuid sqlite3 libxml2"
-# Asterisk: for addons:
-PACKAGES_FBSD="$PACKAGES_FBSD speex speexdsp libogg libvorbis portaudio curl xmlstarlet bison flex"
+
+# Asterisk - addon packages
+PACKAGES_FBSD="$PACKAGES_FBSD speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC neon gmime26 lua52 uriparser libxslt openssl"
PACKAGES_FBSD="$PACKAGES_FBSD mysql57-client radcli freetds"
PACKAGES_FBSD="$PACKAGES_FBSD net-snmp iksemel corosync newt popt libical spandsp"
PACKAGES_FBSD="$PACKAGES_FBSD cclient libbfd libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard"
PACKAGES_FBSD="$PACKAGES_FBSD codec2 fftw3 libsndfile unbound"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_FBSD="$PACKAGES_FBSD wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_FBSD="$PACKAGES_FBSD bzip2 patch"
-# Basic build system:
+##################
+# DragonFly PACKAGES
+##################
+# Basic build system
PACKAGES_DBSD="gmake pkgconf"
-# Asterisk: basic requirements:
+
+# Asterisk - basic prerequisite packages
PACKAGES_DBSD="$PACKAGES_DBSD libedit jansson e2fsprogs-libuuid sqlite3 libxml2"
-# Asterisk: for addons:
-PACKAGES_DBSD="$PACKAGES_DBSD speex speexdsp libogg libvorbis portaudio curl xmlstarlet bison flex"
+
+# Asterisk - addon packages
+PACKAGES_DBSD="$PACKAGES_DBSD speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
PACKAGES_DBSD="$PACKAGES_DBSD postgresql10-client unixODBC neon gmime26 lua52 uriparser libxslt libressl"
PACKAGES_DBSD="$PACKAGES_DBSD mariadb101-client radcli freetds"
PACKAGES_DBSD="$PACKAGES_DBSD net-snmp iksemel corosync newt popt libical spandsp"
PACKAGES_DBSD="$PACKAGES_DBSD cclient binutils libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard"
PACKAGES_DBSD="$PACKAGES_DBSD codec2 fftw3 libsndfile unbound"
-# Asterisk: for the unpackaged below:
+
+# Asterisk- subversion
PACKAGES_DBSD="$PACKAGES_DBSD wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
+
+# Asterisk - packages to run ./configure --with-pjproject-bundled
PACKAGES_DBSD="$PACKAGES_DBSD bzip2 patch"
+##################
+# MISC VARIABLES
+##################
KVERS=`uname -r`
+JANSSON_VER=2.12
-case "$1" in
-test)
- testcmd=echo
- ;;
-install)
- testcmd=''
- ;;
-install-unpackaged)
- unpackaged="yes"
- ;;
-'')
- usage
- exit 0
- ;;
-*)
- usage
- exit 1
- ;;
-esac
+# ============================================
+# Global Variables - End
+# ============================================
-in_test_mode() {
- test "$testcmd" != ''
-}
+# ============================================
+# Main Program Logic - Start
+# ============================================
+# === Algorithm ===
+# - Welcome the user!
+# - Detect and parse runtime arguments
+# - Find distro
+# - Confirm packages to be installed
+# - Attempt to install
+# - Fin!
+##################
+# Welcome!
+##################
+echo "======================================"
+echo "Welcome to the Asterisk Prerequisite Installer!"
+echo ""
+echo "The purpose of this script is to prepare your system"
+echo "for the installation of Asterisk."
+echo ""
+echo "Patches welcome!"
+echo "======================================"
-check_installed_debs() {
- for pack in "$@" ; do
- tocheck="${tocheck} ^${pack}$ ~P^${pack}$"
- done
- pkgs=$(aptitude -F '%c %p' search ${tocheck} 2>/dev/null | awk '/^p/{print $2}')
- if [ ${#pkgs} -ne 0 ]; then
- echo $pkgs | sed -r -e "s/ ?[^ :]+:i386//g"
- fi
-}
+# Arguments
+if [ "$1" eq "" ] ; then
+ # No arguments passed...display the help text and exit
+ usage
-# 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_equery() {
- for pack in "$@"
- do
- # equery --quiet list $pack
- # is slower and
- # would require the optional app-portage/gentoolkit
- # /var/lib/portage/world would be the non-dep list
- pack_with_version=${pack/:/-} # replace a possible version with '-'
- if ! ls -d /var/db/pkg/${pack_with_version}* >/dev/null 2>/dev/null
- then echo $pack
- fi
- done
-}
-
-check_installed_pacman() {
- for pack in "$@"
- do
- if ! pacman -Q --explicit $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
-}
-
-check_installed_fpkgs() {
- for pack in "$@"
- do
- if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
- echo $pack
- fi
- done
-}
-
-check_installed_zypper() {
- for pack in "$@"
- do
- if ! zypper se -ixnC $pack >/dev/null 2>/dev/null
- then echo $pack
- fi
- done
-}
-
-handle_debian() {
- if ! [ -x "$(command -v aptitude)" ]; then
- apt-get install -y aptitude
- fi
- extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
- $testcmd aptitude update
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd aptitude install -y $extra_packs
- fi
-}
-
-handle_rh() {
- extra_packs=`check_installed_rpms $PACKAGES_RH`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd yum install --skip-broken --assumeyes $extra_packs
- fi
-}
-
-handle_gentoo() {
- extra_packs=`check_installed_equery $PACKAGES_GENTOO`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd emerge $extra_packs
- fi
-}
-
-handle_arch() {
- extra_packs=`check_installed_pacman $PACKAGES_ARCH`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd pacman -S --asexplicit --noconfirm $extra_packs
- fi
-}
-
-handle_nbsd() {
- extra_packs=`check_installed_pkgs $PACKAGES_NBSD`
- if [ x"$extra_packs" != "x" ] ; then
- if [ -z "$PKG_PATH" ] ; then
- # see NetBSD Problem Report #48177
- export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -p)/$(uname -r)/All"
- fi
- $testcmd pkg_add $extra_packs
- fi
-}
-
-handle_obsd() {
- extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd pkg_add $extra_packs
- fi
-}
-
-handle_fbsd() {
- extra_packs=`check_installed_fpkgs $PACKAGES_FBSD`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd pkg install -y $extra_packs
- fi
-}
-
-handle_dbsd() {
- extra_packs=`check_installed_fpkgs $PACKAGES_DBSD`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd pkg install -y $extra_packs
- fi
-}
-
-handle_SUSE() {
- extra_packs=`check_installed_zypper $PACKAGES_SUSE`
- if [ x"$extra_packs" != "x" ] ; then
- $testcmd zypper install --no-confirm $extra_packs
- fi
-}
-
-install_unpackaged() {
- # Only install libresample if it wasn't installed via package
- if ! test -f /usr/include/libresample.h; then
- echo "*** Installing libresample ***"
- svn co https://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
- cd libresample-trunk
- ./configure
- make all install
- cd ..
- fi
-
- # Only install libsrtp2 if it wasn't installed via package
- if ! test -f /usr/include/srtp/srtp.h; then
- if ! test -f /usr/include/srtp2/srtp.h; then
- echo "*** Installing libsrtp2 ***"
- wget -O - http://github.com/cisco/libsrtp/archive/v2.tar.gz | zcat | tar -xf -
- cd libsrtp-2
- ./configure --enable-openssl
- make shared_library install
- cd ..
- if test -d /etc/ld.so.conf.d; then
- echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
- else # for example: Slackware 14.2
- echo "/usr/local/lib" > /etc/ld.so.conf
- fi
- /sbin/ldconfig
- fi
- fi
-
- if ! test -f /usr/include/pjlib.h; then
- echo "PJProject not installed, yet. Therefore, please, run"
- echo "./configure --with-pjproject-bundled"
- fi
-}
-
-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
+ # Let's get out of here!
+ exit 0
fi
+# Main script logic starts here
+case "$1" in
+test)
+ testcmd=echo
+ ;;
+install)
+ testcmd=""
+ ;;
+install-unpackaged)
+ unpackaged="yes"
+ ;;
+"")
+ # No arguments passed...display the help text and exit
+ usage
+
+ # Exit!
+ exit 0
+ ;;
+*)
+ # No arguments passed...display the help text and exit
+ usage
+
+ # Exit!
+ exit 1
+ ;;
+esac
+
+# Grab OS name
OS=`uname -s`
-unsupported_distro=''
+unsupported_distro=""
# A number of distributions we don't (yet?) support.
-if [ "$OS" != 'Linux' -a "$OS" != 'NetBSD' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' -a "$OS" != 'DragonFly' ]; then
- echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
- exit 1
+if [ "$OS" != "Linux" -a "$OS" != "NetBSD" -a "$OS" != "OpenBSD" -a "$OS" != "FreeBSD" -a "$OS" != "DragonFly" ] ; then
+ echo >&2 "Unfortunately, $OS is not currently supported. Please post a patched version or reach out to Asterisk support."
+
+ # Exit!
+ exit 1
fi
if [ -f /etc/mandrake-release ]; then
- unsupported_distro='Mandriva'
+ unsupported_distro="Mandriva"
fi
if [ -f /etc/slackware-version ] || ([ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "slackware" ]); then
- echo >&2 "$0: Your distribution (Slackware) is currently not supported. Aborting. Try manually:"
- # libedit requires a newer version than Slackware 14.2, for example Slackware-current
- # or you build it manually: <http://thrysoee.dk/editline/>
- echo >&2 "$0: # slackpkg install make gcc pkg-config libedit util-linux sqlite libxml2 patch wget"
- # required for libjansson
- echo >&2 "$0: # ./contrib/scripts/install_prereq install-unpackaged"
- exit 1
+ echo >&2 "Unfortunately, $OS is not currently supported. Please post a patched version or reach out to Asterisk support."
+ echo "Try manually:"
+ # libedit requires a newer version than Slackware 14.2, for example Slackware-current
+ # or you build it manually: <http://thrysoee.dk/editline/>
+ echo >&2 "# slackpkg install make gcc pkg-config libedit util-linux sqlite libxml2 patch wget"
+
+ # Required for libjansson
+ echo >&2 "# ./contrib/scripts/install_prereq install-unpackaged"
+
+ # Exit!
+ exit 1
fi
if [ "$unsupported_distro" != '' ]; then
- echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
- exit 1
+ echo "======================================"
+ echo >&2 "Unfortunately, $OS is not currently supported. Please post a patched version or reach out to Asterisk support."
+ echo "======================================"
+
+ # Exit!
+ exit 1
fi
# The distributions we do support:
if [ -r /etc/debian_version ]; then
- handle_debian
+ if [ -r /etc/linuxmint/info ]; then
+ # Alert user of OS detection
+ echo ""
+ echo "We've detected you're using Linux Mint. Linux Mint is currently not supported."
+ echo ""
+ echo "Patches welcome! This script will now exit."
+ else
+ # Alert user of OS detection
+ echo ""
+ echo "We've detected you're using Debian...will install Debian packages...please wait..."
+ handle_debian
+ fi
elif [ -r /etc/redhat-release ]; then
- handle_rh
+ echo ""
+ echo "We've detected you're using Red Hat...will install Red Hat packages...please wait..."
+ handle_rh
elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then
- handle_SUSE
+ echo ""
+ echo "We've detected you're using openSUSE...will install openSUSE packages...please wait..."
+ handle_SUSE
elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "opensuse" ]; then
- handle_SUSE
+ echo ""
+ echo "We've detected you're using openSUSE...will install openSUSE packages...please wait..."
+ handle_SUSE
elif [ -r /etc/arch-release ]; then
- handle_arch
+ echo ""
+ echo "We've detected you're using Arch Linux...will install Arch Linux packages...please wait..."
+ handle_arch
elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID_LIKE" = "archlinux" ]; then
- handle_arch # $ID=arch
+ echo ""
+ echo "We've detected you're using Arch Linux...will install Arch Linux packages...please wait..."
+ handle_arch # $ID=arch
elif [ -f /etc/gentoo-release ]; then
- handle_gentoo
+ echo ""
+ echo "We've detected you're using Gentoo...will install Gentoo packages...please wait..."
+ handle_gentoo
elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "gentoo" ]; then
- handle_gentoo
+ echo ""
+ echo "We've detected you're using Gentoo...will install Gentoo packages...please wait..."
+ handle_gentoo
elif [ "$OS" = 'NetBSD' ]; then
- handle_nbsd
+ echo ""
+ echo "We've detected you're using $OS...will install $OS packages...please wait..."
+ handle_nbsd
elif [ "$OS" = 'OpenBSD' ]; then
- handle_obsd
+ echo ""
+ echo "We've detected you're using $OS...will install $OS packages...please wait..."
+ handle_obsd
elif [ "$OS" = 'FreeBSD' ]; then
- handle_fbsd
+ echo ""
+ echo "We've detected you're using $OS...will install $OS packages...please wait..."
+ handle_fbsd
elif [ "$OS" = 'DragonFly' ]; then
- handle_dbsd
+ echo ""
+ echo "We've detected you're using $OS...will install $OS packages...please wait..."
+ handle_dbsd
fi
if ! in_test_mode; then
- echo "#############################################"
- echo "## $1 completed successfully"
- echo "#############################################"
+ echo "======================================"
+ echo "$1 completed successfully."
+ echo ""
+ echo "Thanks for using this script!"
+ echo "You should be good to start installing Asterisk!"
+ echo "======================================"
+
+ # We're done!
+ exit 0
fi
+
+# ============================================
+# Main Program Logic - End
+# ============================================
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19939
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I4bd53ae429e113a76d13a23b48da714a8eefad26
Gerrit-Change-Number: 19939
Gerrit-PatchSet: 1
Gerrit-Owner: Martin McCarthy <martin.c.mccarthy at outlook.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230306/6c7286b4/attachment-0001.html>
More information about the asterisk-code-review
mailing list