[svn-commits] tzafrir: branch 1.2 r2880 - /branches/1.2/build_tools/install_prereq

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 17 13:10:24 CDT 2007


Author: tzafrir
Date: Fri Aug 17 13:10:23 2007
New Revision: 2880

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2880
Log:
install_prereq: Don't install packages twice.

Modified:
    branches/1.2/build_tools/install_prereq

Modified: branches/1.2/build_tools/install_prereq
URL: http://svn.digium.com/view/zaptel/branches/1.2/build_tools/install_prereq?view=diff&rev=2880&r1=2879&r2=2880
==============================================================================
--- branches/1.2/build_tools/install_prereq (original)
+++ branches/1.2/build_tools/install_prereq Fri Aug 17 13:10:23 2007
@@ -26,6 +26,23 @@
 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 @@
 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 @@
 		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 @@
 		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




More information about the svn-commits mailing list