From a8cb375d460840bbf8c91599d16fc87d9ee8b996 Mon Sep 17 00:00:00 2001 From: eitsupi <50911393+eitsupi@users.noreply.github.com> Date: Tue, 11 Oct 2022 07:33:01 +0900 Subject: Ensure remove apt-update cache at the beginning and end of the scripts (#210) * remove apt lists * bump versions --- src/oryx/devcontainer-feature.json | 2 +- src/oryx/install.sh | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/oryx') diff --git a/src/oryx/devcontainer-feature.json b/src/oryx/devcontainer-feature.json index 2e40e88..2abf1f2 100644 --- a/src/oryx/devcontainer-feature.json +++ b/src/oryx/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "oryx", - "version": "1.0.6", + "version": "1.0.7", "name": "Oryx", "description": "Installs the oryx CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx", diff --git a/src/oryx/install.sh b/src/oryx/install.sh index 826d916..f84cf22 100755 --- a/src/oryx/install.sh +++ b/src/oryx/install.sh @@ -12,6 +12,9 @@ MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc" set -eu +# Clean up +rm -rf /var/lib/apt/lists/* + if [ "$(id -u)" -ne 0 ]; then echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 @@ -53,19 +56,17 @@ function updaterc() { apt_get_update() { - echo "Running apt-get update..." - apt-get update -y + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi } # Checks if packages are installed and installs them if not check_packages() { if ! dpkg -s "$@" > /dev/null 2>&1; then apt_get_update - DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends "$@" - - # Clean up - apt-get clean -y - rm -rf /var/lib/apt/lists/* + apt-get -y install --no-install-recommends "$@" fi } @@ -105,6 +106,8 @@ fi # If we don't already have Oryx installed, install it now. if oryx --version > /dev/null ; then echo "oryx is already installed. Skipping installation." + # Clean up + rm -rf /var/lib/apt/lists/* exit 0 fi @@ -182,4 +185,7 @@ if [[ "${DOTNET_INSTALLATION_PACKAGE}" != "" ]]; then apt purge -yq $DOTNET_INSTALLATION_PACKAGE fi +# Clean up +rm -rf /var/lib/apt/lists/* + echo "Done!" -- cgit v1.2.3