Unverified Commit 0cafeee8 authored by Josh Spicer's avatar Josh Spicer Committed by GitHub

favor correctness by removing `apt update ...` short-circuiting (#98)

* favor correctness by removing apt update shortciruiting

* Update install.sh

* apt_get_upadate in node

* update test
parent 58e42503
......@@ -64,7 +64,7 @@ updaterc() {
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt-get update
apt-get update -y
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -62,21 +62,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -35,21 +35,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -127,7 +122,7 @@ install_using_apt() {
install_using_pip() {
echo "(*) No pre-built binaries available in apt-cache. Installing via pip3."
if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install python3-minimal python3-pip libffi-dev python3-venv
fi
export PIPX_HOME=/usr/local/pipx
......
......@@ -60,15 +60,10 @@ fi
# 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()
apt_get_update()
{
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
apt-get update -y
}
# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
......@@ -134,7 +129,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
apt-get update
package_list="${package_list} manpages-posix manpages-posix-dev"
else
apt_get_update_if_needed
apt_get_update
fi
# Install libssl1.1 if available
......@@ -167,7 +162,7 @@ fi
# Get to latest versions of all packages
if [ "${UPGRADE_PACKAGES}" = "true" ]; then
apt_get_update_if_needed
apt_get_update
apt-get -y upgrade --no-install-recommends
apt-get autoremove -y
fi
......@@ -366,7 +361,7 @@ fi
# Optionally install and configure zsh and Oh My Zsh!
if [ "${INSTALL_ZSH}" = "true" ]; then
if ! type zsh > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get install -y zsh
fi
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
......
......@@ -149,22 +149,16 @@ copy_fluxbox_config() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -176,7 +170,7 @@ check_packages() {
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
apt_get_update_if_needed
apt_get_update
# On older Ubuntu, Tilix is in a PPA. on Debian strech its in backports.
if [[ -z $(apt-cache --names-only search ^tilix$) ]]; then
......
......@@ -59,21 +59,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -118,7 +113,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install dependencies
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install git
fi
......@@ -212,7 +207,7 @@ else
if [ "${TARGET_COMPOSE_ARCH}" != "x86_64" ]; then
# Use pip to get a version that runns on this architecture
if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install python3-minimal python3-pip libffi-dev python3-venv
fi
export PIPX_HOME=/usr/local/pipx
......@@ -287,7 +282,7 @@ DOCKER_GID="$(grep -oP '^docker:x:\K[^:]+' /etc/group)"
# If enabling non-root access and specified user is found, setup socat and add script
chown -h "${USERNAME}":root "${TARGET_SOCKET}"
if ! dpkg -s socat > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install socat
fi
tee /usr/local/share/docker-init.sh > /dev/null \
......
......@@ -69,21 +69,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -158,7 +153,7 @@ fi
# Install dependencies
check_packages apt-transport-https curl ca-certificates pigz iptables gnupg2 dirmngr
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install git
fi
......@@ -254,7 +249,7 @@ else
if [ "${target_compose_arch}" != "x86_64" ]; then
# Use pip to get a version that runs on this architecture
if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install python3-minimal python3-pip libffi-dev python3-venv
fi
export PIPX_HOME=/usr/local/pipx
......
......@@ -107,20 +107,16 @@ updaterc() {
fi
}
# Run apt-get if needed.
apt_get_update_if_needed() {
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt_get_update()
{
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
apt-get update -y
}
# Check if packages are installed and installs them if not.
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -105,21 +105,16 @@ receive_gpg_keys() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -183,7 +178,7 @@ export DEBIAN_FRONTEND=noninteractive
. /etc/os-release
check_packages curl ca-certificates gnupg2 dirmngr apt-transport-https
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
if [ "${ID}" = "debian" ]; then
......
......@@ -74,21 +74,16 @@ receive_gpg_keys() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -138,21 +138,16 @@ receive_gpg_keys() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -162,7 +157,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install curl, apt-transport-https, curl, gpg, or dirmngr, git if missing
check_packages curl ca-certificates apt-transport-https dirmngr gnupg2
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -107,21 +107,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -131,7 +126,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install curl, tar, git, other dependencies if missing
check_packages curl ca-certificates gnupg2 tar g++ gcc libc6-dev make pkg-config
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -61,21 +61,16 @@ updaterc() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -62,21 +62,16 @@ updaterc() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -100,21 +100,16 @@ find_version_from_git_tags() {
echo "${variable_name}=${!variable_name}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -125,7 +120,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install dependencies
check_packages curl ca-certificates coreutils gnupg2 dirmngr bash-completion
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -61,21 +61,15 @@ updaterc() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt_get_update() {
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -186,7 +180,7 @@ if [ "${INSTALL_TOOLS_FOR_NODE_GYP}" = "true" ]; then
to_install="${to_install} python3-minimal"
fi
if [ ! -z "${to_install}" ]; then
apt_get_update_if_needed
apt_get_update
apt-get -y install ${to_install}
fi
fi
......
......@@ -51,29 +51,24 @@ function updaterc() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt-get -y install --no-install-recommends "$@"
apt_get_update
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends "$@"
fi
}
install_dotnet_using_apt() {
echo "Attempting to auto-install dotnet..."
install_from_microsoft_feed=false
apt_get_update_if_needed
apt_get_update
apt-get -yq install dotnet6 || install_from_microsoft_feed="true"
if [ "${install_from_microsoft_feed}" = "true" ]; then
......
......@@ -72,21 +72,16 @@ get_common_setting() {
echo "$1=${!1}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -123,7 +118,7 @@ install_using_github() {
# Fall back on direct download if no apt package exists in microsoft pool
check_packages curl ca-certificates gnupg2 dirmngr libc6 libgcc1 libgssapi-krb5-2 libstdc++6 libunwind8 libuuid1 zlib1g libicu[0-9][0-9]
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get install -y --no-install-recommends git
fi
if [ "${architecture}" = "amd64" ]; then
......
......@@ -197,21 +197,16 @@ oryx_install() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -237,7 +232,7 @@ install_from_source() {
libbz2-dev libreadline-dev libxml2-dev xz-utils libgdbm-dev tk-dev dirmngr \
libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev uuid-dev
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -152,21 +152,16 @@ find_version_from_git_tags() {
echo "${variable_name}=${!variable_name}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -185,7 +180,7 @@ check_packages curl ca-certificates software-properties-common build-essential g
procps dirmngr gawk autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev \
libsqlite3-dev libtool libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libssl-dev
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -125,22 +125,17 @@ updaterc() {
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, lldb, python3-minimal,libpython and rust dependencies if missing
if ! dpkg -s curl ca-certificates gnupg2 lldb python3-minimal gcc libc6-dev > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends curl ca-certificates gcc libc6-dev
apt-get -y install lldb python3-minimal libpython3.?
fi
......@@ -175,7 +170,7 @@ else
if [ "${RUST_VERSION}" != "latest" ] && [ "${RUST_VERSION}" != "lts" ] && [ "${RUST_VERSION}" != "stable" ]; then
# Find version using soft match
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -39,10 +39,16 @@ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
apt_get_update()
{
echo "Running apt-get update..."
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt-get update -y
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......
......@@ -122,21 +122,16 @@ find_version_from_git_tags() {
echo "${variable_name}=${!variable_name}"
}
# Function to run apt-get if needed
apt_get_update_if_needed()
apt_get_update()
{
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
apt-get update -y
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}
......@@ -147,7 +142,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install dependencies if missing
check_packages curl ca-certificates gnupg2 dirmngr coreutils unzip
if ! type git > /dev/null 2>&1; then
apt_get_update_if_needed
apt_get_update
apt-get -y install --no-install-recommends git
fi
......
......@@ -8,9 +8,10 @@ source dev-container-features-test-lib
# Definition specific tests
check "dotnet" dotnet --info
check "sdks" dotnet --list-sdks
check "version" dotnet --version
echo "Validating expected version present..."
check "some major version of dotnet 6 is installed" dotnet --list-sdks | grep '6\.[0-9]*\.[0-9]*'
check "some major version of dotnet 6 is installed" dotnet --version | grep '6\.[0-9]*\.[0-9]*'
# Report result
reportResults
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment