From d13087cb4ebf3172ee5794259908f7db22e5c8f1 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 16 Jun 2007 21:21:21 +0000 Subject: [PATCH] 2007-06-16 21:21:21 by steve Updated common.sh such that installing and removing packages can be done with more than one package at a time. Useful for dependency problems. --- hooks/common.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hooks/common.sh b/hooks/common.sh index adcdf34..56166ec 100644 --- a/hooks/common.sh +++ b/hooks/common.sh @@ -1,3 +1,4 @@ + #!/bin/sh # # Common shell functions which may be used by any hook script @@ -55,25 +56,26 @@ assert () # -# Install a Debian package via apt-get. +# Install a number of Debian packages via apt-get. # # We take special care so that daemons shouldn't start after installation # which they might otherwise do. # +# NOTE: Function not renamed with trailing "s" for compatability reasons. +# installDebianPackage () { prefix=$1 - package=$2 + shift # # Log our options # - logMessage "Installing Debian package ${package} to prefix ${prefix}" + logMessage "Installing Debian packages $@ to prefix ${prefix}" # # We require a package + prefix # - assert "$LINENO" "${package}" assert "$LINENO" "${prefix}" # @@ -95,9 +97,9 @@ installDebianPackage () disableStartStopDaemon ${prefix} # - # Install the package + # Install the packages # - DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install ${package} + DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install "$@" # # Remove the policy-rc.d script. @@ -154,12 +156,14 @@ enableStartStopDaemon () # -# Remove a Debian package. +# Remove the specified Debian packages. +# +# NOTE: Function not renamed with trailing "s" for compatability reasons. # removeDebianPackage () { prefix=$1 - package=$2 + shift # # Log our options @@ -167,9 +171,8 @@ removeDebianPackage () logMessage "Purging Debian package ${package} from prefix ${prefix}" # - # We require a package + prefix + # We require a prefix # - assert "$LINENO" "${package}" assert "$LINENO" "${prefix}" # @@ -178,9 +181,9 @@ removeDebianPackage () assert "$LINENO" -d ${prefix} # - # Purge the package + # Purge the packages we've been given. # - chroot ${prefix} /usr/bin/dpkg --purge ${package} + chroot ${prefix} /usr/bin/dpkg --purge "$@" }