Skip to content

Commit

Permalink
[Updates] Automated vendor dotnet-install script (#1064)
Browse files Browse the repository at this point in the history
* Automated dotnet-install script update

* Bump version

* Update src/dotnet/devcontainer-feature.json

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com>
  • Loading branch information
3 people authored Jul 29, 2024
1 parent 51940aa commit 5f4d201
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/oryx/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "oryx",
"version": "1.3.4",
"version": "1.3.5",
"name": "Oryx",
"description": "Installs the oryx CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx",
Expand Down
30 changes: 25 additions & 5 deletions src/oryx/scripts/vendor/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ get_machine_architecture() {
if command -v uname > /dev/null; then
CPUName=$(uname -m)
case $CPUName in
armv1*|armv2*|armv3*|armv4*|armv5*|armv6*)
echo "armv6-or-below"
return 0
;;
armv*l)
echo "arm"
return 0
Expand All @@ -323,6 +327,10 @@ get_machine_architecture() {
echo "loongarch64"
return 0
;;
riscv64)
echo "riscv64"
return 0
;;
esac
fi

Expand All @@ -339,7 +347,13 @@ get_normalized_architecture_from_architecture() {
local architecture="$(to_lowercase "$1")"

if [[ $architecture == \<auto\> ]]; then
echo "$(get_machine_architecture)"
machine_architecture="$(get_machine_architecture)"
if [[ "$machine_architecture" == "armv6-or-below" ]]; then
say_err "Architecture \`$machine_architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues"
return 1
fi

echo $machine_architecture
return 0
fi

Expand Down Expand Up @@ -1013,7 +1027,7 @@ extract_dotnet_package() {
rm -rf "$temp_out_path"
if [ -z ${keep_zip+x} ]; then
rm -f "$zip_path" && say_verbose "Temporary zip file $zip_path was removed"
rm -f "$zip_path" && say_verbose "Temporary archive file $zip_path was removed"
fi
if [ "$failed" = true ]; then
Expand Down Expand Up @@ -1261,6 +1275,12 @@ get_download_link_from_aka_ms() {
http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' )
# They all need to be 301, otherwise some links are broken (except for the last, which is not a redirect but 200 or 404).
broken_redirects=$( echo "$http_codes" | sed '$d' | grep -v '301' )
# The response may end without final code 2xx/4xx/5xx somehow, e.g. network restrictions on www.bing.com causes redirecting to bing.com fails with connection refused.
# In this case it should not exclude the last.
last_http_code=$( echo "$http_codes" | tail -n 1 )
if ! [[ $last_http_code =~ ^(2|4|5)[0-9][0-9]$ ]]; then
broken_redirects=$( echo "$http_codes" | grep -v '301' )
fi
# All HTTP codes are 301 (Moved Permanently), the redirect link exists.
if [[ -z "$broken_redirects" ]]; then
Expand Down Expand Up @@ -1512,7 +1532,7 @@ install_dotnet() {
mkdir -p "$install_root"
zip_path="${zip_path:-$(mktemp "$temporary_file_template")}"
say_verbose "Zip path: $zip_path"
say_verbose "Archive path: $zip_path"
for link_index in "${!download_links[@]}"
do
Expand All @@ -1536,7 +1556,7 @@ install_dotnet() {
say "Failed to download $link_type link '$download_link': $download_error_msg"
;;
esac
rm -f "$zip_path" 2>&1 && say_verbose "Temporary zip file $zip_path was removed"
rm -f "$zip_path" 2>&1 && say_verbose "Temporary archive file $zip_path was removed"
else
download_completed=true
break
Expand All @@ -1551,7 +1571,7 @@ install_dotnet() {
remote_file_size="$(get_remote_file_size "$download_link")"
say "Extracting zip from $download_link"
say "Extracting archive from $download_link"
extract_dotnet_package "$zip_path" "$install_root" "$remote_file_size" || return 1
# Check if the SDK version is installed; if not, fail the installation.
Expand Down

0 comments on commit 5f4d201

Please sign in to comment.