From f78722d2504c29051d581cb972ef6e82ffa4c6af Mon Sep 17 00:00:00 2001 From: CI Date: Sun, 26 Sep 2021 18:02:19 +0000 Subject: [PATCH] Automated update for script library changes --- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-alpine.sh | 0 .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/node-debian.sh | 8 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/node-debian.sh | 8 +- .../library-scripts/terraform-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../docker-in-docker-debian.sh | 20 +- .../library-scripts/git-from-src-debian.sh | 4 +- .../library-scripts/git-lfs-debian.sh | 58 +++-- .../library-scripts/github-debian.sh | 4 +- .../library-scripts/go-debian.sh | 7 +- .../library-scripts/gradle-debian.sh | 6 +- .../library-scripts/java-debian.sh | 6 +- .../library-scripts/kubectl-helm-debian.sh | 0 .../library-scripts/maven-debian.sh | 6 +- .../library-scripts/node-debian.sh | 8 +- .../library-scripts/powershell-debian.sh | 34 ++- .../library-scripts/python-debian.sh | 234 ++++++++++-------- .../library-scripts/ruby-debian.sh | 8 +- .../library-scripts/rust-debian.sh | 6 +- .../library-scripts/sshd-debian.sh | 0 .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../docker-in-docker-debian.sh | 20 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/azcli-debian.sh | 2 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/go-debian.sh | 7 +- .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/gradle-debian.sh | 6 +- .../library-scripts/java-debian.sh | 6 +- .../library-scripts/maven-debian.sh | 6 +- .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../docker-in-docker-debian.sh | 20 +- .../library-scripts/kubectl-helm-debian.sh | 0 .../library-scripts/common-debian.sh | 1 + .../library-scripts/docker-debian.sh | 8 +- .../library-scripts/kubectl-helm-debian.sh | 0 .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/python-debian.sh | 234 ++++++++++-------- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/python-debian.sh | 234 ++++++++++-------- .../library-scripts/common-debian.sh | 1 + .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/ruby-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/rust-debian.sh | 6 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/node-debian.sh | 8 +- .../library-scripts/common-debian.sh | 1 + .../library-scripts/desktop-lite-debian.sh | 2 +- 96 files changed, 708 insertions(+), 473 deletions(-) mode change 100644 => 100755 container-templates/docker-compose/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 container-templates/dockerfile/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/alpine/.devcontainer/library-scripts/common-alpine.sh mode change 100644 => 100755 containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/azure-ansible/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/azure-ansible/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/azure-bicep/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/azure-bicep/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/azure-cli/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/azure-functions-dotnetcore-2.1/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/azure-static-web-apps/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/azure-terraform/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/azure-terraform/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/azure-terraform/.devcontainer/library-scripts/terraform-debian.sh mode change 100644 => 100755 containers/bazel/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/git-from-src-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/github-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/go-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/gradle-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/java-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/kubectl-helm-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/maven-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/powershell-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/rust-debian.sh mode change 100644 => 100755 containers/codespaces-linux/.devcontainer/library-scripts/sshd-debian.sh mode change 100644 => 100755 containers/dapr-dotnet/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/dapr-dotnet/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/dapr-javascript-node/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/dart/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/debian/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/docker-from-docker-compose/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/docker-from-docker-compose/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/docker-from-docker/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/docker-in-docker/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/docker-in-docker/.devcontainer/library-scripts/docker-in-docker-debian.sh mode change 100644 => 100755 containers/dotnet-fsharp/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/dotnet-mssql/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh mode change 100644 => 100755 containers/dotnet/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/dotnet/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/go/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/go/.devcontainer/library-scripts/go-debian.sh mode change 100644 => 100755 containers/go/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/haskell/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/java/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/java/.devcontainer/library-scripts/gradle-debian.sh mode change 100644 => 100755 containers/java/.devcontainer/library-scripts/java-debian.sh mode change 100644 => 100755 containers/java/.devcontainer/library-scripts/maven-debian.sh mode change 100644 => 100755 containers/java/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/javascript-node/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/javascript-node/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/jupyter-datascience-notebooks/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/kubernetes-helm-minikube/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/kubernetes-helm-minikube/.devcontainer/library-scripts/docker-in-docker-debian.sh mode change 100644 => 100755 containers/kubernetes-helm-minikube/.devcontainer/library-scripts/kubectl-helm-debian.sh mode change 100644 => 100755 containers/kubernetes-helm/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/kubernetes-helm/.devcontainer/library-scripts/docker-debian.sh mode change 100644 => 100755 containers/kubernetes-helm/.devcontainer/library-scripts/kubectl-helm-debian.sh mode change 100644 => 100755 containers/mit-scheme/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/perl/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/php/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/php/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/powershell/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/python-3-anaconda/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/python-3-anaconda/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/python-3-miniconda/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/python-3-miniconda/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/python-3-miniconda/.devcontainer/library-scripts/python-debian.sh mode change 100644 => 100755 containers/python-3-pypy/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/python-3/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/python-3/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/python-3/.devcontainer/library-scripts/python-debian.sh mode change 100644 => 100755 containers/r/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/ruby/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/ruby/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/ruby/.devcontainer/library-scripts/ruby-debian.sh mode change 100644 => 100755 containers/rust/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/rust/.devcontainer/library-scripts/rust-debian.sh mode change 100644 => 100755 containers/swift/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 containers/swift/.devcontainer/library-scripts/node-debian.sh mode change 100644 => 100755 containers/ubuntu/.devcontainer/library-scripts/common-debian.sh mode change 100644 => 100755 repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh diff --git a/container-templates/docker-compose/.devcontainer/library-scripts/common-debian.sh b/container-templates/docker-compose/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/container-templates/docker-compose/.devcontainer/library-scripts/common-debian.sh +++ b/container-templates/docker-compose/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/container-templates/dockerfile/.devcontainer/library-scripts/common-debian.sh b/container-templates/dockerfile/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/container-templates/dockerfile/.devcontainer/library-scripts/common-debian.sh +++ b/container-templates/dockerfile/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/alpine/.devcontainer/library-scripts/common-alpine.sh b/containers/alpine/.devcontainer/library-scripts/common-alpine.sh old mode 100644 new mode 100755 diff --git a/containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh b/containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/azure-ansible/.devcontainer/library-scripts/common-debian.sh b/containers/azure-ansible/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/azure-ansible/.devcontainer/library-scripts/common-debian.sh +++ b/containers/azure-ansible/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh b/containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/azure-ansible/.devcontainer/library-scripts/node-debian.sh b/containers/azure-ansible/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/azure-ansible/.devcontainer/library-scripts/node-debian.sh +++ b/containers/azure-ansible/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh b/containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/azure-bicep/.devcontainer/library-scripts/common-debian.sh b/containers/azure-bicep/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/azure-bicep/.devcontainer/library-scripts/common-debian.sh +++ b/containers/azure-bicep/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/azure-bicep/.devcontainer/library-scripts/node-debian.sh b/containers/azure-bicep/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/azure-bicep/.devcontainer/library-scripts/node-debian.sh +++ b/containers/azure-bicep/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh b/containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/azure-cli/.devcontainer/library-scripts/common-debian.sh b/containers/azure-cli/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/azure-cli/.devcontainer/library-scripts/common-debian.sh +++ b/containers/azure-cli/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/azure-functions-dotnetcore-2.1/.devcontainer/library-scripts/common-debian.sh b/containers/azure-functions-dotnetcore-2.1/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/azure-functions-dotnetcore-2.1/.devcontainer/library-scripts/common-debian.sh +++ b/containers/azure-functions-dotnetcore-2.1/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/azure-static-web-apps/.devcontainer/library-scripts/node-debian.sh b/containers/azure-static-web-apps/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/azure-static-web-apps/.devcontainer/library-scripts/node-debian.sh +++ b/containers/azure-static-web-apps/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh b/containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/azure-terraform/.devcontainer/library-scripts/common-debian.sh b/containers/azure-terraform/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/azure-terraform/.devcontainer/library-scripts/common-debian.sh +++ b/containers/azure-terraform/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh b/containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/azure-terraform/.devcontainer/library-scripts/node-debian.sh b/containers/azure-terraform/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/azure-terraform/.devcontainer/library-scripts/node-debian.sh +++ b/containers/azure-terraform/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/azure-terraform/.devcontainer/library-scripts/terraform-debian.sh b/containers/azure-terraform/.devcontainer/library-scripts/terraform-debian.sh old mode 100644 new mode 100755 index 6cdd2645..f2614aeb --- a/containers/azure-terraform/.devcontainer/library-scripts/terraform-debian.sh +++ b/containers/azure-terraform/.devcontainer/library-scripts/terraform-debian.sh @@ -84,7 +84,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } diff --git a/containers/bazel/.devcontainer/library-scripts/common-debian.sh b/containers/bazel/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/bazel/.devcontainer/library-scripts/common-debian.sh +++ b/containers/bazel/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/common-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/codespaces-linux/.devcontainer/library-scripts/common-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh old mode 100644 new mode 100755 index 74a7935d..8ad2a795 --- a/containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh @@ -76,7 +76,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 +check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 dirmngr # Swap to legacy iptables for compatibility if type iptables-legacy > /dev/null 2>&1; then @@ -85,6 +85,7 @@ if type iptables-legacy > /dev/null 2>&1; then fi # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then echo "Docker / Moby CLI and Engine already installed." else @@ -94,9 +95,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose moby-engine + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg @@ -112,11 +114,11 @@ echo "Finished installing docker / moby" if type docker-compose > /dev/null 2>&1; then echo "Docker Compose already installed." else - TARGET_COMPOSE_ARCH="$(uname -m)" - if [ "${TARGET_COMPOSE_ARCH}" = "amd64" ]; then - TARGET_COMPOSE_ARCH="x86_64" + target_compose_arch="${architecture}" + if [ "${target_compose_arch}" = "amd64" ]; then + target_compose_arch="x86_64" fi - if [ "${TARGET_COMPOSE_ARCH}" != "x86_64" ]; then + 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 @@ -135,8 +137,8 @@ else ${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose rm -rf /tmp/pip-tmp else - LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") - curl -fsSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-${TARGET_COMPOSE_ARCH}" -o /usr/local/bin/docker-compose + latest_compose_version=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") + curl -fsSL "https://github.com/docker/compose/releases/download/${latest_compose_version}/docker-compose-$(uname -s)-${target_compose_arch}" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose fi fi diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/git-from-src-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/git-from-src-debian.sh old mode 100644 new mode 100755 index 6273eea8..11a4f0ba --- a/containers/codespaces-linux/.devcontainer/library-scripts/git-from-src-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/git-from-src-debian.sh @@ -71,7 +71,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -102,7 +102,7 @@ export DEBIAN_FRONTEND=noninteractive # If ubuntu, PPAs allowed, and latest - install from there if ([ "${GIT_VERSION}" = "latest" ] || [ "${GIT_VERSION}" = "lts" ] || [ "${GIT_VERSION}" = "current" ]) && [ "${ID}" = "ubuntu" ] && [ "${USE_PPA_IF_AVAILABLE}" = "true" ]; then echo "Using PPA to install latest git..." - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr receive_gpg_keys GIT_CORE_PPA_ARCHIVE_GPG_KEY /usr/share/keyrings/gitcoreppa-archive-keyring.gpg echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gitcoreppa-archive-keyring.gpg] http://ppa.launchpad.net/git-core/ppa/ubuntu ${VERSION_CODENAME} main\ndeb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gitcoreppa-archive-keyring.gpg] http://ppa.launchpad.net/git-core/ppa/ubuntu ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/git-core-ppa.list apt-get update diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh old mode 100644 new mode 100755 index d9813cc7..8b4b2652 --- a/containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh @@ -12,7 +12,7 @@ GIT_LFS_VERSION=${1:-"latest"} GIT_LFS_ARCHIVE_GPG_KEY_URI="https://packagecloud.io/github/git-lfs/gpgkey" GIT_LFS_ARCHIVE_ARCHITECTURES="amd64" -GIT_LFS_ARCHIVE_VERSION_CODENAMES="stretch buster bionic focal" +GIT_LFS_ARCHIVE_VERSION_CODENAMES="stretch buster bullseye bionic focal" GIT_LFS_CHECKSUM_GPG_KEYS="0x88ace9b29196305ba9947552f1ba225c0223b187 0x86cd3297749375bcf8206715f54fe648088335a9 0xaa3b3450295830d2de6db90caba67be5a5795889" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org @@ -101,7 +101,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -125,24 +125,7 @@ check_packages() { fi } -export DEBIAN_FRONTEND=noninteractive - -# Install git, curl, gpg, and debian-archive-keyring if missing -. /etc/os-release -check_packages curl ca-certificates gnupg2 apt-transport-https -if ! type git > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends git -fi -if [ "${ID}" = "debian" ]; then - check_packages debian-archive-keyring -fi - - -# Install Git LFS -echo "Installing Git LFS..." -architecture="$(dpkg --print-architecture)" -if [[ "${GIT_LFS_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${GIT_LFS_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then +install_using_apt() { # Soft version matching if [ "${GIT_LFS_VERSION}" != "latest" ] && [ "${GIT_LFS_VERSION}" != "lts" ] && [ "${GIT_LFS_VERSION}" != "stable" ]; then find_version_from_git_tags GIT_LFS_VERSION "https://github.com/git-lfs/git-lfs" @@ -154,10 +137,12 @@ if [[ "${GIT_LFS_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${GIT_ get_common_setting GIT_LFS_ARCHIVE_GPG_KEY_URI curl -sSL "${GIT_LFS_ARCHIVE_GPG_KEY_URI}" | gpg --dearmor > /usr/share/keyrings/gitlfs-archive-keyring.gpg echo -e "deb [arch=${architecture} signed-by=/usr/share/keyrings/gitlfs-archive-keyring.gpg] https://packagecloud.io/github/git-lfs/${ID} ${VERSION_CODENAME} main\ndeb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gitlfs-archive-keyring.gpg] https://packagecloud.io/github/git-lfs/${ID} ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/git-lfs.list - apt-get install -yq git-lfs${version_suffix} + apt-get install -yq git-lfs${version_suffix} || return 1 git lfs install --skip-repo -else - echo "No apt package for ${VERSION_CODENAME} ${architecture}. Installing manually." +} + +install_using_github() { + echo "(*) No apt package for ${VERSION_CODENAME} ${architecture}. Installing manually." mkdir -p /tmp/git-lfs cd /tmp/git-lfs find_version_from_git_tags GIT_LFS_VERSION "https://github.com/git-lfs/git-lfs" @@ -172,6 +157,33 @@ else tar xf "${git_lfs_filename}" -C . ./install.sh rm -rf /tmp/git-lfs /tmp/tmp-gnupg +} + +export DEBIAN_FRONTEND=noninteractive + +# Install git, curl, gpg, dirmngr and debian-archive-keyring if missing +. /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 -y install --no-install-recommends git +fi +if [ "${ID}" = "debian" ]; then + check_packages debian-archive-keyring +fi + +# Install Git LFS +echo "Installing Git LFS..." +architecture="$(dpkg --print-architecture)" +if [[ "${GIT_LFS_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${GIT_LFS_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then + install_using_apt || use_github="true" +else + use_github="true" +fi + +# If no archive exists or apt install fails, try direct from github +if [ "${use_github}" = "true" ]; then + install_using_github fi echo "Done!" \ No newline at end of file diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/github-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/github-debian.sh old mode 100644 new mode 100755 index 4129d7c9..978cc709 --- a/containers/codespaces-linux/.devcontainer/library-scripts/github-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/github-debian.sh @@ -65,7 +65,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -135,7 +135,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/go-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/go-debian.sh old mode 100644 new mode 100755 index d93cc738..47c922d0 --- a/containers/codespaces-linux/.devcontainer/library-scripts/go-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/go-debian.sh @@ -48,13 +48,14 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi } - # Figure out correct version of a three part version number is not passed find_version_from_git_tags() { local variable_name=$1 diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/gradle-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/gradle-debian.sh old mode 100644 new mode 100755 index 493fae6d..6fc8c982 --- a/containers/codespaces-linux/.devcontainer/library-scripts/gradle-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/gradle-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/java-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/java-debian.sh old mode 100644 new mode 100755 index acd1dc12..47aec3aa --- a/containers/codespaces-linux/.devcontainer/library-scripts/java-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/java-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/kubectl-helm-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/kubectl-helm-debian.sh old mode 100644 new mode 100755 diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/maven-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/maven-debian.sh old mode 100644 new mode 100755 index 7e391ac1..2da1839b --- a/containers/codespaces-linux/.devcontainer/library-scripts/maven-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/maven-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/node-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/codespaces-linux/.devcontainer/library-scripts/node-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/powershell-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/powershell-debian.sh old mode 100644 new mode 100755 index 1203d125..2bb6da66 --- a/containers/codespaces-linux/.devcontainer/library-scripts/powershell-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/powershell-debian.sh @@ -91,23 +91,20 @@ check_packages() { fi } -export DEBIAN_FRONTEND=noninteractive - -# Source /etc/os-release to get OS info -. /etc/os-release -architecture="$(dpkg --print-architecture)" -if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then +install_using_apt() { # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update -yq - apt-get install -yq powershell -else - # Fall back on direct download if no apt package exists in microsoft pool - check_packages curl ca-certificates gnupg2 libc6 libgcc1 libgssapi-krb5-2 liblttng-ust0 libstdc++6 libunwind8 libuuid1 zlib1g libicu[0-9][0-9] + apt-get install -yq powershell || return 1 +} + +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 liblttng-ust0 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 install -y --no-install-recommends git @@ -134,6 +131,21 @@ else tar xf "${powershell_filename}" -C "${powershell_target_path}" ln -s "${powershell_target_path}/pwsh" /usr/local/bin/pwsh rm -rf /tmp/pwsh +} + +export DEBIAN_FRONTEND=noninteractive + +# Source /etc/os-release to get OS info +. /etc/os-release +architecture="$(dpkg --print-architecture)" +if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then + install_using_apt || use_github="true" +else + use_github="true" +fi + +if [ "${use_github}" = "true" ]; then + install_using_github fi echo "Done!" \ No newline at end of file diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh old mode 100644 new mode 100755 index 5555a16f..4c470d42 --- a/containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/python-debian.sh @@ -7,7 +7,7 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/python.md # Maintainer: The VS Code and Codespaces Teams # -# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools] +# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools flag] [Use Oryx if available flag] [Optimize when building from source flag] PYTHON_VERSION=${1:-"latest"} PYTHON_INSTALL_PATH=${2:-"/usr/local/python"} @@ -15,9 +15,10 @@ export PIPX_HOME=${3:-"/usr/local/py-utils"} USERNAME=${4:-"automatic"} UPDATE_RC=${5:-"true"} INSTALL_PYTHON_TOOLS=${6:-"true"} -USE_PPA_IF_AVAILABLE=${7:-"true"} +USE_ORYX_IF_AVAILABLE=${7:-"true"} +OPTIMIZE_BUILD_FROM_SOURCE=${8-"false"} -DEADSNAKES_PPA_ARCHIVE_GPG_KEY="F23C5A6CF475977595C89F51BA6932366A755776" +DEFAULT_UTILS=("pylint" "flake8" "autopep8" "black" "yapf" "mypy" "pydocstyle" "pycodestyle" "bandit" "pipenv" "virtualenv") PYTHON_SOURCE_GPG_KEYS="64E628F8D684696D B26995E310250568 2D347EA6AA65421D FB9921286F5E1540 3A5CA953F73C700D 04C367C218ADD4FF 0EDDC5F26A45C816 6AF053F07D9DC8D2 C9BE28DEE6DF025C 126EB563A74B06BF D9866941EA5BBD71 ED9D77D5" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org @@ -55,8 +56,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -109,7 +112,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -148,6 +151,44 @@ find_version_from_git_tags() { echo "${variable_name}=${!variable_name}" } +# Use Oryx to install something using a partial version match +oryx_install() { + local platform=$1 + local requested_version=$2 + local target_folder=${3:-none} + local ldconfig_folder=${4:-none} + echo "(*) Installing ${platform} ${requested_version} using Oryx..." + check_packages jq + # Soft match if full version not specified + if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then + local version_list="$(oryx platforms --json | jq -r ".[] | select(.Name == \"${platform}\") | .Versions | sort | reverse | @tsv" | tr '\t' '\n' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$')" + if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then + requested_version="$(echo "${version_list}" | head -n 1)" + else + set +e + requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" + set -e + fi + if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then + echo -e "(!) Oryx does not support ${platform} version $2\nValid values:\n${version_list}" >&2 + return 1 + fi + echo "(*) Using ${requested_version} in place of $2." + fi + + export ORYX_ENV_TYPE=vsonline-present ORYX_PREFER_USER_INSTALLED_SDKS=true ENABLE_DYNAMIC_INSTALL=true DYNAMIC_INSTALL_ROOT_DIR=/opt + oryx prep --skip-detection --platforms-and-versions "${platform}=${requested_version}" + local opt_folder="/opt/${platform}/${requested_version}" + if [ "${target_folder}" != "none" ] && [ "${target_folder}" != "${opt_folder}" ]; then + ln -s "${opt_folder}" "${target_folder}" + fi + # Update library path add to conf + if [ "${ldconfig_folder}" != "none" ]; then + echo "/opt/${platform}/${requested_version}/lib" >> "/etc/ld.so.conf.d/${platform}.conf" + ldconfig + fi +} + # Function to run apt-get if needed apt_get_update_if_needed() { @@ -167,76 +208,71 @@ check_packages() { fi } -install_from_ppa() { - local requested_version="python${PYTHON_VERSION}" - echo "Using PPA to install Python..." - check_packages apt-transport-https curl ca-certificates gnupg2 - receive_gpg_keys DEADSNAKES_PPA_ARCHIVE_GPG_KEY /usr/share/keyrings/deadsnakes-archive-keyring.gpg - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main\ndeb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/deadsnakes-ppa.list - apt-get update - if [ "${PYTHON_VERSION}" = "latest" ] || [ "${PYTHON_VERSION}" = "current" ] || [ "${PYTHON_VERSION}" = "lts" ]; then - requested_version="$(apt-cache search '^python3\.[0-9]$' | grep -oE '^python3\.[0-9]' | sort -rV | head -n 1)" - echo "Using ${requested_version} in place of ${PYTHON_VERSION}." - fi - apt-get -y install ${requested_version} - rm -rf /tmp/tmp-gnupg - exit 0 -} - install_from_source() { if [ -d "${PYTHON_INSTALL_PATH}" ]; then - echo "Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." exit 1 - else - echo "Building Python ${PYTHON_VERSION} from source..." - # Install prereqs if missing - check_packages curl ca-certificates tar make build-essential libssl-dev zlib1g-dev \ - wget libbz2-dev libreadline-dev libxml2-dev xz-utils tk-dev gnupg2 \ - libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev llvm dirmngr - if ! type git > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends git - fi - - # Find version using soft match - find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" - - # Download tgz of source - mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" - cd /tmp/python-src - TGZ_FILENAME="Python-${PYTHON_VERSION}.tgz" - TGZ_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${TGZ_FILENAME}" - echo "Downloading ${TGZ_FILENAME}..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}" "${TGZ_URL}" - - # Verify signature - if [ "${SKIP_SIGNATURE_CHECK}" != "true" ]; then - receive_gpg_keys PYTHON_SOURCE_GPG_KEYS - echo "Downloading ${TGZ_FILENAME}.asc..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}.asc" "${TGZ_URL}.asc" - gpg --verify "${TGZ_FILENAME}.asc" - fi - - # Update min protocol for testing only - https://bugs.python.org/issue41561 - cp /etc/ssl/openssl.cnf /tmp/python-src/ - sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf - export OPENSSL_CONF=/tmp/python-src/openssl.cnf - - # Untar and build - tar -xzf "/tmp/python-src/${TGZ_FILENAME}" -C "/tmp/python-src" --strip-components=1 - ./configure --prefix="${PYTHON_INSTALL_PATH}" --enable-optimizations --with-ensurepip=install - make -j 8 - make install - cd /tmp - rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env - chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" - ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python - ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip - ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle - ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc - ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config - updaterc "export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}" fi + echo "(*) Building Python ${PYTHON_VERSION} from source..." + # Install prereqs if missing + check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \ + 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 -y install --no-install-recommends git + fi + + # Find version using soft match + find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" + + # Download tgz of source + mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" + cd /tmp/python-src + local tgz_filename="Python-${PYTHON_VERSION}.tgz" + local tgz_url="https://www.python.org/ftp/python/${PYTHON_VERSION}/${tgz_filename}" + echo "Downloading ${tgz_filename}..." + curl -sSL -o "/tmp/python-src/${tgz_filename}" "${tgz_url}" + + # Verify signature + receive_gpg_keys PYTHON_SOURCE_GPG_KEYS + echo "Downloading ${tgz_filename}.asc..." + curl -sSL -o "/tmp/python-src/${tgz_filename}.asc" "${tgz_url}.asc" + gpg --verify "${tgz_filename}.asc" + + # Update min protocol for testing only - https://bugs.python.org/issue41561 + cp /etc/ssl/openssl.cnf /tmp/python-src/ + sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf + export OPENSSL_CONF=/tmp/python-src/openssl.cnf + + # Untar and build + tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1 + local config_args="" + if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then + config_args="--enable-optimizations" + fi + ./configure --prefix="${PYTHON_INSTALL_PATH}" --with-ensurepip=install ${config_args} + make -j 8 + make install + cd /tmp + rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env + chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" + ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python + ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config +} + +install_using_oryx() { + if [ -d "${PYTHON_INSTALL_PATH}" ]; then + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + exit 1 + fi + oryx_install "python" "${PYTHON_VERSION}" "${PYTHON_INSTALL_PATH}" "lib" || return 1 + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config } # Ensure apt is in non-interactive to avoid prompts @@ -244,41 +280,25 @@ export DEBIAN_FRONTEND=noninteractive # Install python from source if needed if [ "${PYTHON_VERSION}" != "none" ]; then - # Source /etc/os-release to get OS info - . /etc/os-release - # If ubuntu, PPAs allowed - install from there - if [ "${ID}" = "ubuntu" ] && [ "${USE_PPA_IF_AVAILABLE}" = "true" ]; then - install_from_ppa + if [ "$(dpkg --print-architecture)" = "amd64" ] && [ "${USE_ORYX_IF_AVAILABLE}" = "true" ] && type oryx > /dev/null 2>&1; then + install_using_oryx || should_install_from_source=true else + should_install_from_source=true + fi + if [ "${should_install_from_source}" = "true" ]; then install_from_source fi + updaterc "if [[ \"\${PATH}\" != *\"${PYTHON_INSTALL_PATH}/bin\"* ]]; then export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}; fi" fi # If not installing python tools, exit if [ "${INSTALL_PYTHON_TOOLS}" != "true" ]; then echo "Done!" - exit 0; + exit 0 fi -DEFAULT_UTILS="\ - pylint \ - flake8 \ - autopep8 \ - black \ - yapf \ - mypy \ - pydocstyle \ - pycodestyle \ - bandit \ - pipenv \ - virtualenv" - -export PIPX_BIN_DIR=${PIPX_HOME}/bin -export PATH=${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH} - -# Update pip -echo "Updating pip..." -python3 -m pip install --no-cache-dir --upgrade pip +export PIPX_BIN_DIR="${PIPX_HOME}/bin" +export PATH="${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH}" # Create pipx group, dir, and set sticky bit if ! cat /etc/group | grep -e "^pipx:" > /dev/null 2>&1; then @@ -290,13 +310,27 @@ mkdir -p ${PIPX_BIN_DIR} chown :pipx ${PIPX_HOME} ${PIPX_BIN_DIR} chmod g+s ${PIPX_HOME} ${PIPX_BIN_DIR} +# Update pip +echo "Updating pip..." +${PYTHON_INSTALL_PATH}/bin/python3 -m pip install --no-cache-dir --upgrade pip + # Install tools echo "Installing Python tools..." export PYTHONUSERBASE=/tmp/pip-tmp export PIP_CACHE_DIR=/tmp/pip-tmp/cache -pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx -/tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx -echo "${DEFAULT_UTILS}" | xargs -n 1 /tmp/pip-tmp/bin/pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' +pipx_path="" +if ! type pipx > /dev/null 2>&1; then + pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx + /tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx + pipx_path="/tmp/pip-tmp/bin/" +fi +for util in ${DEFAULT_UTILS[@]}; do + if ! type ${util} > /dev/null 2>&1; then + ${pipx_path}pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' ${util} + else + echo "${util} already installed. Skipping." + fi +done rm -rf /tmp/pip-tmp updaterc "$(cat << EOF diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh old mode 100644 new mode 100755 index 17ce709e..c4c101ae --- a/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/ruby-debian.sh @@ -52,8 +52,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -105,7 +107,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/rust-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/rust-debian.sh old mode 100644 new mode 100755 index 78a097e5..0f10a385 --- a/containers/codespaces-linux/.devcontainer/library-scripts/rust-debian.sh +++ b/containers/codespaces-linux/.devcontainer/library-scripts/rust-debian.sh @@ -47,8 +47,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/codespaces-linux/.devcontainer/library-scripts/sshd-debian.sh b/containers/codespaces-linux/.devcontainer/library-scripts/sshd-debian.sh old mode 100644 new mode 100755 diff --git a/containers/dapr-dotnet/.devcontainer/library-scripts/azcli-debian.sh b/containers/dapr-dotnet/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/dapr-dotnet/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/dapr-dotnet/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/dapr-dotnet/.devcontainer/library-scripts/docker-debian.sh b/containers/dapr-dotnet/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/dapr-dotnet/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/dapr-dotnet/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/dapr-javascript-node/.devcontainer/library-scripts/docker-debian.sh b/containers/dapr-javascript-node/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/dapr-javascript-node/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/dapr-javascript-node/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/dart/.devcontainer/library-scripts/common-debian.sh b/containers/dart/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/dart/.devcontainer/library-scripts/common-debian.sh +++ b/containers/dart/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/debian/.devcontainer/library-scripts/common-debian.sh b/containers/debian/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/debian/.devcontainer/library-scripts/common-debian.sh +++ b/containers/debian/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/docker-from-docker-compose/.devcontainer/library-scripts/common-debian.sh b/containers/docker-from-docker-compose/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/docker-from-docker-compose/.devcontainer/library-scripts/common-debian.sh +++ b/containers/docker-from-docker-compose/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/docker-from-docker-compose/.devcontainer/library-scripts/docker-debian.sh b/containers/docker-from-docker-compose/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/docker-from-docker-compose/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/docker-from-docker-compose/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/docker-from-docker/.devcontainer/library-scripts/common-debian.sh b/containers/docker-from-docker/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/docker-from-docker/.devcontainer/library-scripts/common-debian.sh +++ b/containers/docker-from-docker/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh b/containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/docker-from-docker/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/docker-in-docker/.devcontainer/library-scripts/common-debian.sh b/containers/docker-in-docker/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/docker-in-docker/.devcontainer/library-scripts/common-debian.sh +++ b/containers/docker-in-docker/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/docker-in-docker/.devcontainer/library-scripts/docker-in-docker-debian.sh b/containers/docker-in-docker/.devcontainer/library-scripts/docker-in-docker-debian.sh old mode 100644 new mode 100755 index 74a7935d..8ad2a795 --- a/containers/docker-in-docker/.devcontainer/library-scripts/docker-in-docker-debian.sh +++ b/containers/docker-in-docker/.devcontainer/library-scripts/docker-in-docker-debian.sh @@ -76,7 +76,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 +check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 dirmngr # Swap to legacy iptables for compatibility if type iptables-legacy > /dev/null 2>&1; then @@ -85,6 +85,7 @@ if type iptables-legacy > /dev/null 2>&1; then fi # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then echo "Docker / Moby CLI and Engine already installed." else @@ -94,9 +95,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose moby-engine + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg @@ -112,11 +114,11 @@ echo "Finished installing docker / moby" if type docker-compose > /dev/null 2>&1; then echo "Docker Compose already installed." else - TARGET_COMPOSE_ARCH="$(uname -m)" - if [ "${TARGET_COMPOSE_ARCH}" = "amd64" ]; then - TARGET_COMPOSE_ARCH="x86_64" + target_compose_arch="${architecture}" + if [ "${target_compose_arch}" = "amd64" ]; then + target_compose_arch="x86_64" fi - if [ "${TARGET_COMPOSE_ARCH}" != "x86_64" ]; then + 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 @@ -135,8 +137,8 @@ else ${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose rm -rf /tmp/pip-tmp else - LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") - curl -fsSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-${TARGET_COMPOSE_ARCH}" -o /usr/local/bin/docker-compose + latest_compose_version=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") + curl -fsSL "https://github.com/docker/compose/releases/download/${latest_compose_version}/docker-compose-$(uname -s)-${target_compose_arch}" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose fi fi diff --git a/containers/dotnet-fsharp/.devcontainer/library-scripts/azcli-debian.sh b/containers/dotnet-fsharp/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/dotnet-fsharp/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/dotnet-fsharp/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/dotnet-mssql/.devcontainer/library-scripts/azcli-debian.sh b/containers/dotnet-mssql/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/dotnet-mssql/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/dotnet-mssql/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh b/containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh old mode 100644 new mode 100755 index d0603b2c..7e81ffd9 --- a/containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh +++ b/containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh @@ -58,7 +58,7 @@ export DEBIAN_FRONTEND=noninteractive architecture="$(dpkg --print-architecture)" if [ "${architecture}" = "amd64" ]; then # Install dependencies - check_packages apt-transport-https curl ca-certificates gnupg2 + check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install . /etc/os-release get_common_setting MICROSOFT_GPG_KEYS_URI diff --git a/containers/dotnet/.devcontainer/library-scripts/common-debian.sh b/containers/dotnet/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/dotnet/.devcontainer/library-scripts/common-debian.sh +++ b/containers/dotnet/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/dotnet/.devcontainer/library-scripts/node-debian.sh b/containers/dotnet/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/dotnet/.devcontainer/library-scripts/node-debian.sh +++ b/containers/dotnet/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/go/.devcontainer/library-scripts/common-debian.sh b/containers/go/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/go/.devcontainer/library-scripts/common-debian.sh +++ b/containers/go/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/go/.devcontainer/library-scripts/go-debian.sh b/containers/go/.devcontainer/library-scripts/go-debian.sh old mode 100644 new mode 100755 index d93cc738..47c922d0 --- a/containers/go/.devcontainer/library-scripts/go-debian.sh +++ b/containers/go/.devcontainer/library-scripts/go-debian.sh @@ -48,13 +48,14 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi } - # Figure out correct version of a three part version number is not passed find_version_from_git_tags() { local variable_name=$1 diff --git a/containers/go/.devcontainer/library-scripts/node-debian.sh b/containers/go/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/go/.devcontainer/library-scripts/node-debian.sh +++ b/containers/go/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/haskell/.devcontainer/library-scripts/common-debian.sh b/containers/haskell/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/haskell/.devcontainer/library-scripts/common-debian.sh +++ b/containers/haskell/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/java/.devcontainer/library-scripts/common-debian.sh b/containers/java/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/java/.devcontainer/library-scripts/common-debian.sh +++ b/containers/java/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/java/.devcontainer/library-scripts/gradle-debian.sh b/containers/java/.devcontainer/library-scripts/gradle-debian.sh old mode 100644 new mode 100755 index 493fae6d..6fc8c982 --- a/containers/java/.devcontainer/library-scripts/gradle-debian.sh +++ b/containers/java/.devcontainer/library-scripts/gradle-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/java/.devcontainer/library-scripts/java-debian.sh b/containers/java/.devcontainer/library-scripts/java-debian.sh old mode 100644 new mode 100755 index acd1dc12..47aec3aa --- a/containers/java/.devcontainer/library-scripts/java-debian.sh +++ b/containers/java/.devcontainer/library-scripts/java-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/java/.devcontainer/library-scripts/maven-debian.sh b/containers/java/.devcontainer/library-scripts/maven-debian.sh old mode 100644 new mode 100755 index 7e391ac1..2da1839b --- a/containers/java/.devcontainer/library-scripts/maven-debian.sh +++ b/containers/java/.devcontainer/library-scripts/maven-debian.sh @@ -46,8 +46,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/java/.devcontainer/library-scripts/node-debian.sh b/containers/java/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/java/.devcontainer/library-scripts/node-debian.sh +++ b/containers/java/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh b/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh +++ b/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/javascript-node/.devcontainer/library-scripts/node-debian.sh b/containers/javascript-node/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/javascript-node/.devcontainer/library-scripts/node-debian.sh +++ b/containers/javascript-node/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/jupyter-datascience-notebooks/.devcontainer/library-scripts/common-debian.sh b/containers/jupyter-datascience-notebooks/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/jupyter-datascience-notebooks/.devcontainer/library-scripts/common-debian.sh +++ b/containers/jupyter-datascience-notebooks/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/common-debian.sh b/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/common-debian.sh +++ b/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/docker-in-docker-debian.sh b/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/docker-in-docker-debian.sh old mode 100644 new mode 100755 index 74a7935d..8ad2a795 --- a/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/docker-in-docker-debian.sh +++ b/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/docker-in-docker-debian.sh @@ -76,7 +76,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 +check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 dirmngr # Swap to legacy iptables for compatibility if type iptables-legacy > /dev/null 2>&1; then @@ -85,6 +85,7 @@ if type iptables-legacy > /dev/null 2>&1; then fi # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1 && type dockerd > /dev/null 2>&1; then echo "Docker / Moby CLI and Engine already installed." else @@ -94,9 +95,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose moby-engine + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg @@ -112,11 +114,11 @@ echo "Finished installing docker / moby" if type docker-compose > /dev/null 2>&1; then echo "Docker Compose already installed." else - TARGET_COMPOSE_ARCH="$(uname -m)" - if [ "${TARGET_COMPOSE_ARCH}" = "amd64" ]; then - TARGET_COMPOSE_ARCH="x86_64" + target_compose_arch="${architecture}" + if [ "${target_compose_arch}" = "amd64" ]; then + target_compose_arch="x86_64" fi - if [ "${TARGET_COMPOSE_ARCH}" != "x86_64" ]; then + 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 @@ -135,8 +137,8 @@ else ${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose rm -rf /tmp/pip-tmp else - LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") - curl -fsSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-${TARGET_COMPOSE_ARCH}" -o /usr/local/bin/docker-compose + latest_compose_version=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)") + curl -fsSL "https://github.com/docker/compose/releases/download/${latest_compose_version}/docker-compose-$(uname -s)-${target_compose_arch}" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose fi fi diff --git a/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/kubectl-helm-debian.sh b/containers/kubernetes-helm-minikube/.devcontainer/library-scripts/kubectl-helm-debian.sh old mode 100644 new mode 100755 diff --git a/containers/kubernetes-helm/.devcontainer/library-scripts/common-debian.sh b/containers/kubernetes-helm/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/kubernetes-helm/.devcontainer/library-scripts/common-debian.sh +++ b/containers/kubernetes-helm/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/kubernetes-helm/.devcontainer/library-scripts/docker-debian.sh b/containers/kubernetes-helm/.devcontainer/library-scripts/docker-debian.sh old mode 100644 new mode 100755 index d21d97f6..b3b4aa2d --- a/containers/kubernetes-helm/.devcontainer/library-scripts/docker-debian.sh +++ b/containers/kubernetes-helm/.devcontainer/library-scripts/docker-debian.sh @@ -78,9 +78,10 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates gnupg2 +check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr # Install Docker / Moby CLI if not already installed +architecture="$(dpkg --print-architecture)" if type docker > /dev/null 2>&1; then echo "Docker / Moby CLI already installed." else @@ -90,9 +91,10 @@ else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install get_common_setting MICROSOFT_GPG_KEYS_URI curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list + echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/microsoft-${ID}-${VERSION_CODENAME}-prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft.list apt-get update - apt-get -y install --no-install-recommends moby-cli moby-buildx moby-compose + apt-get -y install --no-install-recommends moby-cli moby-buildx moby-engine + apt-get -y install --no-install-recommends moby-compose || echo "(*) Package moby-compose (Docker Compose v2) not available for ${VERSION_CODENAME} ${architecture}. Skipping." else # Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install curl -fsSL https://download.docker.com/linux/${ID}/gpg | gpg --dearmor > /usr/share/keyrings/docker-archive-keyring.gpg diff --git a/containers/kubernetes-helm/.devcontainer/library-scripts/kubectl-helm-debian.sh b/containers/kubernetes-helm/.devcontainer/library-scripts/kubectl-helm-debian.sh old mode 100644 new mode 100755 diff --git a/containers/mit-scheme/.devcontainer/library-scripts/common-debian.sh b/containers/mit-scheme/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/mit-scheme/.devcontainer/library-scripts/common-debian.sh +++ b/containers/mit-scheme/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/perl/.devcontainer/library-scripts/common-debian.sh b/containers/perl/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/perl/.devcontainer/library-scripts/common-debian.sh +++ b/containers/perl/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/php/.devcontainer/library-scripts/common-debian.sh b/containers/php/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/php/.devcontainer/library-scripts/common-debian.sh +++ b/containers/php/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/php/.devcontainer/library-scripts/node-debian.sh b/containers/php/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/php/.devcontainer/library-scripts/node-debian.sh +++ b/containers/php/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/powershell/.devcontainer/library-scripts/common-debian.sh b/containers/powershell/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/powershell/.devcontainer/library-scripts/common-debian.sh +++ b/containers/powershell/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/python-3-anaconda/.devcontainer/library-scripts/common-debian.sh b/containers/python-3-anaconda/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/python-3-anaconda/.devcontainer/library-scripts/common-debian.sh +++ b/containers/python-3-anaconda/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/python-3-anaconda/.devcontainer/library-scripts/node-debian.sh b/containers/python-3-anaconda/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/python-3-anaconda/.devcontainer/library-scripts/node-debian.sh +++ b/containers/python-3-anaconda/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/python-3-miniconda/.devcontainer/library-scripts/common-debian.sh b/containers/python-3-miniconda/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/python-3-miniconda/.devcontainer/library-scripts/common-debian.sh +++ b/containers/python-3-miniconda/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/python-3-miniconda/.devcontainer/library-scripts/node-debian.sh b/containers/python-3-miniconda/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/python-3-miniconda/.devcontainer/library-scripts/node-debian.sh +++ b/containers/python-3-miniconda/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/python-3-miniconda/.devcontainer/library-scripts/python-debian.sh b/containers/python-3-miniconda/.devcontainer/library-scripts/python-debian.sh old mode 100644 new mode 100755 index 5555a16f..4c470d42 --- a/containers/python-3-miniconda/.devcontainer/library-scripts/python-debian.sh +++ b/containers/python-3-miniconda/.devcontainer/library-scripts/python-debian.sh @@ -7,7 +7,7 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/python.md # Maintainer: The VS Code and Codespaces Teams # -# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools] +# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools flag] [Use Oryx if available flag] [Optimize when building from source flag] PYTHON_VERSION=${1:-"latest"} PYTHON_INSTALL_PATH=${2:-"/usr/local/python"} @@ -15,9 +15,10 @@ export PIPX_HOME=${3:-"/usr/local/py-utils"} USERNAME=${4:-"automatic"} UPDATE_RC=${5:-"true"} INSTALL_PYTHON_TOOLS=${6:-"true"} -USE_PPA_IF_AVAILABLE=${7:-"true"} +USE_ORYX_IF_AVAILABLE=${7:-"true"} +OPTIMIZE_BUILD_FROM_SOURCE=${8-"false"} -DEADSNAKES_PPA_ARCHIVE_GPG_KEY="F23C5A6CF475977595C89F51BA6932366A755776" +DEFAULT_UTILS=("pylint" "flake8" "autopep8" "black" "yapf" "mypy" "pydocstyle" "pycodestyle" "bandit" "pipenv" "virtualenv") PYTHON_SOURCE_GPG_KEYS="64E628F8D684696D B26995E310250568 2D347EA6AA65421D FB9921286F5E1540 3A5CA953F73C700D 04C367C218ADD4FF 0EDDC5F26A45C816 6AF053F07D9DC8D2 C9BE28DEE6DF025C 126EB563A74B06BF D9866941EA5BBD71 ED9D77D5" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org @@ -55,8 +56,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -109,7 +112,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -148,6 +151,44 @@ find_version_from_git_tags() { echo "${variable_name}=${!variable_name}" } +# Use Oryx to install something using a partial version match +oryx_install() { + local platform=$1 + local requested_version=$2 + local target_folder=${3:-none} + local ldconfig_folder=${4:-none} + echo "(*) Installing ${platform} ${requested_version} using Oryx..." + check_packages jq + # Soft match if full version not specified + if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then + local version_list="$(oryx platforms --json | jq -r ".[] | select(.Name == \"${platform}\") | .Versions | sort | reverse | @tsv" | tr '\t' '\n' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$')" + if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then + requested_version="$(echo "${version_list}" | head -n 1)" + else + set +e + requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" + set -e + fi + if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then + echo -e "(!) Oryx does not support ${platform} version $2\nValid values:\n${version_list}" >&2 + return 1 + fi + echo "(*) Using ${requested_version} in place of $2." + fi + + export ORYX_ENV_TYPE=vsonline-present ORYX_PREFER_USER_INSTALLED_SDKS=true ENABLE_DYNAMIC_INSTALL=true DYNAMIC_INSTALL_ROOT_DIR=/opt + oryx prep --skip-detection --platforms-and-versions "${platform}=${requested_version}" + local opt_folder="/opt/${platform}/${requested_version}" + if [ "${target_folder}" != "none" ] && [ "${target_folder}" != "${opt_folder}" ]; then + ln -s "${opt_folder}" "${target_folder}" + fi + # Update library path add to conf + if [ "${ldconfig_folder}" != "none" ]; then + echo "/opt/${platform}/${requested_version}/lib" >> "/etc/ld.so.conf.d/${platform}.conf" + ldconfig + fi +} + # Function to run apt-get if needed apt_get_update_if_needed() { @@ -167,76 +208,71 @@ check_packages() { fi } -install_from_ppa() { - local requested_version="python${PYTHON_VERSION}" - echo "Using PPA to install Python..." - check_packages apt-transport-https curl ca-certificates gnupg2 - receive_gpg_keys DEADSNAKES_PPA_ARCHIVE_GPG_KEY /usr/share/keyrings/deadsnakes-archive-keyring.gpg - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main\ndeb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/deadsnakes-ppa.list - apt-get update - if [ "${PYTHON_VERSION}" = "latest" ] || [ "${PYTHON_VERSION}" = "current" ] || [ "${PYTHON_VERSION}" = "lts" ]; then - requested_version="$(apt-cache search '^python3\.[0-9]$' | grep -oE '^python3\.[0-9]' | sort -rV | head -n 1)" - echo "Using ${requested_version} in place of ${PYTHON_VERSION}." - fi - apt-get -y install ${requested_version} - rm -rf /tmp/tmp-gnupg - exit 0 -} - install_from_source() { if [ -d "${PYTHON_INSTALL_PATH}" ]; then - echo "Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." exit 1 - else - echo "Building Python ${PYTHON_VERSION} from source..." - # Install prereqs if missing - check_packages curl ca-certificates tar make build-essential libssl-dev zlib1g-dev \ - wget libbz2-dev libreadline-dev libxml2-dev xz-utils tk-dev gnupg2 \ - libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev llvm dirmngr - if ! type git > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends git - fi - - # Find version using soft match - find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" - - # Download tgz of source - mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" - cd /tmp/python-src - TGZ_FILENAME="Python-${PYTHON_VERSION}.tgz" - TGZ_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${TGZ_FILENAME}" - echo "Downloading ${TGZ_FILENAME}..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}" "${TGZ_URL}" - - # Verify signature - if [ "${SKIP_SIGNATURE_CHECK}" != "true" ]; then - receive_gpg_keys PYTHON_SOURCE_GPG_KEYS - echo "Downloading ${TGZ_FILENAME}.asc..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}.asc" "${TGZ_URL}.asc" - gpg --verify "${TGZ_FILENAME}.asc" - fi - - # Update min protocol for testing only - https://bugs.python.org/issue41561 - cp /etc/ssl/openssl.cnf /tmp/python-src/ - sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf - export OPENSSL_CONF=/tmp/python-src/openssl.cnf - - # Untar and build - tar -xzf "/tmp/python-src/${TGZ_FILENAME}" -C "/tmp/python-src" --strip-components=1 - ./configure --prefix="${PYTHON_INSTALL_PATH}" --enable-optimizations --with-ensurepip=install - make -j 8 - make install - cd /tmp - rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env - chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" - ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python - ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip - ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle - ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc - ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config - updaterc "export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}" fi + echo "(*) Building Python ${PYTHON_VERSION} from source..." + # Install prereqs if missing + check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \ + 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 -y install --no-install-recommends git + fi + + # Find version using soft match + find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" + + # Download tgz of source + mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" + cd /tmp/python-src + local tgz_filename="Python-${PYTHON_VERSION}.tgz" + local tgz_url="https://www.python.org/ftp/python/${PYTHON_VERSION}/${tgz_filename}" + echo "Downloading ${tgz_filename}..." + curl -sSL -o "/tmp/python-src/${tgz_filename}" "${tgz_url}" + + # Verify signature + receive_gpg_keys PYTHON_SOURCE_GPG_KEYS + echo "Downloading ${tgz_filename}.asc..." + curl -sSL -o "/tmp/python-src/${tgz_filename}.asc" "${tgz_url}.asc" + gpg --verify "${tgz_filename}.asc" + + # Update min protocol for testing only - https://bugs.python.org/issue41561 + cp /etc/ssl/openssl.cnf /tmp/python-src/ + sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf + export OPENSSL_CONF=/tmp/python-src/openssl.cnf + + # Untar and build + tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1 + local config_args="" + if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then + config_args="--enable-optimizations" + fi + ./configure --prefix="${PYTHON_INSTALL_PATH}" --with-ensurepip=install ${config_args} + make -j 8 + make install + cd /tmp + rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env + chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" + ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python + ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config +} + +install_using_oryx() { + if [ -d "${PYTHON_INSTALL_PATH}" ]; then + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + exit 1 + fi + oryx_install "python" "${PYTHON_VERSION}" "${PYTHON_INSTALL_PATH}" "lib" || return 1 + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config } # Ensure apt is in non-interactive to avoid prompts @@ -244,41 +280,25 @@ export DEBIAN_FRONTEND=noninteractive # Install python from source if needed if [ "${PYTHON_VERSION}" != "none" ]; then - # Source /etc/os-release to get OS info - . /etc/os-release - # If ubuntu, PPAs allowed - install from there - if [ "${ID}" = "ubuntu" ] && [ "${USE_PPA_IF_AVAILABLE}" = "true" ]; then - install_from_ppa + if [ "$(dpkg --print-architecture)" = "amd64" ] && [ "${USE_ORYX_IF_AVAILABLE}" = "true" ] && type oryx > /dev/null 2>&1; then + install_using_oryx || should_install_from_source=true else + should_install_from_source=true + fi + if [ "${should_install_from_source}" = "true" ]; then install_from_source fi + updaterc "if [[ \"\${PATH}\" != *\"${PYTHON_INSTALL_PATH}/bin\"* ]]; then export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}; fi" fi # If not installing python tools, exit if [ "${INSTALL_PYTHON_TOOLS}" != "true" ]; then echo "Done!" - exit 0; + exit 0 fi -DEFAULT_UTILS="\ - pylint \ - flake8 \ - autopep8 \ - black \ - yapf \ - mypy \ - pydocstyle \ - pycodestyle \ - bandit \ - pipenv \ - virtualenv" - -export PIPX_BIN_DIR=${PIPX_HOME}/bin -export PATH=${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH} - -# Update pip -echo "Updating pip..." -python3 -m pip install --no-cache-dir --upgrade pip +export PIPX_BIN_DIR="${PIPX_HOME}/bin" +export PATH="${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH}" # Create pipx group, dir, and set sticky bit if ! cat /etc/group | grep -e "^pipx:" > /dev/null 2>&1; then @@ -290,13 +310,27 @@ mkdir -p ${PIPX_BIN_DIR} chown :pipx ${PIPX_HOME} ${PIPX_BIN_DIR} chmod g+s ${PIPX_HOME} ${PIPX_BIN_DIR} +# Update pip +echo "Updating pip..." +${PYTHON_INSTALL_PATH}/bin/python3 -m pip install --no-cache-dir --upgrade pip + # Install tools echo "Installing Python tools..." export PYTHONUSERBASE=/tmp/pip-tmp export PIP_CACHE_DIR=/tmp/pip-tmp/cache -pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx -/tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx -echo "${DEFAULT_UTILS}" | xargs -n 1 /tmp/pip-tmp/bin/pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' +pipx_path="" +if ! type pipx > /dev/null 2>&1; then + pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx + /tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx + pipx_path="/tmp/pip-tmp/bin/" +fi +for util in ${DEFAULT_UTILS[@]}; do + if ! type ${util} > /dev/null 2>&1; then + ${pipx_path}pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' ${util} + else + echo "${util} already installed. Skipping." + fi +done rm -rf /tmp/pip-tmp updaterc "$(cat << EOF diff --git a/containers/python-3-pypy/.devcontainer/library-scripts/common-debian.sh b/containers/python-3-pypy/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/python-3-pypy/.devcontainer/library-scripts/common-debian.sh +++ b/containers/python-3-pypy/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/python-3/.devcontainer/library-scripts/common-debian.sh b/containers/python-3/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/python-3/.devcontainer/library-scripts/common-debian.sh +++ b/containers/python-3/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/python-3/.devcontainer/library-scripts/node-debian.sh b/containers/python-3/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/python-3/.devcontainer/library-scripts/node-debian.sh +++ b/containers/python-3/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/python-3/.devcontainer/library-scripts/python-debian.sh b/containers/python-3/.devcontainer/library-scripts/python-debian.sh old mode 100644 new mode 100755 index 5555a16f..4c470d42 --- a/containers/python-3/.devcontainer/library-scripts/python-debian.sh +++ b/containers/python-3/.devcontainer/library-scripts/python-debian.sh @@ -7,7 +7,7 @@ # Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/python.md # Maintainer: The VS Code and Codespaces Teams # -# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools] +# Syntax: ./python-debian.sh [Python Version] [Python intall path] [PIPX_HOME] [non-root user] [Update rc files flag] [install tools flag] [Use Oryx if available flag] [Optimize when building from source flag] PYTHON_VERSION=${1:-"latest"} PYTHON_INSTALL_PATH=${2:-"/usr/local/python"} @@ -15,9 +15,10 @@ export PIPX_HOME=${3:-"/usr/local/py-utils"} USERNAME=${4:-"automatic"} UPDATE_RC=${5:-"true"} INSTALL_PYTHON_TOOLS=${6:-"true"} -USE_PPA_IF_AVAILABLE=${7:-"true"} +USE_ORYX_IF_AVAILABLE=${7:-"true"} +OPTIMIZE_BUILD_FROM_SOURCE=${8-"false"} -DEADSNAKES_PPA_ARCHIVE_GPG_KEY="F23C5A6CF475977595C89F51BA6932366A755776" +DEFAULT_UTILS=("pylint" "flake8" "autopep8" "black" "yapf" "mypy" "pydocstyle" "pycodestyle" "bandit" "pipenv" "virtualenv") PYTHON_SOURCE_GPG_KEYS="64E628F8D684696D B26995E310250568 2D347EA6AA65421D FB9921286F5E1540 3A5CA953F73C700D 04C367C218ADD4FF 0EDDC5F26A45C816 6AF053F07D9DC8D2 C9BE28DEE6DF025C 126EB563A74B06BF D9866941EA5BBD71 ED9D77D5" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80 keyserver hkps://keys.openpgp.org @@ -55,8 +56,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -109,7 +112,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } @@ -148,6 +151,44 @@ find_version_from_git_tags() { echo "${variable_name}=${!variable_name}" } +# Use Oryx to install something using a partial version match +oryx_install() { + local platform=$1 + local requested_version=$2 + local target_folder=${3:-none} + local ldconfig_folder=${4:-none} + echo "(*) Installing ${platform} ${requested_version} using Oryx..." + check_packages jq + # Soft match if full version not specified + if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then + local version_list="$(oryx platforms --json | jq -r ".[] | select(.Name == \"${platform}\") | .Versions | sort | reverse | @tsv" | tr '\t' '\n' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$')" + if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then + requested_version="$(echo "${version_list}" | head -n 1)" + else + set +e + requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" + set -e + fi + if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then + echo -e "(!) Oryx does not support ${platform} version $2\nValid values:\n${version_list}" >&2 + return 1 + fi + echo "(*) Using ${requested_version} in place of $2." + fi + + export ORYX_ENV_TYPE=vsonline-present ORYX_PREFER_USER_INSTALLED_SDKS=true ENABLE_DYNAMIC_INSTALL=true DYNAMIC_INSTALL_ROOT_DIR=/opt + oryx prep --skip-detection --platforms-and-versions "${platform}=${requested_version}" + local opt_folder="/opt/${platform}/${requested_version}" + if [ "${target_folder}" != "none" ] && [ "${target_folder}" != "${opt_folder}" ]; then + ln -s "${opt_folder}" "${target_folder}" + fi + # Update library path add to conf + if [ "${ldconfig_folder}" != "none" ]; then + echo "/opt/${platform}/${requested_version}/lib" >> "/etc/ld.so.conf.d/${platform}.conf" + ldconfig + fi +} + # Function to run apt-get if needed apt_get_update_if_needed() { @@ -167,76 +208,71 @@ check_packages() { fi } -install_from_ppa() { - local requested_version="python${PYTHON_VERSION}" - echo "Using PPA to install Python..." - check_packages apt-transport-https curl ca-certificates gnupg2 - receive_gpg_keys DEADSNAKES_PPA_ARCHIVE_GPG_KEY /usr/share/keyrings/deadsnakes-archive-keyring.gpg - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main\ndeb-src [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deadsnakes-archive-keyring.gpg] http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/deadsnakes-ppa.list - apt-get update - if [ "${PYTHON_VERSION}" = "latest" ] || [ "${PYTHON_VERSION}" = "current" ] || [ "${PYTHON_VERSION}" = "lts" ]; then - requested_version="$(apt-cache search '^python3\.[0-9]$' | grep -oE '^python3\.[0-9]' | sort -rV | head -n 1)" - echo "Using ${requested_version} in place of ${PYTHON_VERSION}." - fi - apt-get -y install ${requested_version} - rm -rf /tmp/tmp-gnupg - exit 0 -} - install_from_source() { if [ -d "${PYTHON_INSTALL_PATH}" ]; then - echo "Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." exit 1 - else - echo "Building Python ${PYTHON_VERSION} from source..." - # Install prereqs if missing - check_packages curl ca-certificates tar make build-essential libssl-dev zlib1g-dev \ - wget libbz2-dev libreadline-dev libxml2-dev xz-utils tk-dev gnupg2 \ - libxmlsec1-dev libsqlite3-dev libffi-dev liblzma-dev llvm dirmngr - if ! type git > /dev/null 2>&1; then - apt_get_update_if_needed - apt-get -y install --no-install-recommends git - fi - - # Find version using soft match - find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" - - # Download tgz of source - mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" - cd /tmp/python-src - TGZ_FILENAME="Python-${PYTHON_VERSION}.tgz" - TGZ_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${TGZ_FILENAME}" - echo "Downloading ${TGZ_FILENAME}..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}" "${TGZ_URL}" - - # Verify signature - if [ "${SKIP_SIGNATURE_CHECK}" != "true" ]; then - receive_gpg_keys PYTHON_SOURCE_GPG_KEYS - echo "Downloading ${TGZ_FILENAME}.asc..." - curl -sSL -o "/tmp/python-src/${TGZ_FILENAME}.asc" "${TGZ_URL}.asc" - gpg --verify "${TGZ_FILENAME}.asc" - fi - - # Update min protocol for testing only - https://bugs.python.org/issue41561 - cp /etc/ssl/openssl.cnf /tmp/python-src/ - sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf - export OPENSSL_CONF=/tmp/python-src/openssl.cnf - - # Untar and build - tar -xzf "/tmp/python-src/${TGZ_FILENAME}" -C "/tmp/python-src" --strip-components=1 - ./configure --prefix="${PYTHON_INSTALL_PATH}" --enable-optimizations --with-ensurepip=install - make -j 8 - make install - cd /tmp - rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env - chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" - ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python - ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip - ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle - ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc - ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config - updaterc "export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}" fi + echo "(*) Building Python ${PYTHON_VERSION} from source..." + # Install prereqs if missing + check_packages curl ca-certificates gnupg2 tar make gcc libssl-dev zlib1g-dev libncurses5-dev \ + 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 -y install --no-install-recommends git + fi + + # Find version using soft match + find_version_from_git_tags PYTHON_VERSION "https://github.com/python/cpython" + + # Download tgz of source + mkdir -p /tmp/python-src "${PYTHON_INSTALL_PATH}" + cd /tmp/python-src + local tgz_filename="Python-${PYTHON_VERSION}.tgz" + local tgz_url="https://www.python.org/ftp/python/${PYTHON_VERSION}/${tgz_filename}" + echo "Downloading ${tgz_filename}..." + curl -sSL -o "/tmp/python-src/${tgz_filename}" "${tgz_url}" + + # Verify signature + receive_gpg_keys PYTHON_SOURCE_GPG_KEYS + echo "Downloading ${tgz_filename}.asc..." + curl -sSL -o "/tmp/python-src/${tgz_filename}.asc" "${tgz_url}.asc" + gpg --verify "${tgz_filename}.asc" + + # Update min protocol for testing only - https://bugs.python.org/issue41561 + cp /etc/ssl/openssl.cnf /tmp/python-src/ + sed -i -E 's/MinProtocol[=\ ]+.*/MinProtocol = TLSv1.0/g' /tmp/python-src/openssl.cnf + export OPENSSL_CONF=/tmp/python-src/openssl.cnf + + # Untar and build + tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1 + local config_args="" + if [ "${OPTIMIZE_BUILD_FROM_SOURCE}" = "true" ]; then + config_args="--enable-optimizations" + fi + ./configure --prefix="${PYTHON_INSTALL_PATH}" --with-ensurepip=install ${config_args} + make -j 8 + make install + cd /tmp + rm -rf /tmp/python-src ${GNUPGHOME} /tmp/vscdc-settings.env + chown -R ${USERNAME} "${PYTHON_INSTALL_PATH}" + ln -s ${PYTHON_INSTALL_PATH}/bin/python3 ${PYTHON_INSTALL_PATH}/bin/python + ln -s ${PYTHON_INSTALL_PATH}/bin/pip3 ${PYTHON_INSTALL_PATH}/bin/pip + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config +} + +install_using_oryx() { + if [ -d "${PYTHON_INSTALL_PATH}" ]; then + echo "(!) Path ${PYTHON_INSTALL_PATH} already exists. Remove this existing path or select a different one." + exit 1 + fi + oryx_install "python" "${PYTHON_VERSION}" "${PYTHON_INSTALL_PATH}" "lib" || return 1 + ln -s ${PYTHON_INSTALL_PATH}/bin/idle3 ${PYTHON_INSTALL_PATH}/bin/idle + ln -s ${PYTHON_INSTALL_PATH}/bin/pydoc3 ${PYTHON_INSTALL_PATH}/bin/pydoc + ln -s ${PYTHON_INSTALL_PATH}/bin/python3-config ${PYTHON_INSTALL_PATH}/bin/python-config } # Ensure apt is in non-interactive to avoid prompts @@ -244,41 +280,25 @@ export DEBIAN_FRONTEND=noninteractive # Install python from source if needed if [ "${PYTHON_VERSION}" != "none" ]; then - # Source /etc/os-release to get OS info - . /etc/os-release - # If ubuntu, PPAs allowed - install from there - if [ "${ID}" = "ubuntu" ] && [ "${USE_PPA_IF_AVAILABLE}" = "true" ]; then - install_from_ppa + if [ "$(dpkg --print-architecture)" = "amd64" ] && [ "${USE_ORYX_IF_AVAILABLE}" = "true" ] && type oryx > /dev/null 2>&1; then + install_using_oryx || should_install_from_source=true else + should_install_from_source=true + fi + if [ "${should_install_from_source}" = "true" ]; then install_from_source fi + updaterc "if [[ \"\${PATH}\" != *\"${PYTHON_INSTALL_PATH}/bin\"* ]]; then export PATH=${PYTHON_INSTALL_PATH}/bin:\${PATH}; fi" fi # If not installing python tools, exit if [ "${INSTALL_PYTHON_TOOLS}" != "true" ]; then echo "Done!" - exit 0; + exit 0 fi -DEFAULT_UTILS="\ - pylint \ - flake8 \ - autopep8 \ - black \ - yapf \ - mypy \ - pydocstyle \ - pycodestyle \ - bandit \ - pipenv \ - virtualenv" - -export PIPX_BIN_DIR=${PIPX_HOME}/bin -export PATH=${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH} - -# Update pip -echo "Updating pip..." -python3 -m pip install --no-cache-dir --upgrade pip +export PIPX_BIN_DIR="${PIPX_HOME}/bin" +export PATH="${PYTHON_INSTALL_PATH}/bin:${PIPX_BIN_DIR}:${PATH}" # Create pipx group, dir, and set sticky bit if ! cat /etc/group | grep -e "^pipx:" > /dev/null 2>&1; then @@ -290,13 +310,27 @@ mkdir -p ${PIPX_BIN_DIR} chown :pipx ${PIPX_HOME} ${PIPX_BIN_DIR} chmod g+s ${PIPX_HOME} ${PIPX_BIN_DIR} +# Update pip +echo "Updating pip..." +${PYTHON_INSTALL_PATH}/bin/python3 -m pip install --no-cache-dir --upgrade pip + # Install tools echo "Installing Python tools..." export PYTHONUSERBASE=/tmp/pip-tmp export PIP_CACHE_DIR=/tmp/pip-tmp/cache -pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx -/tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx -echo "${DEFAULT_UTILS}" | xargs -n 1 /tmp/pip-tmp/bin/pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' +pipx_path="" +if ! type pipx > /dev/null 2>&1; then + pip3 install --disable-pip-version-check --no-warn-script-location --no-cache-dir --user pipx + /tmp/pip-tmp/bin/pipx install --pip-args=--no-cache-dir pipx + pipx_path="/tmp/pip-tmp/bin/" +fi +for util in ${DEFAULT_UTILS[@]}; do + if ! type ${util} > /dev/null 2>&1; then + ${pipx_path}pipx install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' ${util} + else + echo "${util} already installed. Skipping." + fi +done rm -rf /tmp/pip-tmp updaterc "$(cat << EOF diff --git a/containers/r/.devcontainer/library-scripts/common-debian.sh b/containers/r/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/r/.devcontainer/library-scripts/common-debian.sh +++ b/containers/r/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/ruby/.devcontainer/library-scripts/common-debian.sh b/containers/ruby/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/ruby/.devcontainer/library-scripts/common-debian.sh +++ b/containers/ruby/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/ruby/.devcontainer/library-scripts/node-debian.sh b/containers/ruby/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/ruby/.devcontainer/library-scripts/node-debian.sh +++ b/containers/ruby/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh b/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh old mode 100644 new mode 100755 index 17ce709e..c4c101ae --- a/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh +++ b/containers/ruby/.devcontainer/library-scripts/ruby-debian.sh @@ -52,8 +52,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -105,7 +107,7 @@ receive_gpg_keys() { done set -e if [ "${gpg_ok}" = "false" ]; then - echo "(!) Failed to install rvm." + echo "(!) Failed to get gpg key." exit 1 fi } diff --git a/containers/rust/.devcontainer/library-scripts/common-debian.sh b/containers/rust/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/rust/.devcontainer/library-scripts/common-debian.sh +++ b/containers/rust/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/rust/.devcontainer/library-scripts/rust-debian.sh b/containers/rust/.devcontainer/library-scripts/rust-debian.sh old mode 100644 new mode 100755 index 78a097e5..0f10a385 --- a/containers/rust/.devcontainer/library-scripts/rust-debian.sh +++ b/containers/rust/.devcontainer/library-scripts/rust-debian.sh @@ -47,8 +47,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi diff --git a/containers/swift/.devcontainer/library-scripts/common-debian.sh b/containers/swift/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/swift/.devcontainer/library-scripts/common-debian.sh +++ b/containers/swift/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/containers/swift/.devcontainer/library-scripts/node-debian.sh b/containers/swift/.devcontainer/library-scripts/node-debian.sh old mode 100644 new mode 100755 index d1d7bc5c..44c2a05c --- a/containers/swift/.devcontainer/library-scripts/node-debian.sh +++ b/containers/swift/.devcontainer/library-scripts/node-debian.sh @@ -48,8 +48,10 @@ fi updaterc() { if [ "${UPDATE_RC}" = "true" ]; then echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - echo -e "$1" >> /etc/bash.bashrc - if [ -f "/etc/zsh/zshrc" ]; then + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then echo -e "$1" >> /etc/zsh/zshrc fi fi @@ -78,7 +80,7 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive # Install dependencies -check_packages apt-transport-https curl ca-certificates tar gnupg2 +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr # Install yarn if type yarn > /dev/null 2>&1; then diff --git a/containers/ubuntu/.devcontainer/library-scripts/common-debian.sh b/containers/ubuntu/.devcontainer/library-scripts/common-debian.sh old mode 100644 new mode 100755 index dfbe6f6a..f268e51a --- a/containers/ubuntu/.devcontainer/library-scripts/common-debian.sh +++ b/containers/ubuntu/.devcontainer/library-scripts/common-debian.sh @@ -78,6 +78,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then package_list="apt-utils \ openssh-client \ gnupg2 \ + dirmngr \ iproute2 \ procps \ lsof \ diff --git a/repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh b/repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh old mode 100644 new mode 100755 index 0cccbc9c..31036fbb --- a/repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh +++ b/repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh @@ -14,7 +14,7 @@ VNC_PASSWORD=${2:-"vscode"} INSTALL_NOVNC=${3:-"true"} NOVNC_VERSION=1.2.0 -WEBSOCKETIFY_VERSION=0.9.0 +WEBSOCKETIFY_VERSION=0.10.0 package_list=" tigervnc-standalone-server \