Skip to content

Commit 4ed1c6d

Browse files
abdurriqCopilotKaniska244
authored
Fix conda installation failure due to SHA1 signature rejection (#1576)
Fix conda installation failure due to SHA1 signature rejection (#1565) * Initial plan * Fix conda installation by switching from apt repository to direct Miniconda installer * Add error handling for Miniconda download and installation * Use APT::Key::GPGVCommand=1 option to bypass SHA1 signature check * Fix version to 1.2.1 for semantic versioning * Revert to Miniconda installer approach - APT option caused gpgv errors * Use mktemp for secure temporary file creation * Replace Miniconda installer with direct .deb package download and apt install * Fix apt-get install syntax and improve error handling * Fix package filename - use architecture-specific deb and extract Filename from Packages * Update version to 1.2.3 * Fix apt-get install path - remove ./ prefix for absolute paths * Fix version matching for specific conda versions - handle version suffixes --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Kaniska <kaniska244@github.com>
1 parent 29e3e86 commit 4ed1c6d

File tree

2 files changed

+107
-49
lines changed

2 files changed

+107
-49
lines changed
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
2-
"id": "conda",
3-
"version": "1.0.10",
4-
"name": "Conda",
5-
"description": "A cross-platform, language-agnostic binary package manager",
6-
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda",
7-
"options": {
8-
"version": {
9-
"type": "string",
10-
"proposals": [
11-
"latest",
12-
"4.11.0",
13-
"4.12.0"
14-
],
15-
"default": "latest",
16-
"description": "Select or enter a conda version."
17-
},
18-
"addCondaForge": {
19-
"type": "boolean",
20-
"default": false,
21-
"description": "Add conda-forge channel to the config?"
22-
}
2+
"id": "conda",
3+
"version": "1.2.5",
4+
"name": "Conda",
5+
"description": "A cross-platform, language-agnostic binary package manager",
6+
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest",
12+
"4.11.0",
13+
"4.12.0"
14+
],
15+
"default": "latest",
16+
"description": "Select or enter a conda version."
2317
},
24-
"containerEnv": {
25-
"CONDA_DIR": "/opt/conda",
26-
"CONDA_SCRIPT":"/opt/conda/etc/profile.d/conda.sh",
27-
"PATH": "/opt/conda/bin:${PATH}"
28-
},
29-
"customizations": {
30-
"vscode": {
31-
"settings": {
32-
"github.copilot.chat.codeGeneration.instructions": [
33-
{
34-
"text": "This dev container includes the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
35-
}
36-
]
37-
}
38-
}
39-
},
40-
"installsAfter": [
41-
"ghcr.io/devcontainers/features/common-utils"
42-
]
18+
"addCondaForge": {
19+
"type": "boolean",
20+
"default": false,
21+
"description": "Add conda-forge channel to the config?"
22+
}
23+
},
24+
"containerEnv": {
25+
"CONDA_DIR": "/opt/conda",
26+
"CONDA_SCRIPT": "/opt/conda/etc/profile.d/conda.sh",
27+
"PATH": "/opt/conda/bin:${PATH}"
28+
},
29+
"customizations": {
30+
"vscode": {
31+
"settings": {
32+
"github.copilot.chat.codeGeneration.instructions": [
33+
{
34+
"text": "This dev container includes the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
35+
}
36+
]
37+
}
38+
}
39+
},
40+
"installsAfter": [
41+
"ghcr.io/devcontainers/features/common-utils"
42+
]
4343
}

src/conda/install.sh

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,78 @@ if ! conda --version &> /dev/null ; then
8383
usermod -a -G conda "${USERNAME}"
8484

8585
# Install dependencies
86-
check_packages curl ca-certificates gnupg2
86+
check_packages curl ca-certificates
8787

8888
echo "Installing Conda..."
8989

90-
curl -sS https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > /usr/share/keyrings/conda-archive-keyring.gpg
91-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list
92-
apt-get update -y
93-
94-
CONDA_PKG="conda=${VERSION}-0"
90+
# Download .deb package directly from repository (bypassing SHA1 signature issue)
91+
TEMP_DEB="$(mktemp -t conda_XXXXXX.deb)"
92+
CONDA_REPO_BASE="https://repo.anaconda.com/pkgs/misc/debrepo/conda"
93+
94+
# Determine package filename based on requested version
95+
ARCH="$(dpkg --print-architecture 2>/dev/null || echo "amd64")"
96+
PACKAGES_URL="https://repo.anaconda.com/pkgs/misc/debrepo/conda/dists/stable/main/binary-${ARCH}/Packages"
97+
9598
if [ "${VERSION}" = "latest" ]; then
96-
CONDA_PKG="conda"
99+
# For latest, we need to query the repository to find the current version
100+
echo "Fetching package list to determine latest version..."
101+
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | head -n 31)
102+
CONDA_VERSION=$(echo "${CONDA_PKG_INFO}" | grep "^Version:" | head -n 1 | awk '{print $2}')
103+
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
104+
105+
if [ -z "${CONDA_VERSION}" ] || [ -z "${CONDA_FILENAME}" ]; then
106+
echo "ERROR: Could not determine latest conda version or filename from ${PACKAGES_URL}"
107+
echo "This may indicate an unsupported architecture or repository unavailability."
108+
rm -f "${TEMP_DEB}"
109+
exit 1
110+
fi
111+
112+
CONDA_PKG_NAME="${CONDA_FILENAME}"
113+
else
114+
# For specific versions, query the Packages file to find the exact filename
115+
echo "Fetching package list to find version ${VERSION}..."
116+
# Search for version pattern - user may specify 4.12.0 but package has 4.12.0-0
117+
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | grep -B 5 -A 25 "^Version: ${VERSION}")
118+
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
119+
120+
if [ -z "${CONDA_FILENAME}" ]; then
121+
echo "ERROR: Could not find conda version ${VERSION} in ${PACKAGES_URL}"
122+
echo "Please verify the version specified is valid."
123+
rm -f "${TEMP_DEB}"
124+
exit 1
125+
fi
126+
127+
CONDA_PKG_NAME="${CONDA_FILENAME}"
97128
fi
98-
99-
check_packages $CONDA_PKG
129+
130+
# Download the .deb package
131+
CONDA_DEB_URL="${CONDA_REPO_BASE}/${CONDA_PKG_NAME}"
132+
echo "Downloading conda package from ${CONDA_DEB_URL}..."
133+
134+
if ! curl -fsSL "${CONDA_DEB_URL}" -o "${TEMP_DEB}"; then
135+
echo "ERROR: Failed to download conda .deb package from ${CONDA_DEB_URL}"
136+
echo "Please verify the version specified is valid."
137+
rm -f "${TEMP_DEB}"
138+
exit 1
139+
fi
140+
141+
# Verify the package was downloaded successfully
142+
if [ ! -f "${TEMP_DEB}" ] || [ ! -s "${TEMP_DEB}" ]; then
143+
echo "ERROR: Conda .deb package file is missing or empty"
144+
rm -f "${TEMP_DEB}"
145+
exit 1
146+
fi
147+
148+
# Install the package using apt (which handles dependencies automatically)
149+
echo "Installing conda package..."
150+
if ! apt-get install -y "${TEMP_DEB}"; then
151+
echo "ERROR: Failed to install conda package"
152+
rm -f "${TEMP_DEB}"
153+
exit 1
154+
fi
155+
156+
# Clean up downloaded package
157+
rm -f "${TEMP_DEB}"
100158

101159
CONDA_SCRIPT="/opt/conda/etc/profile.d/conda.sh"
102160
. $CONDA_SCRIPT

0 commit comments

Comments
 (0)