Skip to content

Commit 8054e63

Browse files
authored
[conda] - Accept the terms of service for root and target user and conda cleanup (#1622)
* [conda] - Accept the terms of service for root and target user and conda cleanup * Removing the version bump. * Removing commented lines. * Retrigger test * Revert the notes change
1 parent ac24137 commit 8054e63

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/conda/install.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,23 @@ accept_anaconda_tos_if_needed() {
8686

8787
for channel in "https://repo.anaconda.com/pkgs/main" "https://repo.anaconda.com/pkgs/r"; do
8888
echo "Accepting Conda Terms of Service for ${channel}..."
89+
# Accept as root (for install-time commands)
8990
"${CONDA_DIR}/bin/conda" tos accept --override-channels --channel "${channel}"
91+
# Accept as the target user (for runtime usage)
92+
sudo_if "${CONDA_DIR}/bin/conda" tos accept --override-channels --channel "${channel}"
9093
done
9194
}
9295

96+
clean_conda_cache() {
97+
"${CONDA_DIR}/bin/conda" clean --all --yes
98+
find "${CONDA_DIR}" -type f -name '*.pyc' -delete
99+
find "${CONDA_DIR}" -type d -name '__pycache__' -exec rm -rf {} +
100+
rm -rf "${CONDA_DIR}/pkgs/cache" /root/.cache/pip
101+
if [ "${USERNAME}" != "root" ]; then
102+
rm -rf "/home/${USERNAME}/.cache/pip"
103+
fi
104+
}
105+
93106
# Install Conda if it's missing
94107
if ! conda --version &> /dev/null ; then
95108
if ! cat /etc/group | grep -e "^conda:" > /dev/null 2>&1; then
@@ -145,16 +158,7 @@ if ! conda --version &> /dev/null ; then
145158

146159
find "${CONDA_DIR}" -type d -print0 | xargs -n 1 -0 chmod g+s
147160

148-
# Temporary fixes
149-
# Due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23491
150-
install_user_package certifi
151-
# Due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-0286 and https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-23931
152-
install_user_package cryptography
153-
# Due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
154-
install_user_package setuptools
155-
156-
install_user_package pluggy
157-
161+
clean_conda_cache
158162
fi
159163

160164
# Display a notice on conda when not running in GitHub Codespaces
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
conda_channel_creation.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
install_conda_package_after_upgrade.sh

test/conda/scenarios.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"install_conda": {
3-
"image": "ubuntu:noble",
3+
"image": "mcr.microsoft.com/devcontainers/base:noble",
44
"features": {
55
"conda": {
66
"version": "latest",
@@ -9,12 +9,24 @@
99
}
1010
},
1111
"install_conda_package_after_upgrade": {
12-
"image": "ubuntu:noble",
12+
"image": "mcr.microsoft.com/devcontainers/base:noble",
1313
"features": {
1414
"conda": {}
1515
}
1616
},
1717
"conda_channel_creation": {
18+
"image": "mcr.microsoft.com/devcontainers/base:noble",
19+
"features": {
20+
"conda": {}
21+
}
22+
},
23+
"install_conda_package_after_upgrade_with_root": {
24+
"image": "ubuntu:noble",
25+
"features": {
26+
"conda": {}
27+
}
28+
},
29+
"conda_channel_creation_with_root": {
1830
"image": "ubuntu:noble",
1931
"features": {
2032
"conda": {}

0 commit comments

Comments
 (0)