[zaptel-commits] tzafrir: branch 1.2 r2728 - /branches/1.2/build_tools/install_prereq

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Jul 12 05:04:20 CDT 2007


Author: tzafrir
Date: Thu Jul 12 05:04:19 2007
New Revision: 2728

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2728
Log:
Add a script to install build requirements.

This was after the instructions on which kernel to install on CentOS 
became a manual script with if-s and case-s.

Should work on Debian and CentOS.

Added:
    branches/1.2/build_tools/install_prereq   (with props)

Added: branches/1.2/build_tools/install_prereq
URL: http://svn.digium.com/view/zaptel/branches/1.2/build_tools/install_prereq?view=auto&rev=2728
==============================================================================
--- branches/1.2/build_tools/install_prereq (added)
+++ branches/1.2/build_tools/install_prereq Thu Jul 12 05:04:19 2007
@@ -1,0 +1,93 @@
+#! /bin/sh
+
+# install_prereq: a script to install distribution-specific
+# prerequirements
+
+set -e
+
+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."
+  echo "Usage: $0 install  Really install."
+}
+
+PACKAGES_DEBIAN="build-essential libnewt-dev libusb-dev"
+PACKAGES_RH="gcc newt-devel libusb-devel"
+KVERS=`uname -r`
+
+case "$1" in
+test)    testcmd=echo ;;
+install) testcmd='' ;;
+'') usage; exit 0 ;;
+*) usage; exit 1 ;;
+esac
+
+
+
+has_kernel_source() {
+	test -r /lib/modules/$KVERS/build/.config
+}
+
+in_test_mode() {
+  test "$testcmd" != ''
+}
+
+handle_debian() {
+	# echo "# Distribution is Debian or compatible"
+	kernel_package=''
+	if ! has_kernel_source; then
+		kernel_package="linux-headers-$KVERS"
+		debian_release=`cat /etc/debian_version`
+		case "$debian_release" in
+		3.1) kernel_package="kernel-headers-$KVERS";;
+		esac
+		echo "# Kernel source not found. Installing $kernel_package"
+	fi
+	$testcmd apt-get install -y $PACKAGES_DEBIAN $kernel_package
+}
+
+handle_rh() {
+	# echo "# Distribution is Debian or compatible"
+	kernel_package=''
+	if ! has_kernel_source; then
+		kern_str='' # extra "kernel version"
+		case $KVERS in
+		*smp*) kern_str='-smp';;
+		*PAE*) kern_str='-PAE';;
+		*xen*) kern_str='-xen';;
+		esac
+		kernel_package="kernel$kern_str-devel-$KVERS"
+		echo "# Kernel source not found. Installing $kernel_package"
+
+		echo "# if you get an error for the following command, consider"
+		echo "#"
+		echo "#yum install -y kernel$kern_str kernel$kern_str-devel"
+		echo "#"
+		echo "# and then reboot to upgrade to the newly installed kernel."
+	fi
+	$testcmd yum install -y $PACKAGES_RH $kernel_package
+}
+
+if in_test_mode; then
+	echo "#############################################"
+	echo "## $1: test mode."
+	echo "## Use the commands here to install your system."
+	echo "#############################################"
+fi
+
+# handle the easy case of Debians first
+if [ -r /etc/debian_version ]; then
+  handle_debian
+elif [ -r /etc/redhat-release ]; then
+  handle_rh
+fi
+
+echo "#############################################"
+echo "## $1 completed successfully"
+if in_test_mode; then
+	echo "## (in test mode)"
+fi
+echo "#############################################"

Propchange: branches/1.2/build_tools/install_prereq
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/1.2/build_tools/install_prereq
------------------------------------------------------------------------------
    svn:executable = *

Propchange: branches/1.2/build_tools/install_prereq
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Keywords

Propchange: branches/1.2/build_tools/install_prereq
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the zaptel-commits mailing list