From 7bdd6a58b4ada80df2892c63f6b573cd3f717a1d Mon Sep 17 00:00:00 2001 From: tzafrir Date: Fri, 17 Aug 2007 18:10:23 +0000 Subject: install_prereq: Don't install packages twice. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2880 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- build_tools/install_prereq | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'build_tools') diff --git a/build_tools/install_prereq b/build_tools/install_prereq index 0fb7f47..56463b4 100755 --- a/build_tools/install_prereq +++ b/build_tools/install_prereq @@ -26,6 +26,23 @@ install) testcmd='' ;; esac +# Fixme: should be done by apt and not by dpkg? +check_installed_debs() { + dpkg-query -W --showformat '${Status} ${Package}\n' "$@" 2>/dev/null \ + | awk '/ not-installed/{print $4}' +} + +# 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 +} + has_kernel_source() { test -r /lib/modules/$KVERS/build/.config @@ -38,6 +55,7 @@ in_test_mode() { handle_debian() { # echo "# Distribution is Debian or compatible" kernel_package='' + extra_packs=`check_installed_debs $PACKAGES_DEBIAN` if ! has_kernel_source; then kernel_package="linux-headers-$KVERS" debian_release=`cat /etc/debian_version` @@ -46,15 +64,16 @@ handle_debian() { esac echo "# Kernel source not found. Installing $kernel_package" fi - $testcmd apt-get install -y $PACKAGES_DEBIAN $kernel_package + $testcmd apt-get install -y $extra_packs $kernel_package } handle_rh() { - # echo "# Distribution is Debian or compatible" + # echo "# Distribution is RedHat or similar." kernel_package='' + extra_packs=`check_installed_rpms $PACKAGES_RH` if ! has_kernel_source; then kern_str='' # extra "kernel version" - case $KVERS in + case "$KVERS" in *smp*) kern_str='-smp';; *PAE*) kern_str='-PAE';; *xen*) kern_str='-xen';; @@ -68,7 +87,7 @@ handle_rh() { echo "#" echo "# and then reboot to upgrade to the newly installed kernel." fi - $testcmd yum install -y $PACKAGES_RH $kernel_package + $testcmd yum install -y $extra_packs $kernel_package } if in_test_mode; then -- cgit v1.2.3