[Asterisk-code-review] install prereq: Split into multiple scripts and data. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Tue Mar 13 14:41:18 CDT 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8516
Change subject: install_prereq: Split into multiple scripts and data.
......................................................................
install_prereq: Split into multiple scripts and data.
As the install_prereq script supports more distributions and OS's it
becomes more difficult to read. This splits package lists and macros
for each supported platform into separate files that are read and run by
the main script.
Change-Id: I16a26b19047a8b3da3947c7953cd104241b7472d
---
M contrib/scripts/install_prereq
A contrib/scripts/prereqs/debian
A contrib/scripts/prereqs/debian.mandatory
A contrib/scripts/prereqs/freebsd
A contrib/scripts/prereqs/freebsd.mandatory
A contrib/scripts/prereqs/openbsd
A contrib/scripts/prereqs/openbsd.mandatory
A contrib/scripts/prereqs/rh
A contrib/scripts/prereqs/rh.mandatory
9 files changed, 181 insertions(+), 173 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/16/8516/1
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 23a247a..7922a99 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -1,7 +1,4 @@
-#! /bin/sh
-#
-# $Id$
-#
+#!/bin/sh
# install_prereq: a script to install distribution-specific
# prerequirements
@@ -10,7 +7,6 @@
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."
@@ -18,69 +14,7 @@
echo "Usage: $0 install-unpackaged Really install unpackaged requirements."
}
-# Basic build system:
-PACKAGES_DEBIAN="build-essential pkg-config"
-# Asterisk: basic requirements:
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev"
-# Asterisk: for addons:
-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 libltdl-dev libneon27-dev libgmime-2.6-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev"
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN libvpb-dev libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libosptk-dev libjack-jackd2-dev bash"
-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:
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch python-dev"
-
-# Basic build system:
-PACKAGES_RH="make gcc gcc-c++ pkgconfig"
-# Asterisk: basic requirements:
-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 alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
-PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel libtool-ltdl-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"
-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:
-PACKAGES_RH="$PACKAGES_RH wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel"
-
-# Basic build system:
-PACKAGES_OBSD="gmake"
-# Asterisk: basic requirements:
-PACKAGES_OBSD="$PACKAGES_OBSD libxml sqlite3 e2fsprogs jansson"
-# Asterisk: for addons:
-PACKAGES_OBSD="$PACKAGES_OBSD speex speexdsp libogg libvorbis portaudio-svn curl xmlstarlet bison"
-PACKAGES_OBSD="$PACKAGES_OBSD postgresql-client iodbc libltdl 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:
-PACKAGES_OBSD="$PACKAGES_OBSD wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_OBSD="$PACKAGES_OBSD bzip2 python%2"
-
-# Basic build system:
-PACKAGES_FBSD="gmake pkgconf"
-# Asterisk: basic requirements:
-PACKAGES_FBSD="$PACKAGES_FBSD libedit jansson e2fsprogs-libuuid sqlite3 libxml2"
-# Asterisk: for addons:
-PACKAGES_FBSD="$PACKAGES_FBSD speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
-PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC libltdl 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"
-# Asterisk: for the unpackaged below:
-PACKAGES_FBSD="$PACKAGES_FBSD wget subversion"
-# Asterisk: for ./configure --with-pjproject-bundled:
-PACKAGES_FBSD="$PACKAGES_FBSD bzip2 patch python"
-
+PREREQDIR=`dirname $0`/prereqs
KVERS=`uname -r`
JANSSON_VER=2.11
@@ -109,75 +43,9 @@
test "$testcmd" != ''
}
-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
-}
-
-# 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
-}
-
-check_installed_fpkgs() {
- for pack in "$@"
- do
- if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
- echo $pack
- fi
- done
-}
-
-handle_debian() {
- if ! [ -x "$(command -v aptitude)" ]; then
- apt-get install 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_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
+unsupported_platform() {
+ echo >&2 "$0: Your $1 ($2) is currently not supported. Aborting."
+ exit 1
}
install_unpackaged() {
@@ -240,45 +108,58 @@
fi
OS=`uname -s`
-unsupported_distro=''
-# A number of distributions we don't (yet?) support.
-if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then
- echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
- exit 1
+case "$OS" in
+Linux)
+ # A number of distributions we don't (yet?) support.
+ if [ -f /etc/gentoo-release ]; then
+ unsupported_platform 'distribution' 'Gentoo'
+ fi
+
+ if [ -f /etc/mandrake-release ]; then
+ unsupported_platform 'distribution' 'Mandriva'
+ fi
+
+ if [ -f /etc/SuSE-release ]; then
+ unsupported_platform 'distribution' 'SUSE'
+ fi
+
+ if [ -f /etc/slackware-version ]; then
+ unsupported_platform 'distribution' 'Slackware'
+ fi
+
+
+ # The distributions we do support:
+ if [ -r /etc/debian_version ]; then
+ PREREQPLATFORM=debian
+ elif [ -r /etc/redhat-release ]; then
+ PREREQPLATFORM=rh
+ else
+ unsupported_platform 'distribution' 'Unknown'
+ fi
+ ;;
+OpenBSD)
+ PREREQPLATFORM=openbsd
+ ;;
+FreeBSD)
+ PREREQPLATFORM=freebsd
+ ;;
+*)
+ unsupported_platform "OS" "$OS"
+ ;;
+esac
+
+# Initialize PREREQPKGS first so the platform script can modify it if needed.
+PREREQPKGS=`grep ${PREREQDIR}/${PREREQPLATFORM}.mandatory -ve '^#'`
+
+. ${PREREQDIR}/${PREREQPLATFORM}
+
+if test "x${PREREQ_DISTCHECK}" = "x1"; then
+ # Make sure packaging system is available
+ prereq_dist_check
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
-elif [ "$OS" = 'FreeBSD' ]; then
- handle_fbsd
-fi
+prereq_install `prereq_check_installed $PREREQPKGS`
if ! in_test_mode; then
echo "#############################################"
diff --git a/contrib/scripts/prereqs/debian b/contrib/scripts/prereqs/debian
new file mode 100644
index 0000000..1a98ca6
--- /dev/null
+++ b/contrib/scripts/prereqs/debian
@@ -0,0 +1,24 @@
+PREREQ_DISTCHECK=1
+
+prereq_dist_check() {
+ if ! [ -x "$(command -v aptitude)" ]; then
+ apt-get install aptitude
+ fi
+}
+
+prereq_check_installed() {
+ 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
+}
+
+prereq_install() {
+ $testcmd aptitude update
+ if test $# -ne 0; then
+ $testcmd aptitude install -y "$@"
+ fi
+}
diff --git a/contrib/scripts/prereqs/debian.mandatory b/contrib/scripts/prereqs/debian.mandatory
new file mode 100644
index 0000000..0992e8a
--- /dev/null
+++ b/contrib/scripts/prereqs/debian.mandatory
@@ -0,0 +1,15 @@
+# Basic build system:
+build-essential pkg-config
+# Asterisk: basic requirements:
+libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev
+# Asterisk: for addons:
+libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev xmlstarlet bison flex
+libpq-dev unixodbc-dev libltdl-dev libneon27-dev libgmime-2.6-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev
+libvpb-dev libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libosptk-dev libjack-jackd2-dev bash
+libsnmp-dev libiksemel-dev libcorosync-common-dev libcpg-dev libcfg-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev
+libresample1-dev libc-client2007e-dev binutils-dev libsrtp0-dev libsrtp2-dev libgsm1-dev doxygen graphviz zlib1g-dev libldap2-dev
+libcodec2-dev libfftw3-dev libsndfile1-dev libunbound-dev
+# Asterisk: for the unpackaged below:
+wget subversion
+# Asterisk: for ./configure --with-pjproject-bundled:
+bzip2 patch python-dev
diff --git a/contrib/scripts/prereqs/freebsd b/contrib/scripts/prereqs/freebsd
new file mode 100644
index 0000000..1fc43de
--- /dev/null
+++ b/contrib/scripts/prereqs/freebsd
@@ -0,0 +1,14 @@
+prereq_check_installed() {
+ for pack in "$@"
+ do
+ if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
+ echo $pack
+ fi
+ done
+}
+
+prereq_install() {
+ if test $# -ne 0; then
+ $testcmd pkg install -y "$@"
+ fi
+}
diff --git a/contrib/scripts/prereqs/freebsd.mandatory b/contrib/scripts/prereqs/freebsd.mandatory
new file mode 100644
index 0000000..d18ddd4
--- /dev/null
+++ b/contrib/scripts/prereqs/freebsd.mandatory
@@ -0,0 +1,14 @@
+# Basic build system:
+gmake pkgconf
+# Asterisk: basic requirements:
+libedit jansson e2fsprogs-libuuid sqlite3 libxml2
+# Asterisk: for addons:
+speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex
+postgresql10-client unixODBC libltdl neon gmime26 lua52 uriparser libxslt openssl
+mysql57-client radcli freetds
+net-snmp iksemel corosync newt popt libical spandsp
+cclient libbfd libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard
+# Asterisk: for the unpackaged below:
+wget subversion
+# Asterisk: for ./configure --with-pjproject-bundled:
+bzip2 patch python
diff --git a/contrib/scripts/prereqs/openbsd b/contrib/scripts/prereqs/openbsd
new file mode 100644
index 0000000..4eb9505
--- /dev/null
+++ b/contrib/scripts/prereqs/openbsd
@@ -0,0 +1,14 @@
+prereq_check_installed() {
+ for pack in "$@"
+ do
+ if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
+ echo $pack
+ fi
+ done
+}
+
+prereq_install() {
+ if test $# -ne 0; then
+ $testcmd pkg_add "$@"
+ fi
+}
diff --git a/contrib/scripts/prereqs/openbsd.mandatory b/contrib/scripts/prereqs/openbsd.mandatory
new file mode 100644
index 0000000..63993ae
--- /dev/null
+++ b/contrib/scripts/prereqs/openbsd.mandatory
@@ -0,0 +1,15 @@
+# Basic build system:
+gmake
+# Asterisk: basic requirements:
+libxml sqlite3 e2fsprogs jansson
+# Asterisk: for addons:
+speex speexdsp libogg libvorbis portaudio-svn curl xmlstarlet bison
+postgresql-client iodbc libltdl neon gmime lua%5.2 uriparser libxslt
+mariadb-client radcli freetds
+net-snmp iksemel popt libical spandsp
+c-client libsrtp gsm doxygen graphviz
+fftw3 libsndfile
+# Asterisk: for the unpackaged below:
+wget subversion
+# Asterisk: for ./configure --with-pjproject-bundled:
+bzip2 python%2
diff --git a/contrib/scripts/prereqs/rh b/contrib/scripts/prereqs/rh
new file mode 100644
index 0000000..a7a27db
--- /dev/null
+++ b/contrib/scripts/prereqs/rh
@@ -0,0 +1,16 @@
+# parsing the output of yum is close to impossible.
+# We'll use rpm and hope for the best:
+prereq_check_installed() {
+ for pack in "$@"
+ do
+ if ! rpm -q $pack >/dev/null 2>/dev/null
+ then echo $pack
+ fi
+ done
+}
+
+prereq_install() {
+ if test $# -ne 0; then
+ $testcmd yum install --skip-broken --assumeyes "$@"
+ fi
+}
diff --git a/contrib/scripts/prereqs/rh.mandatory b/contrib/scripts/prereqs/rh.mandatory
new file mode 100644
index 0000000..5bffba9
--- /dev/null
+++ b/contrib/scripts/prereqs/rh.mandatory
@@ -0,0 +1,15 @@
+# Basic build system:
+make gcc gcc-c++ pkgconfig
+# Asterisk: basic requirements:
+libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel
+# Asterisk: for addons:
+speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex
+postgresql-devel unixODBC-devel libtool-ltdl-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel
+mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel bash
+net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel
+libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard
+codec2-devel fftw-devel libsndfile-devel unbound-devel
+# Asterisk: for the unpackaged below:
+wget subversion
+# Asterisk: for ./configure --with-pjproject-bundled:
+bzip2 patch python-devel
--
To view, visit https://gerrit.asterisk.org/8516
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I16a26b19047a8b3da3947c7953cd104241b7472d
Gerrit-Change-Number: 8516
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180313/832e9220/attachment-0001.html>
More information about the asterisk-code-review
mailing list