@@ -22,7 +22,10 @@ enum UnitySetupComponent {
22
22
Mac_IL2CPP = (1 -shl 14 )
23
23
Lumin = (1 -shl 15 )
24
24
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
26
29
}
27
30
28
31
[Flags ()]
@@ -390,22 +393,27 @@ function Find-UnitySetupInstaller {
390
393
$installerExtension = " exe"
391
394
}
392
395
([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 = " "
394
399
}
395
400
([OperatingSystem ]::Mac) {
396
401
$targetSupport = " MacEditorTargetInstaller"
397
402
$installerExtension = " pkg"
398
403
}
399
404
}
400
405
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 $"
402
409
403
410
$knownBaseUrls = @ (
404
411
" https://download.unity3d.com/download_unity" ,
405
412
" https://netstorage.unity3d.com/unity" ,
406
413
" https://beta.unity3d.com/download"
407
414
)
408
415
416
+ # For Linux this hashtable will be rewritten later
409
417
$installerTemplates = @ {
410
418
[UnitySetupComponent ]::UWP = " $targetSupport /UnitySetup-UWP-.NET-Support-for-Editor-$Version .$installerExtension " ,
411
419
" $targetSupport /UnitySetup-Metro-Support-for-Editor-$Version .$installerExtension " ,
@@ -443,9 +451,7 @@ function Find-UnitySetupInstaller {
443
451
}
444
452
([OperatingSystem ]::Linux) {
445
453
$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 " ;
449
455
}
450
456
([OperatingSystem ]::Mac) {
451
457
$setupComponent = [UnitySetupComponent ]::Mac
@@ -526,10 +532,52 @@ function Find-UnitySetupInstaller {
526
532
throw " Could not find archives for Unity version $Version "
527
533
}
528
534
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 "
530
578
531
579
if ($knownBaseUrls -notcontains $linkComponents [0 ]) {
532
- $knownBaseUrls = $linkComponents [0 ], $knownBaseUrls
580
+ $knownBaseUrls = @ ( $linkComponents [0 ]) + $knownBaseUrls
533
581
}
534
582
else {
535
583
$knownBaseUrls = $knownBaseUrls | Sort-Object - Property @ { Expression = { [math ]::Abs(($_.CompareTo ($linkComponents [0 ]))) }; Ascending = $true }
0 commit comments