@@ -22,7 +22,10 @@ enum UnitySetupComponent {
2222 Mac_IL2CPP = (1 -shl 14 )
2323 Lumin = (1 -shl 15 )
2424 Linux_IL2CPP = (1 -shl 16 )
25- All = (1 -shl 17 ) - 1
25+ Windows_Server = (1 -shl 17 )
26+ Linux_Server = (1 -shl 18 )
27+ Mac_Server = (1 -shl 19 )
28+ All = (1 -shl 20 ) - 1
2629}
2730
2831[Flags ()]
@@ -390,22 +393,27 @@ function Find-UnitySetupInstaller {
390393 $installerExtension = " exe"
391394 }
392395 ([OperatingSystem ]::Linux) {
393- throw " Find-UnitySetupInstaller has not been implemented on the Linux platform. Contributions welcomed!" ;
396+ # This is default, but it seems some packages are used from Mac
397+ $targetSupport = " LinuxEditorTargetInstaller"
398+ $installerExtension = " "
394399 }
395400 ([OperatingSystem ]::Mac) {
396401 $targetSupport = " MacEditorTargetInstaller"
397402 $installerExtension = " pkg"
398403 }
399404 }
400405
401- $unitySetupRegEx = " ^(.+)\/([a-z0-9]+)\/(.+)\/(.+)-(\d+)\.(\d+)\.(\d+)([fpba])(\d+).$installerExtension $"
406+ $hashRegEx = " ([a-z0-9]+)"
407+ $versionRegEx = " (\d+)\.(\d+)\.(\d+)([fpba])(\d+)"
408+ $unitySetupRegEx = " ^(.+)\/$hashRegEx \/(.+)\/(.+)-$versionRegEx .$installerExtension $"
402409
403410 $knownBaseUrls = @ (
404411 " https://download.unity3d.com/download_unity" ,
405412 " https://netstorage.unity3d.com/unity" ,
406413 " https://beta.unity3d.com/download"
407414 )
408415
416+ # For Linux this hashtable will be rewritten later
409417 $installerTemplates = @ {
410418 [UnitySetupComponent ]::UWP = " $targetSupport /UnitySetup-UWP-.NET-Support-for-Editor-$Version .$installerExtension " ,
411419 " $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ,
@@ -443,9 +451,7 @@ function Find-UnitySetupInstaller {
443451 }
444452 ([OperatingSystem ]::Linux) {
445453 $setupComponent = [UnitySetupComponent ]::Linux
446- # TODO: $installerTemplates[$setupComponent] = , "???/UnitySetup64-$Version.exe";
447-
448- throw " Find-UnitySetupInstaller has not been implemented on the Linux platform. Contributions welcomed!" ;
454+ $installerTemplates [$setupComponent ] = , " UnitySetup-$Version " ;
449455 }
450456 ([OperatingSystem ]::Mac) {
451457 $setupComponent = [UnitySetupComponent ]::Mac
@@ -526,10 +532,52 @@ function Find-UnitySetupInstaller {
526532 throw " Could not find archives for Unity version $Version "
527533 }
528534
529- $linkComponents = $prototypeLink -split $unitySetupRegEx -ne " "
535+ if ($currentOS -ne [OperatingSystem ]::Linux) {
536+ $linkComponents = $prototypeLink -split $unitySetupRegEx -ne " "
537+ }
538+ else {
539+ # For Linux we should get list of available components with their target
540+ Import-Module PsIni - MinimumVersion ' 3.1.3' - ErrorAction Stop
541+
542+ $linkComponents = $prototypeLink -split " /$hashRegEx /" -ne " "
543+
544+ $iniFileName = " unity-$Version -linux.ini"
545+ $baseUrl = $linkComponents [0 ] + " /" + $linkComponents [1 ]
546+ $iniLink = " $baseUrl /$iniFileName "
547+
548+ $linuxIni = Invoke-WebRequest $iniLink - UseBasicParsing
549+
550+ # PsIni can read only from files and from stdin
551+ $localCachedIni = " /tmp/$iniFileName "
552+
553+ Set-Content - Path $localCachedIni - Value $linuxIni
554+
555+ $iniContent = Get-IniContent $localCachedIni
556+
557+ # fill from scratch accessible targets using retrieved .ini
558+ $installerTemplates = @ {}
559+
560+ foreach ($section in $iniContent.GetEnumerator ()) {
561+ $sectionName = $section.Name.Replace (' -' , " _" )
562+ $url = $iniContent [$section.Name ].url
563+
564+ Write-Verbose " Retrieved $url for $sectionName "
565+
566+ switch ($sectionName ) {
567+ " Unity" { $component = [UnitySetupComponent ]::Linux }
568+ " Windows_Mono" { $component = [UnitySetupComponent ]::Windows }
569+ " Mac_Mono" { $component = [UnitySetupComponent ]::Mac }
570+ Default { $component = $sectionName }
571+ }
572+
573+ $installerTemplates [$component ] = $url
574+ }
575+ }
576+
577+ Write-Verbose " components: $linkComponents "
530578
531579 if ($knownBaseUrls -notcontains $linkComponents [0 ]) {
532- $knownBaseUrls = $linkComponents [0 ], $knownBaseUrls
580+ $knownBaseUrls = @ ( $linkComponents [0 ]) + $knownBaseUrls
533581 }
534582 else {
535583 $knownBaseUrls = $knownBaseUrls | Sort-Object - Property @ { Expression = { [math ]::Abs(($_.CompareTo ($linkComponents [0 ]))) }; Ascending = $true }
0 commit comments