]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
install_prereq: Check if is installed aptitude otherwise to install. 08/508/3
authorRodrigo Ramírez Norambuena <decipher.hk@gmail.com>
Thu, 4 Jun 2015 01:12:50 +0000 (21:12 -0400)
committerRodrigo Ramírez Norambuena <decipher.hk@gmail.com>
Thu, 4 Jun 2015 01:12:50 +0000 (21:12 -0400)
If in Debian or system based, dont have aptitude installed the script do
nothing. This patch checked if aptitude  installed, if not installed.

Also, if execute script with all packages installed yet, the script not show
nothing and return exit 1 because the command 'grep' get nothing from pipe from
'awk'.

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

Change-Id: Iebdff55805d3917166e5e08e0a1e2176f36ff27f

contrib/scripts/install_prereq

index 58ef05ca2c7f317c7b5d148c4862ebeca283593a..b0caab8e9224afd35c92db00030784d3d14e0be5 100755 (executable)
@@ -70,9 +70,10 @@ check_installed_debs() {
        do
                tocheck="${tocheck} ^${pack}$"
        done
-       aptitude -F '%c %p' search ${tocheck} 2>/dev/null \
-               | awk '/^p/{print $2}' \
-               | grep -v ':i386$'
+       pkgs=$(aptitude -F '%c %p' search ${tocheck} 2>/dev/null | awk '/^p/{print $2}')
+       if ! [ ${#pkgs} -eq 0 ]; then
+               echo $pkgs | grep -v ':i386$'
+       fi
 }
 
 # parsing the output of yum is close to impossible.
@@ -96,6 +97,9 @@ check_installed_pkgs() {
 }
 
 handle_debian() {
+       if ! [ -x "$(command -v aptitude)" ]; then
+               apt-get install aptitude
+       fi
        extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
        $testcmd aptitude install -y $extra_packs
 }