LocalAI/scripts/debian.sh
Aisuko 4117509927
feat: split building process by several scripts
Signed-off-by: GitHub <noreply@github.com>
2023-06-18 12:46:51 +00:00

46 lines
No EOL
1.3 KiB
Bash

#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./debian.sh [upgrade packages flag]
set -e
UPGRADE_PACKAGES=${1:-"true"}
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Function to call apt-get if needed
apt_get_update_if_needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
}
# Get to latest versions of all packages
if [ "${UPGRADE_PACKAGES}" = "true" ]; then
apt_get_update_if_needed
apt-get -y upgrade --no-install-recommends
apt-get autoremove -y
fi
# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
apt_get_update_if_needed
package_list="apt-utils \
ca-certificates \
cmake \
patch \
curl"
echo "Packages to verify are installed: ${package_list}"
apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
PACKAGES_ALREADY_INSTALLED="true"
fi
echo "Done!"