Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
159e12c79a | ||
|
|
dae0123a17 |
+24
-3
@@ -17,6 +17,26 @@ function Require-Environment([string]$Name) {
|
||||
return $value
|
||||
}
|
||||
|
||||
function Test-PathIsWithinDirectory([string]$ParentDirectory, [string]$CandidateDirectory) {
|
||||
# [IO.Path]::GetRelativePath is not available in Windows PowerShell 5.1.
|
||||
# Compare complete paths with a separator boundary so, for example,
|
||||
# C:\workspace-other is not considered a child of C:\workspace.
|
||||
$parentPath = [IO.Path]::GetFullPath($ParentDirectory)
|
||||
$candidatePath = [IO.Path]::GetFullPath($CandidateDirectory)
|
||||
$directorySeparator = [IO.Path]::DirectorySeparatorChar.ToString()
|
||||
$alternateSeparator = [IO.Path]::AltDirectorySeparatorChar.ToString()
|
||||
|
||||
if ($candidatePath.Equals($parentPath, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
return $true
|
||||
}
|
||||
|
||||
if (-not $parentPath.EndsWith($directorySeparator) -and -not $parentPath.EndsWith($alternateSeparator)) {
|
||||
$parentPath += $directorySeparator
|
||||
}
|
||||
|
||||
return $candidatePath.StartsWith($parentPath, [StringComparison]::OrdinalIgnoreCase)
|
||||
}
|
||||
|
||||
function Get-ActualArchitecture {
|
||||
$architecture = $env:PROCESSOR_ARCHITEW6432
|
||||
if ([string]::IsNullOrWhiteSpace($architecture)) {
|
||||
@@ -98,8 +118,7 @@ if ($HostArch -ne (Get-ActualArchitecture)) { Fail "host-arch '$HostArch' does n
|
||||
$workspaceDirectory = [IO.Path]::GetFullPath($Workspace)
|
||||
if ([IO.Path]::IsPathRooted($ProjectPath)) { Fail 'project-path must be relative to the checked-out workspace.' }
|
||||
$ProjectDirectory = [IO.Path]::GetFullPath((Join-Path $workspaceDirectory $ProjectPath))
|
||||
$projectRelativePath = [IO.Path]::GetRelativePath($workspaceDirectory, $ProjectDirectory)
|
||||
if ($projectRelativePath -eq '..' -or $projectRelativePath.StartsWith("..$([IO.Path]::DirectorySeparatorChar)") -or [IO.Path]::IsPathRooted($projectRelativePath)) { Fail 'project-path must remain inside the checked-out workspace.' }
|
||||
if (-not (Test-PathIsWithinDirectory $workspaceDirectory $ProjectDirectory)) { Fail 'project-path must remain inside the checked-out workspace.' }
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $ProjectDirectory 'project.godot') -PathType Leaf)) { Fail "No project.godot was found in project-path '$ProjectPath'." }
|
||||
$PresetFile = Join-Path $ProjectDirectory 'export_presets.cfg'
|
||||
if (-not (Test-Path -LiteralPath $PresetFile -PathType Leaf)) { Fail "No export_presets.cfg was found in project-path '$ProjectPath'." }
|
||||
@@ -143,6 +162,7 @@ if (-not $editorExecutable) {
|
||||
$manifestPath = Join-Path $cacheDirectory 'SHA512-SUMS.txt'
|
||||
$editorArchive = Join-Path $cacheDirectory $editorAsset
|
||||
$templatesArchive = Join-Path $cacheDirectory $templatesAsset
|
||||
$templatesZipArchive = Join-Path $cacheDirectory ($templatesAsset -replace '\.tpz$', '.zip')
|
||||
$templatesStagingDirectory = Join-Path $cacheDirectory 'templates-staging'
|
||||
Invoke-WebRequest -Uri "$script:BaseUrl/SHA512-SUMS.txt" -OutFile $manifestPath
|
||||
$editorChecksum = Get-Checksum $manifestPath $editorAsset
|
||||
@@ -150,7 +170,8 @@ if (-not $editorExecutable) {
|
||||
Download-AndVerify $editorAsset $editorArchive $editorChecksum
|
||||
Download-AndVerify $templatesAsset $templatesArchive $templatesChecksum
|
||||
Expand-Archive -LiteralPath $editorArchive -DestinationPath $editorDirectory -Force
|
||||
Expand-Archive -LiteralPath $templatesArchive -DestinationPath $templatesStagingDirectory -Force
|
||||
Move-Item -LiteralPath $templatesArchive -Destination $templatesZipArchive
|
||||
Expand-Archive -LiteralPath $templatesZipArchive -DestinationPath $templatesStagingDirectory -Force
|
||||
Install-ExportTemplates $templatesStagingDirectory $templateDirectory $templatesAsset $templateVersion
|
||||
$editorExecutable = Find-Editor $editorDirectory
|
||||
if (-not $editorExecutable) { Fail 'The Godot editor archive did not contain an executable.' }
|
||||
|
||||
Reference in New Issue
Block a user