1
0
mirror of synced 2026-01-19 09:08:30 +00:00
steve 2196e621ad 2006-06-23 17:55:40 by steve
Add a stub function 'installGentooPackage' since this is called
 to install OpenSSH.
2006-06-23 17:55:40 +00:00

129 lines
2.0 KiB
Bash

#
# Common shell functions which may be used by any hook script
#
# If you find that a distribution-specific hook script or two
# are doing the same thing more than once it should be added here.
#
# This script also includes a logging utility which you're encouraged
# to use.
#
# Steve
# --
#
#
# If we're running verbosely show a message, otherwise swallow it.
#
function logMessage
{
message="$*"
if [ ! -z "${verbose}" ]; then
echo $message
fi
}
#
# Test the given condition is true, and if not abort.
#
# Sample usage:
# assert $LINENO "${verbose}"
#
assert ()
{
line=$1;
shift;
if ! [ $* ] ; then
echo "assert failed: $0:$lineno [$*]"
exit
fi
}
#
# Install a Debian package via apt-get.
#
function installDebianPackage
{
prefix=$1
package=$2
#
# Log our options
#
logMessage "Installing Debian package ${package} to prefix ${prefix}"
#
# We require a package + prefix
#
assert $LINENO "${package}"
assert $LINENO "${prefix}"
#
# Prefix must be a directory.
#
assert $LINENO -d ${prefix}
#
# Install the package
#
DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install ${package}
}
#
# Install a CentOS4 package via yum
#
function installCentOS4Package
{
prefix=$1
package=$2
#
# Log our options
#
logMessage "Installing CentOS4 ${package} to prefix ${prefix}"
#
# We require a package + prefix
#
assert $LINENO "${package}"
assert $LINENO "${prefix}"
#
# Prefix must be a directory.
#
assert $LINENO -d ${prefix}
#
# Install the package
#
chroot ${prefix} /usr/bin/yum -y install ${package}
}
#
# Install a package upon a gentoo system via emerge.
#
# TODO: STUB
#
function installDebianPackage
{
prefix=$1
package=$2
#
# Log our options
#
logMessage "Installing Gentoo package ${package} to prefix ${prefix}"
logMessage "NOTE: Not doing anything - this is a stub - FIXME"
}