Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 5117676

Browse files
author
CI
committed
Automated update of common script sources and hash
1 parent 063e398 commit 5117676

File tree

22 files changed

+485
-37
lines changed

22 files changed

+485
-37
lines changed

containers/azure-ansible/.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_using_apt() {
6363
get_common_setting MICROSOFT_GPG_KEYS_URI
6464
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
6565
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
66-
if ! apt-get update && apt-get install -yq azure-cli; then
66+
if ! (apt-get update && apt-get install -yq azure-cli); then
6767
-f /etc/apt/sources.list.d/azure-cli.list
6868
return 1
6969
fi

containers/azure-ansible/.devcontainer/library-scripts/docker-debian.sh

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TARGET_SOCKET=${3:-"/var/run/docker.sock"}
1515
USERNAME=${4:-"automatic"}
1616
USE_MOBY=${5:-"true"}
1717
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
18+
DOCKER_DASH_COMPOSE_VERSION="1"
1819

1920
set -e
2021

@@ -74,11 +75,49 @@ check_packages() {
7475
fi
7576
}
7677

78+
# Figure out correct version of a three part version number is not passed
79+
find_version_from_git_tags() {
80+
local variable_name=$1
81+
local requested_version=${!variable_name}
82+
if [ "${requested_version}" = "none" ]; then return; fi
83+
local repository=$2
84+
local prefix=${3:-"tags/v"}
85+
local separator=${4:-"."}
86+
local last_part_optional=${5:-"false"}
87+
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
88+
local escaped_separator=${separator//./\\.}
89+
local last_part
90+
if [ "${last_part_optional}" = "true" ]; then
91+
last_part="(${escaped_separator}[0-9]+)?"
92+
else
93+
last_part="${escaped_separator}[0-9]+"
94+
fi
95+
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
96+
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
97+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
98+
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
99+
else
100+
set +e
101+
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
102+
set -e
103+
fi
104+
fi
105+
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
106+
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
107+
exit 1
108+
fi
109+
echo "${variable_name}=${!variable_name}"
110+
}
111+
77112
# Ensure apt is in non-interactive to avoid prompts
78113
export DEBIAN_FRONTEND=noninteractive
79114

80115
# Install dependencies
81116
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
117+
if ! type git > /dev/null 2>&1; then
118+
apt_get_update_if_needed
119+
apt-get -y install git
120+
fi
82121

83122
# Install Docker / Moby CLI if not already installed
84123
architecture="$(dpkg --print-architecture)"
@@ -131,8 +170,9 @@ else
131170
${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose
132171
rm -rf /tmp/pip-tmp
133172
else
134-
LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)")
135-
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
173+
find_version_from_git_tags DOCKER_DASH_COMPOSE_VERSION "https://github.com/docker/compose" "tags/"
174+
echo "(*) Installing docker-compose ${DOCKER_DASH_COMPOSE_VERSION}..."
175+
curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_DASH_COMPOSE_VERSION}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
136176
chmod +x /usr/local/bin/docker-compose
137177
fi
138178
fi
@@ -141,6 +181,7 @@ fi
141181
if [ -f "/usr/local/share/docker-init.sh" ]; then
142182
exit 0
143183
fi
184+
echo "docker-init doesnt exist, adding..."
144185

145186
# By default, make the source and target sockets the same
146187
if [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ]; then

containers/azure-bicep/.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_using_apt() {
6363
get_common_setting MICROSOFT_GPG_KEYS_URI
6464
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
6565
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
66-
if ! apt-get update && apt-get install -yq azure-cli; then
66+
if ! (apt-get update && apt-get install -yq azure-cli); then
6767
-f /etc/apt/sources.list.d/azure-cli.list
6868
return 1
6969
fi

containers/azure-cli/.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_using_apt() {
6363
get_common_setting MICROSOFT_GPG_KEYS_URI
6464
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
6565
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
66-
if ! apt-get update && apt-get install -yq azure-cli; then
66+
if ! (apt-get update && apt-get install -yq azure-cli); then
6767
-f /etc/apt/sources.list.d/azure-cli.list
6868
return 1
6969
fi

containers/azure-terraform/.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_using_apt() {
6363
get_common_setting MICROSOFT_GPG_KEYS_URI
6464
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
6565
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
66-
if ! apt-get update && apt-get install -yq azure-cli; then
66+
if ! (apt-get update && apt-get install -yq azure-cli); then
6767
-f /etc/apt/sources.list.d/azure-cli.list
6868
return 1
6969
fi

containers/azure-terraform/.devcontainer/library-scripts/docker-debian.sh

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TARGET_SOCKET=${3:-"/var/run/docker.sock"}
1515
USERNAME=${4:-"automatic"}
1616
USE_MOBY=${5:-"true"}
1717
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
18+
DOCKER_DASH_COMPOSE_VERSION="1"
1819

1920
set -e
2021

@@ -74,11 +75,49 @@ check_packages() {
7475
fi
7576
}
7677

78+
# Figure out correct version of a three part version number is not passed
79+
find_version_from_git_tags() {
80+
local variable_name=$1
81+
local requested_version=${!variable_name}
82+
if [ "${requested_version}" = "none" ]; then return; fi
83+
local repository=$2
84+
local prefix=${3:-"tags/v"}
85+
local separator=${4:-"."}
86+
local last_part_optional=${5:-"false"}
87+
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
88+
local escaped_separator=${separator//./\\.}
89+
local last_part
90+
if [ "${last_part_optional}" = "true" ]; then
91+
last_part="(${escaped_separator}[0-9]+)?"
92+
else
93+
last_part="${escaped_separator}[0-9]+"
94+
fi
95+
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
96+
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
97+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
98+
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
99+
else
100+
set +e
101+
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
102+
set -e
103+
fi
104+
fi
105+
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
106+
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
107+
exit 1
108+
fi
109+
echo "${variable_name}=${!variable_name}"
110+
}
111+
77112
# Ensure apt is in non-interactive to avoid prompts
78113
export DEBIAN_FRONTEND=noninteractive
79114

80115
# Install dependencies
81116
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
117+
if ! type git > /dev/null 2>&1; then
118+
apt_get_update_if_needed
119+
apt-get -y install git
120+
fi
82121

83122
# Install Docker / Moby CLI if not already installed
84123
architecture="$(dpkg --print-architecture)"
@@ -131,8 +170,9 @@ else
131170
${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose
132171
rm -rf /tmp/pip-tmp
133172
else
134-
LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)")
135-
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
173+
find_version_from_git_tags DOCKER_DASH_COMPOSE_VERSION "https://github.com/docker/compose" "tags/"
174+
echo "(*) Installing docker-compose ${DOCKER_DASH_COMPOSE_VERSION}..."
175+
curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_DASH_COMPOSE_VERSION}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
136176
chmod +x /usr/local/bin/docker-compose
137177
fi
138178
fi
@@ -141,6 +181,7 @@ fi
141181
if [ -f "/usr/local/share/docker-init.sh" ]; then
142182
exit 0
143183
fi
184+
echo "docker-init doesnt exist, adding..."
144185

145186
# By default, make the source and target sockets the same
146187
if [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ]; then

containers/codespaces-linux/.devcontainer/library-scripts/azcli-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_using_apt() {
6363
get_common_setting MICROSOFT_GPG_KEYS_URI
6464
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
6565
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
66-
if ! apt-get update && apt-get install -yq azure-cli; then
66+
if ! (apt-get update && apt-get install -yq azure-cli); then
6767
-f /etc/apt/sources.list.d/azure-cli.list
6868
return 1
6969
fi

containers/codespaces-linux/.devcontainer/library-scripts/docker-debian.sh

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TARGET_SOCKET=${3:-"/var/run/docker.sock"}
1515
USERNAME=${4:-"automatic"}
1616
USE_MOBY=${5:-"true"}
1717
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
18+
DOCKER_DASH_COMPOSE_VERSION="1"
1819

1920
set -e
2021

@@ -74,11 +75,49 @@ check_packages() {
7475
fi
7576
}
7677

78+
# Figure out correct version of a three part version number is not passed
79+
find_version_from_git_tags() {
80+
local variable_name=$1
81+
local requested_version=${!variable_name}
82+
if [ "${requested_version}" = "none" ]; then return; fi
83+
local repository=$2
84+
local prefix=${3:-"tags/v"}
85+
local separator=${4:-"."}
86+
local last_part_optional=${5:-"false"}
87+
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
88+
local escaped_separator=${separator//./\\.}
89+
local last_part
90+
if [ "${last_part_optional}" = "true" ]; then
91+
last_part="(${escaped_separator}[0-9]+)?"
92+
else
93+
last_part="${escaped_separator}[0-9]+"
94+
fi
95+
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
96+
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
97+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
98+
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
99+
else
100+
set +e
101+
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
102+
set -e
103+
fi
104+
fi
105+
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
106+
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
107+
exit 1
108+
fi
109+
echo "${variable_name}=${!variable_name}"
110+
}
111+
77112
# Ensure apt is in non-interactive to avoid prompts
78113
export DEBIAN_FRONTEND=noninteractive
79114

80115
# Install dependencies
81116
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
117+
if ! type git > /dev/null 2>&1; then
118+
apt_get_update_if_needed
119+
apt-get -y install git
120+
fi
82121

83122
# Install Docker / Moby CLI if not already installed
84123
architecture="$(dpkg --print-architecture)"
@@ -131,8 +170,9 @@ else
131170
${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose
132171
rm -rf /tmp/pip-tmp
133172
else
134-
LATEST_COMPOSE_VERSION=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)")
135-
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
173+
find_version_from_git_tags DOCKER_DASH_COMPOSE_VERSION "https://github.com/docker/compose" "tags/"
174+
echo "(*) Installing docker-compose ${DOCKER_DASH_COMPOSE_VERSION}..."
175+
curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_DASH_COMPOSE_VERSION}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
136176
chmod +x /usr/local/bin/docker-compose
137177
fi
138178
fi
@@ -141,6 +181,7 @@ fi
141181
if [ -f "/usr/local/share/docker-init.sh" ]; then
142182
exit 0
143183
fi
184+
echo "docker-init doesnt exist, adding..."
144185

145186
# By default, make the source and target sockets the same
146187
if [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ]; then

containers/codespaces-linux/.devcontainer/library-scripts/docker-in-docker-debian.sh

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ENABLE_NONROOT_DOCKER=${1:-"true"}
1313
USERNAME=${2:-"automatic"}
1414
USE_MOBY=${3:-"true"}
1515
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
16+
DOCKER_DASH_COMPOSE_VERSION="1"
1617

1718
set -e
1819

@@ -72,11 +73,49 @@ check_packages() {
7273
fi
7374
}
7475

76+
# Figure out correct version of a three part version number is not passed
77+
find_version_from_git_tags() {
78+
local variable_name=$1
79+
local requested_version=${!variable_name}
80+
if [ "${requested_version}" = "none" ]; then return; fi
81+
local repository=$2
82+
local prefix=${3:-"tags/v"}
83+
local separator=${4:-"."}
84+
local last_part_optional=${5:-"false"}
85+
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
86+
local escaped_separator=${separator//./\\.}
87+
local last_part
88+
if [ "${last_part_optional}" = "true" ]; then
89+
last_part="(${escaped_separator}[0-9]+)?"
90+
else
91+
last_part="${escaped_separator}[0-9]+"
92+
fi
93+
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
94+
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
95+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
96+
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
97+
else
98+
set +e
99+
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
100+
set -e
101+
fi
102+
fi
103+
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
104+
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
105+
exit 1
106+
fi
107+
echo "${variable_name}=${!variable_name}"
108+
}
109+
75110
# Ensure apt is in non-interactive to avoid prompts
76111
export DEBIAN_FRONTEND=noninteractive
77112

78113
# Install dependencies
79114
check_packages apt-transport-https curl ca-certificates lxc pigz iptables gnupg2 dirmngr
115+
if ! type git > /dev/null 2>&1; then
116+
apt_get_update_if_needed
117+
apt-get -y install git
118+
fi
80119

81120
# Swap to legacy iptables for compatibility
82121
if type iptables-legacy > /dev/null 2>&1; then
@@ -137,8 +176,9 @@ else
137176
${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' docker-compose
138177
rm -rf /tmp/pip-tmp
139178
else
140-
latest_compose_version=$(basename "$(curl -fsSL -o /dev/null -w "%{url_effective}" https://github.com/docker/compose/releases/latest)")
141-
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
179+
find_version_from_git_tags DOCKER_DASH_COMPOSE_VERSION "https://github.com/docker/compose" "tags/"
180+
echo "(*) Installing docker-compose ${DOCKER_DASH_COMPOSE_VERSION}..."
181+
curl -fsSL "https://github.com/docker/compose/releases/download/${DOCKER_DASH_COMPOSE_VERSION}/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose
142182
chmod +x /usr/local/bin/docker-compose
143183
fi
144184
fi
@@ -148,7 +188,7 @@ if [ -f "/usr/local/share/docker-init.sh" ]; then
148188
echo "/usr/local/share/docker-init.sh already exists, so exiting."
149189
exit 0
150190
fi
151-
echo "docker-init doesnt exist..."
191+
echo "docker-init doesnt exist, adding..."
152192

153193
# Add user to the docker group
154194
if [ "${ENABLE_NONROOT_DOCKER}" = "true" ]; then

containers/codespaces-linux/.devcontainer/library-scripts/git-lfs-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ install_using_apt() {
138138
curl -sSL "${GIT_LFS_ARCHIVE_GPG_KEY_URI}" | gpg --dearmor > /usr/share/keyrings/gitlfs-archive-keyring.gpg
139139
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
140140

141-
if ! apt-get update && apt-get install -yq git-lfs${version_suffix}; then
141+
if ! (apt-get update && apt-get install -yq git-lfs${version_suffix}); then
142142
rm -f /etc/apt/sources.list.d/git-lfs.list
143143
return 1
144144
fi

0 commit comments

Comments
 (0)