@@ -45,10 +45,14 @@ elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
4545fi
4646
4747architecture=" $( uname -m) "
48- if [ " ${architecture} " != " x86_64" ]; then
49- echo " (!) Architecture $architecture unsupported"
50- exit 1
51- fi
48+ case " ${architecture} " in
49+ x86_64) MINICONDA_ARCH=" x86_64" ;;
50+ aarch64|arm64) MINICONDA_ARCH=" aarch64" ;;
51+ * )
52+ echo " (!) Architecture $architecture unsupported"
53+ exit 1
54+ ;;
55+ esac
5256
5357# Checks if packages are installed and installs them if not
5458check_packages () {
@@ -75,6 +79,17 @@ install_user_package() {
7579 sudo_if " ${CONDA_DIR} /bin/python3" -m pip install --user --upgrade " $PACKAGE "
7680}
7781
82+ accept_anaconda_tos_if_needed () {
83+ if ! " ${CONDA_DIR} /bin/conda" tos --help > /dev/null 2>&1 ; then
84+ return 0
85+ fi
86+
87+ for channel in " https://repo.anaconda.com/pkgs/main" " https://repo.anaconda.com/pkgs/r" ; do
88+ echo " Accepting Conda Terms of Service for ${channel} ..."
89+ " ${CONDA_DIR} /bin/conda" tos accept --override-channels --channel " ${channel} "
90+ done
91+ }
92+
7893# Install Conda if it's missing
7994if ! conda --version & > /dev/null ; then
8095 if ! cat /etc/group | grep -e " ^conda:" > /dev/null 2>&1 ; then
@@ -85,78 +100,36 @@ if ! conda --version &> /dev/null ; then
85100 # Install dependencies
86101 check_packages curl ca-certificates
87102
88- echo " Installing Conda..."
103+ echo " Installing Conda via Miniconda installer ..."
89104
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-
98- if [ " ${VERSION} " = " latest" ]; then
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} "
128- fi
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} "
105+ # Download and run the official Miniconda installer
106+ MINICONDA_INSTALLER=" $( mktemp -t miniconda_XXXXXX.sh) "
107+ MINICONDA_URL=" https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-${MINICONDA_ARCH} .sh"
108+
109+ echo " Downloading Miniconda installer from ${MINICONDA_URL} ..."
110+ if ! curl -fsSL --connect-timeout 10 --max-time 120 " ${MINICONDA_URL} " -o " ${MINICONDA_INSTALLER} " ; then
111+ echo " ERROR: Failed to download Miniconda installer from ${MINICONDA_URL} "
112+ rm -f " ${MINICONDA_INSTALLER} "
145113 exit 1
146114 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
115+
116+ # Run installer in batch mode (no prompts) and install to CONDA_DIR
117+ bash " ${MINICONDA_INSTALLER} " -b -p " ${CONDA_DIR} "
118+ rm -f " ${MINICONDA_INSTALLER} "
119+
120+ # Conda defaults channels now require a non-interactive ToS acknowledgement.
121+ accept_anaconda_tos_if_needed
122+
123+ # Install specific conda version if requested (latest Miniconda already bundles a recent conda)
124+ if [ " ${VERSION} " != " latest" ]; then
125+ echo " Installing conda version ${VERSION} ..."
126+ if ! " ${CONDA_DIR} /bin/conda" install -y " conda=${VERSION} " ; then
127+ echo " ERROR: Failed to install conda version ${VERSION} . Please verify the version is valid and available."
128+ exit 1
129+ fi
154130 fi
155-
156- # Clean up downloaded package
157- rm -f " ${TEMP_DEB} "
158131
159- CONDA_SCRIPT=" /opt/conda /etc/profile.d/conda.sh"
132+ CONDA_SCRIPT=" ${CONDA_DIR} /etc/profile.d/conda.sh"
160133 . $CONDA_SCRIPT
161134
162135 if [ " ${ADD_CONDA_FORGE} " = " true" ]; then
0 commit comments