diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-07-12 10:04:19 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-07-12 10:04:19 +0000 |
commit | 65c8c1ce19305af9f8b54e424f4f193d7c5552e7 (patch) | |
tree | c8b24c6ed1a8f39a97b8d0196af8891fa02c80ce /build_tools | |
parent | c3fa589937545e9d44d086d780d72d0a4cb6b2ce (diff) |
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.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2728 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'build_tools')
-rwxr-xr-x | build_tools/install_prereq | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/build_tools/install_prereq b/build_tools/install_prereq new file mode 100755 index 0000000..0fb7f47 --- /dev/null +++ b/build_tools/install_prereq @@ -0,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 "#############################################" |