@@ -314,6 +314,10 @@ get_machine_architecture() {
314
314
echo " ppc64le"
315
315
return 0
316
316
;;
317
+ loongarch64)
318
+ echo " loongarch64"
319
+ return 0
320
+ ;;
317
321
esac
318
322
fi
319
323
@@ -355,6 +359,10 @@ get_normalized_architecture_from_architecture() {
355
359
echo " ppc64le"
356
360
return 0
357
361
;;
362
+ loongarch64)
363
+ echo " loongarch64"
364
+ return 0
365
+ ;;
358
366
esac
359
367
360
368
say_err " Architecture \` $architecture \` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues"
@@ -546,6 +554,40 @@ is_dotnet_package_installed() {
546
554
fi
547
555
}
548
556
557
+ # args:
558
+ # downloaded file - $1
559
+ # remote_file_size - $2
560
+ validate_remote_local_file_sizes ()
561
+ {
562
+ eval $invocation
563
+
564
+ local downloaded_file=" $1 "
565
+ local remote_file_size=" $2 "
566
+ local file_size=' '
567
+
568
+ if [[ " $OSTYPE " == " linux-gnu" * ]]; then
569
+ file_size=" $( stat -c ' %s' " $downloaded_file " ) "
570
+ elif [[ " $OSTYPE " == " darwin" * ]]; then
571
+ # hardcode in order to avoid conflicts with GNU stat
572
+ file_size=" $( /usr/bin/stat -f ' %z' " $downloaded_file " ) "
573
+ fi
574
+
575
+ if [ -n " $file_size " ]; then
576
+ say " Downloaded file size is $file_size bytes."
577
+
578
+ if [ -n " $remote_file_size " ] && [ -n " $file_size " ]; then
579
+ if [ " $remote_file_size " -ne " $file_size " ]; then
580
+ say " The remote and local file sizes are not equal. The remote file size is $remote_file_size bytes and the local size is $file_size bytes. The local package may be corrupted."
581
+ else
582
+ say " The remote and local file sizes are equal."
583
+ fi
584
+ fi
585
+
586
+ else
587
+ say " Either downloaded or local package size can not be measured. One of them may be corrupted."
588
+ fi
589
+ }
590
+
549
591
# args:
550
592
# azure_feed - $1
551
593
# channel - $2
@@ -914,14 +956,39 @@ copy_files_or_dirs_from_list() {
914
956
done
915
957
}
916
958
959
+ # args:
960
+ # zip_uri - $1
961
+ get_remote_file_size () {
962
+ local zip_uri=" $1 "
963
+
964
+ if machine_has " curl" ; then
965
+ file_size=$( curl -sI " $zip_uri " | grep -i content-length | awk ' { num = $2 + 0; print num }' )
966
+ elif machine_has " wget" ; then
967
+ file_size=$( wget --spider --server-response -O /dev/null " $zip_uri " 2>&1 | grep -i ' Content-Length:' | awk ' { num = $2 + 0; print num }' )
968
+ else
969
+ say " Neither curl nor wget is available on this system."
970
+ return
971
+ fi
972
+
973
+ if [ -n " $file_size " ]; then
974
+ say " Remote file $zip_uri size is $file_size bytes."
975
+ echo " $file_size "
976
+ else
977
+ say_verbose " Content-Length header was not extracted for $zip_uri ."
978
+ echo " "
979
+ fi
980
+ }
981
+
917
982
# args:
918
983
# zip_path - $1
919
984
# out_path - $2
985
+ # remote_file_size - $3
920
986
extract_dotnet_package () {
921
987
eval $invocation
922
988
923
989
local zip_path=" $1 "
924
990
local out_path=" $2 "
991
+ local remote_file_size=" $3 "
925
992
926
993
local temp_out_path=" $( mktemp -d " $temporary_file_template " ) "
927
994
@@ -931,9 +998,13 @@ extract_dotnet_package() {
931
998
local folders_with_version_regex=' ^.*/[0-9]+\.[0-9]+[^/]+/'
932
999
find " $temp_out_path " -type f | grep -Eo " $folders_with_version_regex " | sort | copy_files_or_dirs_from_list " $temp_out_path " " $out_path " false
933
1000
find " $temp_out_path " -type f | grep -Ev " $folders_with_version_regex " | copy_files_or_dirs_from_list " $temp_out_path " " $out_path " " $override_non_versioned_files "
934
-
1001
+
1002
+ validate_remote_local_file_sizes " $zip_path " " $remote_file_size "
1003
+
935
1004
rm -rf " $temp_out_path "
936
- rm -f " $zip_path " && say_verbose " Temporary zip file $zip_path was removed"
1005
+ if [ -z ${keep_zip+x} ]; then
1006
+ rm -f " $zip_path " && say_verbose " Temporary zip file $zip_path was removed"
1007
+ fi
937
1008
938
1009
if [ " $failed " = true ]; then
939
1010
say_err " Extraction failed"
@@ -1427,9 +1498,10 @@ install_dotnet() {
1427
1498
eval $invocation
1428
1499
local download_failed=false
1429
1500
local download_completed=false
1501
+ local remote_file_size=0
1430
1502
1431
1503
mkdir -p " $install_root "
1432
- zip_path=" $( mktemp " $temporary_file_template " ) "
1504
+ zip_path=" ${zip_path :- $ (mktemp " $temporary_file_template " )} "
1433
1505
say_verbose " Zip path: $zip_path "
1434
1506
1435
1507
for link_index in " ${! download_links[@]} "
@@ -1467,8 +1539,10 @@ install_dotnet() {
1467
1539
return 1
1468
1540
fi
1469
1541
1542
+ remote_file_size=" $( get_remote_file_size " $download_link " ) "
1543
+
1470
1544
say " Extracting zip from $download_link "
1471
- extract_dotnet_package " $zip_path " " $install_root " || return 1
1545
+ extract_dotnet_package " $zip_path " " $install_root " " $remote_file_size " || return 1
1472
1546
1473
1547
# Check if the SDK version is installed; if not, fail the installation.
1474
1548
# if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed.
@@ -1618,6 +1692,14 @@ do
1618
1692
override_non_versioned_files=false
1619
1693
non_dynamic_parameters+=" $name "
1620
1694
;;
1695
+ --keep-zip|-[Kk]eep[Zz]ip)
1696
+ keep_zip=true
1697
+ non_dynamic_parameters+=" $name "
1698
+ ;;
1699
+ --zip-path|-[Zz]ip[Pp]ath)
1700
+ shift
1701
+ zip_path=" $1 "
1702
+ ;;
1621
1703
-? |--? |-h|--help|-[Hh]elp)
1622
1704
script_name=" $( basename " $0 " ) "
1623
1705
echo " .NET Tools Installer"
1663
1745
echo " -InstallDir"
1664
1746
echo " --architecture <ARCHITECTURE> Architecture of dotnet binaries to be installed, Defaults to \` $architecture \` ."
1665
1747
echo " --arch,-Architecture,-Arch"
1666
- echo " Possible values: x64, arm, arm64, s390x and ppc64le "
1748
+ echo " Possible values: x64, arm, arm64, s390x, ppc64le and loongarch64 "
1667
1749
echo " --os <system> Specifies operating system to be used when selecting the installer."
1668
1750
echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6."
1669
1751
echo " In case any other value is provided, the platform will be determined by the script based on machine configuration."
1688
1770
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
1689
1771
echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
1690
1772
echo " Note: global.json must have a value for 'SDK:Version'"
1773
+ echo " --keep-zip,-KeepZip If set, downloaded file is kept."
1774
+ echo " --zip-path, -ZipPath If set, downloaded file is stored at the specified path."
1691
1775
echo " -?,--?,-h,--help,-Help Shows this help message"
1692
1776
echo " "
1693
1777
echo " Install Location:"
0 commit comments