blob: 7bf4199fa3a33ef6fafe19532914cf50bf9c4393 (
plain) (
tree)
|
|
#!/bin/bash
install_package() {
# These stacked ifs are just a stopgap until proper trapping.
echo -n "# Installing package $PACKAGE... "
apt-get -qq -y --no-install-recommends install ${PACKAGE}
ERR=$?
if [ "$ERR" -ne 0 ]; then
echo
echo "# Could not install package $PACKAGE - Error number $ERR!"
echo -n "# Trying an apt-get update..."
apt-get update 2>/dev/null 1>&2
ERR=$?
if [ "$ERR" -ne 0 ]; then
echo
echo "# apt-get update has thrown error number $ERR. You need to take care"
echo "# of this by hand. Commencing installation."
else
echo " ok."
echo -n "# Retrying installing package $PACKAGE... "
apt-get -qq -y --no-install-recommends install ${PACKAGE} 2>/dev/null 1>&2
ERR=$?
if [ "$ERR" -ne 0 ]; then
echo "Could not install $PACKAGE. Giving up."
exit 1
else
echo "ok."
fi
fi
else
echo "ok."
fi
}
install_packages() {
local NEEDED_PACKAGES="$1"
echo "#"
echo "# Installing packages. This may take a while."
echo "#"
for PACKAGE in $NEEDED_PACKAGES; do
install_package
done
}
|