[Asterisk-code-review] install prereq: Check if is installed aptitude otherwise use... (asterisk[master])

Rodrigo Ramirez Norambuena asteriskteam at digium.com
Thu May 21 13:25:35 CDT 2015


Rodrigo Ramirez Norambuena has uploaded a new change for review.

  https://gerrit.asterisk.org/508

Change subject: install_prereq: Check if is installed aptitude otherwise use apt-get.
......................................................................

install_prereq: Check if is installed aptitude otherwise use apt-get.

If in Debian or system based, dont have aptitude installed the script do
nothing. This patch checked if aptitude is not installed and used apt-get for
install and dpkg for check de packages.

Also, in new release of Debian, example jessy, the package 'libgmime-dev' is
called 'libgmime-2.6-dev' or 'libgmime2-dev' for this use a expresion regular
for package name.

ASTERISK-25113 #close
Reported By: Rodrigo Ramírez Norambuena <decipher.hk at gmail.com>

Change-Id: Iebdff55805d3917166e5e08e0a1e2176f36ff27f
---
M contrib/scripts/install_prereq
1 file changed, 25 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/508/1

diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 58ef05c..775ee7a 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -24,7 +24,7 @@
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev libsqlite3-dev uuid-dev uuid"
 # 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 libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1"
+PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libmysqlclient15-dev libneon27-dev libgmime(2)?-dev libusb-dev liblua5.1-0-dev lua5.1"
 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 libcorosync-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev doxygen libjansson-dev libldap-dev"
@@ -66,13 +66,24 @@
 }
 
 check_installed_debs() {
-	for pack in "$@"
-	do
-		tocheck="${tocheck} ^${pack}$"
-	done
-	aptitude -F '%c %p' search ${tocheck} 2>/dev/null \
-		| awk '/^p/{print $2}' \
-		| grep -v ':i386$'
+	if which aptitude >/dev/null; then
+		for pack in "$@"
+		do
+			tocheck="${tocheck} ^${pack}$"
+		done
+		aptitude -F '%c %p' search ${tocheck} 2>/dev/null \
+			| awk '/^p/{print $2}' \
+			| grep -v ':i386$'
+	else
+		for pack in "$@"
+		do
+			if [ $(dpkg-query -W -f='${Status}' $pack 2>/dev/null | grep -c "ok installed") -eq 0 ];
+			then
+				toinstall="${toinstall} ^${pack}$"
+			fi
+		done
+		echo "$toinstall"
+	fi
 }
 
 # parsing the output of yum is close to impossible.
@@ -97,7 +108,12 @@
 
 handle_debian() {
 	extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
-	$testcmd aptitude install -y $extra_packs
+	if which aptitude >/dev/null; then
+		apt_cmd="aptitude"
+	else
+		apt_cmd="apt-get"
+	fi
+	$testcmd $apt_cmd install -y $extra_packs
 }
 
 handle_rh() {

-- 
To view, visit https://gerrit.asterisk.org/508
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebdff55805d3917166e5e08e0a1e2176f36ff27f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <decipher.hk at gmail.com>



More information about the asterisk-code-review mailing list