@@ -58,8 +58,10 @@ elif command -v microdnf >/dev/null 2>&1; then
5858 PKG_MANAGER=" microdnf"
5959elif command -v tdnf > /dev/null 2>&1 ; then
6060 PKG_MANAGER=" tdnf"
61+ elif command -v apk > /dev/null 2>&1 ; then
62+ PKG_MANAGER=" apk"
6163else
62- echo " No supported package manager found. Supported: apt, dnf, yum, microdnf, tdnf"
64+ echo " No supported package manager found. Supported: apt, dnf, yum, microdnf, tdnf, apk "
6365 exit 1
6466fi
6567
@@ -85,6 +87,11 @@ clean_package_cache() {
8587 tdnf)
8688 tdnf clean all
8789 ;;
90+ apk)
91+ if [ " $( ls -1 /var/cache/apk/ 2> /dev/null | wc -l) " -gt 0 ]; then
92+ rm -rf /var/cache/apk/*
93+ fi
94+ ;;
8895 esac
8996}
9097
@@ -217,6 +224,12 @@ pkg_mgr_update() {
217224 tdnf)
218225 tdnf makecache || true
219226 ;;
227+ apk)
228+ if [ " $( find /var/cache/apk/* | wc -l) " = " 0" ]; then
229+ echo " Running apk update..."
230+ apk update
231+ fi
232+ ;;
220233 esac
221234}
222235
@@ -230,6 +243,9 @@ is_package_installed() {
230243 dnf|yum|microdnf|tdnf)
231244 rpm -q " $package " > /dev/null 2>&1
232245 ;;
246+ apk)
247+ apk info --installed " $package " > /dev/null 2>&1
248+ ;;
233249 esac
234250}
235251
@@ -266,6 +282,14 @@ check_packages() {
266282 " gnupg2" ) packages[$i ]=" gnupg" ;;
267283 esac
268284 ;;
285+ apk)
286+ case " ${packages[$i]} " in
287+ " libc6-dev" ) packages[$i ]=" libc-dev" ;;
288+ " python3-minimal" ) packages[$i ]=" python3" ;;
289+ " libpython3.*" ) packages[$i ]=" python3-dev" ;;
290+ " gnupg2" ) packages[$i ]=" gnupg" ;;
291+ esac
292+ ;;
269293 esac
270294 done
271295
@@ -295,6 +319,9 @@ check_packages() {
295319 tdnf)
296320 tdnf install -y " ${missing_packages[@]} "
297321 ;;
322+ apk)
323+ apk add --no-cache " ${missing_packages[@]} "
324+ ;;
298325 esac
299326 fi
300327}
@@ -317,6 +344,9 @@ case "$PKG_MANAGER" in
317344 check_packages python3 python3-devel || true
318345 # LLDB might not be available in Photon/Mariner
319346 ;;
347+ apk)
348+ check_packages lldb python3 python3-dev || true
349+ ;;
320350esac
321351
322352# Get architecture
@@ -348,6 +378,11 @@ case ${download_architecture} in
348378 ;;
349379esac
350380
381+ clibtype=" gnu"
382+ if ldd --version 2>&1 | grep -q ' musl' ; then
383+ clibtype=" musl"
384+ fi
385+
351386# Install Rust
352387umask 0002
353388if ! grep -e " ^rustlang:" /etc/group > /dev/null 2>&1 ; then
@@ -378,14 +413,14 @@ else
378413 fi
379414 echo " Installing Rust..."
380415 # Download and verify rustup sha
381- mkdir -p /tmp/rustup/target/${download_architecture} -unknown-linux-gnu /release/
382- curl -sSL --proto ' =https' --tlsv1.2 " https://static.rust-lang.org/rustup/dist/${download_architecture} -unknown-linux-gnu /rustup-init" -o /tmp/rustup/target/${download_architecture} -unknown-linux-gnu /release/rustup-init
383- curl -sSL --proto ' =https' --tlsv1.2 " https://static.rust-lang.org/rustup/dist/${download_architecture} -unknown-linux-gnu /rustup-init.sha256" -o /tmp/rustup/rustup-init.sha256
416+ mkdir -p /tmp/rustup/target/${download_architecture} -unknown-linux-${clibtype} /release/
417+ curl -sSL --proto ' =https' --tlsv1.2 " https://static.rust-lang.org/rustup/dist/${download_architecture} -unknown-linux-${clibtype} /rustup-init" -o /tmp/rustup/target/${download_architecture} -unknown-linux-${clibtype} /release/rustup-init
418+ curl -sSL --proto ' =https' --tlsv1.2 " https://static.rust-lang.org/rustup/dist/${download_architecture} -unknown-linux-${clibtype} /rustup-init.sha256" -o /tmp/rustup/rustup-init.sha256
384419 cd /tmp/rustup
385- cp /tmp/rustup/target/${download_architecture} -unknown-linux-gnu /release/rustup-init /tmp/rustup/rustup-init
420+ cp /tmp/rustup/target/${download_architecture} -unknown-linux-${clibtype} /release/rustup-init /tmp/rustup/rustup-init
386421 sha256sum -c rustup-init.sha256
387- chmod +x target/${download_architecture} -unknown-linux-gnu /release/rustup-init
388- target/${download_architecture} -unknown-linux-gnu /release/rustup-init -y --no-modify-path --profile " ${RUSTUP_PROFILE} " ${default_toolchain_arg}
422+ chmod +x target/${download_architecture} -unknown-linux-${clibtype} /release/rustup-init
423+ target/${download_architecture} -unknown-linux-${clibtype} /release/rustup-init -y --no-modify-path --profile " ${RUSTUP_PROFILE} " ${default_toolchain_arg}
389424 cd ~
390425 rm -rf /tmp/rustup
391426fi
0 commit comments