@@ -132,14 +132,17 @@ case "$PLATFORM" in
132132 # Install OS dependencies
133133 progress 1 " Installing OS dependencies..."
134134 { $SUDO_CMD apt-get -y update || fail " Could not update OS package definitions." ; } >&2
135- { $SUDO_CMD apt-get -y install apt-transport-https ca-certificates curl gnupg gnupg-agent lsb-release software-properties-common chrony || fail " Could not install OS packages." ; } >&2
135+ { $SUDO_CMD apt-get -y install apt-transport-https ca-certificates curl gnupg gnupg-agent lsb-release chrony || fail " Could not install OS packages." ; } >&2
136136
137137 # Check for existing Docker installation
138138 progress 2 " Checking if Docker is installed..."
139139 dpkg-query -W -f=' ${Status}' docker-ce 2>&1 | grep -q -P ' ^install ok installed$' > /dev/null
140140 if [ $? != " 0" ]; then
141141 echo " Installing Docker..."
142- if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
142+ # Check for an available installation candidate
143+ REPO_FOUND=$( apt-cache policy docker-ce 2> /dev/null | awk ' /Candidate:/ {print $2}' )
144+ if [ -z " $REPO_FOUND " -o " $REPO_FOUND " = " (none)" ]; then
145+ echo " No installation candidate found for docker-ce. Setting up Docker repository..."
143146 # Install the Docker repo
144147 { $SUDO_CMD mkdir -p /etc/apt/keyrings || fail " Could not create APT keyrings directory." ; } >&2
145148 { curl -fsSL " https://download.docker.com/linux/$PLATFORM_NAME /gpg" | $SUDO_CMD gpg --dearmor -o /etc/apt/keyrings/docker.gpg || fail " Could not add docker repository key." ; } >&2
@@ -154,9 +157,11 @@ case "$PLATFORM" in
154157 dpkg-query -W -f=' ${Status}' docker-compose-plugin 2>&1 | grep -q -P ' ^install ok installed$' > /dev/null
155158 if [ $? != " 0" ]; then
156159 echo " Installing docker-compose-plugin..."
157- if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
158- # Install the Docker repo, removing the legacy one if it exists
159- { $SUDO_CMD add-apt-repository --remove " deb [arch=$( dpkg --print-architecture) ] https://download.docker.com/linux/$PLATFORM_NAME $( lsb_release -cs) stable" ; } 2> /dev/null
160+ # Check for an available installation candidate
161+ REPO_FOUND=$( apt-cache policy docker-compose-plugin 2> /dev/null | awk ' /Candidate:/ {print $2}' )
162+ if [ -z " $REPO_FOUND " -o " $REPO_FOUND " = " (none)" ]; then
163+ echo " No installation candidate found for docker-compose-plugin. Setting up Docker repository..."
164+ # Install the Docker repo
160165 { $SUDO_CMD mkdir -p /etc/apt/keyrings || fail " Could not create APT keyrings directory." ; } >&2
161166 { curl -fsSL " https://download.docker.com/linux/$PLATFORM_NAME /gpg" | $SUDO_CMD gpg --dearmor -o /etc/apt/keyrings/docker.gpg || fail " Could not add docker repository key." ; } >&2
162167 { echo " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$PLATFORM_NAME $( lsb_release -cs) stable" | $SUDO_CMD tee /etc/apt/sources.list.d/docker.list > /dev/null || fail " Could not add Docker repository." ; } >&2
@@ -267,9 +272,10 @@ else
267272 if [ $? != " 0" ]; then
268273 >&2 get_escalation_cmd
269274 echo " Installing docker-compose-plugin..."
270- if [ ! -f /etc/apt/sources.list.d/docker.list ]; then
271- # Install the Docker repo, removing the legacy one if it exists
272- { $SUDO_CMD add-apt-repository --remove " deb [arch=$( dpkg --print-architecture) ] https://download.docker.com/linux/$PLATFORM_NAME $( lsb_release -cs) stable" ; } 2> /dev/null
275+ # Check for an available installation candidate
276+ REPO_FOUND=$( apt-cache policy docker-compose-plugin 2> /dev/null | awk ' /Candidate:/ {print $2}' )
277+ if [ -z " $REPO_FOUND " -o " $REPO_FOUND " = " (none)" ]; then
278+ echo " No installation candidate found for docker-compose-plugin. Setting up Docker repository..."
273279 { $SUDO_CMD mkdir -p /etc/apt/keyrings || fail " Could not create APT keyrings directory." ; } >&2
274280 { curl -fsSL " https://download.docker.com/linux/$PLATFORM_NAME /gpg" | $SUDO_CMD gpg --dearmor -o /etc/apt/keyrings/docker.gpg || fail " Could not add docker repository key." ; } >&2
275281 { echo " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$PLATFORM_NAME $( lsb_release -cs) stable" | $SUDO_CMD tee /etc/apt/sources.list.d/docker.list > /dev/null || fail " Could not add Docker repository." ; } >&2
0 commit comments