@@ -58,8 +58,10 @@ elif command -v microdnf >/dev/null 2>&1; then
58
58
PKG_MANAGER=" microdnf"
59
59
elif command -v tdnf > /dev/null 2>&1 ; then
60
60
PKG_MANAGER=" tdnf"
61
+ elif command -v apk > /dev/null 2>&1 ; then
62
+ PKG_MANAGER=" apk"
61
63
else
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 "
63
65
exit 1
64
66
fi
65
67
@@ -85,6 +87,11 @@ clean_package_cache() {
85
87
tdnf)
86
88
tdnf clean all
87
89
;;
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
+ ;;
88
95
esac
89
96
}
90
97
@@ -217,6 +224,12 @@ pkg_mgr_update() {
217
224
tdnf)
218
225
tdnf makecache || true
219
226
;;
227
+ apk)
228
+ if [ " $( find /var/cache/apk/* | wc -l) " = " 0" ]; then
229
+ echo " Running apk update..."
230
+ apk update
231
+ fi
232
+ ;;
220
233
esac
221
234
}
222
235
@@ -230,6 +243,9 @@ is_package_installed() {
230
243
dnf|yum|microdnf|tdnf)
231
244
rpm -q " $package " > /dev/null 2>&1
232
245
;;
246
+ apk)
247
+ apk info --installed " $package " > /dev/null 2>&1
248
+ ;;
233
249
esac
234
250
}
235
251
@@ -266,6 +282,14 @@ check_packages() {
266
282
" gnupg2" ) packages[$i ]=" gnupg" ;;
267
283
esac
268
284
;;
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
+ ;;
269
293
esac
270
294
done
271
295
@@ -295,6 +319,9 @@ check_packages() {
295
319
tdnf)
296
320
tdnf install -y " ${missing_packages[@]} "
297
321
;;
322
+ apk)
323
+ apk add --no-cache " ${missing_packages[@]} "
324
+ ;;
298
325
esac
299
326
fi
300
327
}
@@ -317,6 +344,9 @@ case "$PKG_MANAGER" in
317
344
check_packages python3 python3-devel || true
318
345
# LLDB might not be available in Photon/Mariner
319
346
;;
347
+ apk)
348
+ check_packages lldb python3 python3-dev || true
349
+ ;;
320
350
esac
321
351
322
352
# Get architecture
@@ -348,6 +378,11 @@ case ${download_architecture} in
348
378
;;
349
379
esac
350
380
381
+ clibtype=" gnu"
382
+ if ldd --version 2>&1 | grep -q ' musl' ; then
383
+ clibtype=" musl"
384
+ fi
385
+
351
386
# Install Rust
352
387
umask 0002
353
388
if ! grep -e " ^rustlang:" /etc/group > /dev/null 2>&1 ; then
@@ -378,14 +413,14 @@ else
378
413
fi
379
414
echo " Installing Rust..."
380
415
# 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
384
419
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
386
421
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}
389
424
cd ~
390
425
rm -rf /tmp/rustup
391
426
fi
0 commit comments