@@ -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
94107if ! 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
158162fi
159163
160164# Display a notice on conda when not running in GitHub Codespaces
0 commit comments