@@ -389,10 +389,6 @@ function Find-UnitySetupInstaller {
389
389
390
390
[parameter (Mandatory = $false )]
391
391
[string ]$Cache = [io.Path ]::Combine(" ~" , " .unitysetup" )
392
-
393
- # ,
394
- # [parameter(Mandatory = $false)]
395
- # [switch]$Verbose = $false
396
392
)
397
393
398
394
# Note that this has to happen before calculating the full path since
@@ -584,23 +580,28 @@ function Find-UnitySetupInstaller {
584
580
585
581
Write-Verbose " Saving installer to $localCachedInstaller "
586
582
587
- Invoke-WebRequest $installerUrl - UseBasicParsing | Set-Content - Path $localCachedInstaller
583
+ Invoke-WebRequest $installerUrl - OutFile $localCachedInstaller
584
+
585
+ chmod + x $localCachedInstaller
588
586
589
587
# Configuration file for installer
590
588
$iniFileName = " unity-$Version -linux.ini"
591
589
$iniUrl = " $baseUrl /$iniFileName "
592
590
593
591
# PsIni can read only from files and from stdin
594
- $localCachedIni = " $Cache /$iniFileName "
592
+ $localCachedIni = " $cachedInstallerBasePath /$iniFileName "
593
+
594
+ Invoke-WebRequest $iniUrl - UseBasicParsing - OutFile $localCachedIni
595
595
596
- Invoke-WebRequest $iniUrl - UseBasicParsing | Set-Content - Path $localCachedIni
596
+ Write-Verbose $localCachedIni
597
597
598
598
$iniContent = Get-IniContent $localCachedIni
599
599
600
600
# fill from scratch accessible targets using retrieved .ini
601
601
$installerTemplates = @ {}
602
602
603
603
foreach ($section in $iniContent.GetEnumerator ()) {
604
+ # replace "-" with "_" to match enum entries
604
605
$sectionName = $section.Name.Replace (' -' , " _" )
605
606
$url = $iniContent [$section.Name ].url
606
607
@@ -1024,67 +1025,60 @@ function Install-UnitySetupPackage {
1024
1025
}
1025
1026
}
1026
1027
([OperatingSystem ]::Linux) {
1027
-
1028
- $VerbosePreference = " Continue "
1028
+ # Assume that UnitySetup in the same folder as package
1029
+ $basePackagePath = [ System.IO.Path ]::GetDirectoryName( $Package .Path )
1029
1030
1030
- # TODO: assert that tar and 7z are installed
1031
+ $versionRegEx = " (\d+)\.(\d+)\.(\d+)([fpba])(\d+)"
1032
+ if (-not ($Package.Path -match $versionRegEx )) {
1033
+ throw " Can't determine Unity version from package"
1034
+ }
1031
1035
1032
- Write-Verbose " Package path: $ ( $Package.Path ) "
1033
- Write-Verbose " Destination: $Destination "
1036
+ $version = $Matches [0 ]
1034
1037
1035
- $isTarXz = $Package.Path -match " .*\.tar\.xz"
1036
- $isPkg = $Package.Path -match " .*\.pkg"
1038
+ # installer is expected to be already donwloaded to the same location during Find-UnitySetupInstaller invocation
1039
+ $installerName = " UnitySetup-$version "
1040
+ $installerPath = " $basePackagePath /$installerName "
1037
1041
1038
- if ($isTarXz ) {
1039
- Write-Verbose " .tar.xz"
1042
+ if (-not (Test-Path $installerPath )) {
1043
+ throw " Can't find Unity installer, expected at $installerPath "
1044
+ }
1040
1045
1041
- $unpackedDir = $ ( Resolve-Path " $ ( $ Package.Path ) " ) -replace ' \.tar\.xz$ ' , ' '
1042
- New-Item - ItemType Directory - Force " $unpackedDir " | Out-Null
1046
+ Write-Verbose " Package path: $ ( $ Package.Path ) "
1047
+ Write-Verbose " Destination: $Destination "
1043
1048
1044
- Write-Verbose " Unpack $ ( $Package .Path ) to $unpackedDir "
1049
+ Import-Module PsIni - MinimumVersion ' 3.1.3 ' - ErrorAction Stop
1045
1050
1046
- $startProcessArgs = @ {
1047
- ' FilePath' = ' tar' ;
1048
- ' ArgumentList' = @ (" xf" , $Package.Path , " -C" , " $unpackedDir " , " -v" );
1049
- ' PassThru' = $true ;
1050
- ' Wait' = $true ;
1051
- }
1051
+ $iniFileName = " unity-$Version -linux.ini"
1052
+ $iniPath = " $basePackagePath /$iniFileName "
1052
1053
1053
- StartProcessWithArgs($startProcessArgs )
1054
- }
1055
- elseif ($isPkg ) {
1056
- Write-Verbose " .pkg"
1054
+ $iniContent = Get-IniContent $iniPath
1057
1055
1058
- $unpackedDir = $ (Resolve-Path " $ ( $Package.Path ) " ) -replace ' \.pkg$' , ' '
1059
- New-Item - ItemType Directory - Force " $unpackedDir " | Out-Null
1056
+ $componentName = " "
1057
+ foreach ($section in $iniContent.GetEnumerator ()) {
1058
+ $sectionName = $section.Name
1059
+ $url = $iniContent [$section.Name ].url # e.g. "LinuxEditorInstaller/Unity.tar.xz"
1060
1060
1061
- Write-Verbose " Unpack $ ( $Package.Path ) to $unpackedDir "
1061
+ # this should match package name
1062
+ $urlFileName = [System.IO.Path ]::GetFileName($url ) # e.g. "Unity.tar.xz"
1062
1063
1063
- $startProcessArgs = @ {
1064
- ' FilePath' = ' 7z' ;
1065
- ' ArgumentList' = @ (" x" , $Package.Path , " -o$unpackedDir /" , " -t*" , " -y" );
1066
- ' PassThru' = $true ;
1067
- ' Wait' = $true ;
1068
- }
1064
+ Write-Verbose " Retrieved $url for $sectionName "
1069
1065
1070
- StartProcessWithArgs( $startProcessArgs )
1071
- }
1072
- else {
1073
- throw " $ ( $Package .Path ) has unsupported archive format "
1066
+ if ( $Package .Path -like " * $urlFileName " ) {
1067
+ $componentName = $sectionName
1068
+ break
1069
+ }
1074
1070
}
1075
1071
1076
- $pkgInfo = [xml ](Get-Content ./ TargetSupport.pkg.tmp/ PackageInfo)
1077
- $targetName = basename $ ($pkgInfo .' pkg-info' .' install-location' )
1078
-
1079
- Write-Verbose " targetName: $targetName "
1072
+ if (-not $componentName ) {
1073
+ throw " Could not determine proper component name for $ ( $Package.Path ) "
1074
+ }
1080
1075
1081
- return
1076
+ # Note: this way user will be asked for license confirmation.
1077
+ # To bypass it, one should use "yes | <command>"
1082
1078
1083
- $payloadPath = " $unpackedDir /TargetSupport.pkg.tmp/Payload"
1084
- # extract /TargetSupport.pkg.tmp/Payload to destination
1085
1079
$startProcessArgs = @ {
1086
- ' FilePath' = ' 7z ' ;
1087
- ' ArgumentList' = @ (" x " , $Package .Path , " -o $unpackedDir " , " -t* " );
1080
+ ' FilePath' = " $installerPath " ;
1081
+ ' ArgumentList' = @ (' -u ' , ' -l ' , $Destination , ' -d ' , $basePackagePath , ' -c ' , $componentName );
1088
1082
' PassThru' = $true ;
1089
1083
' Wait' = $true ;
1090
1084
}
0 commit comments