Skip to content

Commit

Permalink
Merged PR 30677: Revert changes to packaging.psm1
Browse files Browse the repository at this point in the history
Merged PR 30675: Revert changes to packaging.psm1

Revert changes to packaging.psm1
  • Loading branch information
Patrick Meinecke committed Apr 6, 2024
1 parent 4dfadc6 commit e29d8bf
Showing 1 changed file with 4 additions and 41 deletions.
45 changes: 4 additions & 41 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -889,54 +889,17 @@ function Update-PSSignedBuildFolder
[string[]] $RemoveFilter = ('*.pdb', '*.zip', '*.r2rmap')
)

$BuildPathNormalized = (Get-Item $BuildPath).FullName
$SignedFilesPathNormalized = (Get-Item $SignedFilesPath).FullName

Write-Verbose -Verbose "BuildPath = $BuildPathNormalized"
Write-Verbose -Verbose "SignedFilesPath = $signedFilesPath"

# Replace unsigned binaries with signed
$signedFilesFilter = Join-Path -Path $SignedFilesPathNormalized -ChildPath '*'
Write-Verbose -Verbose "signedFilesFilter = $signedFilesFilter"

$signedFilesFilter = Join-Path -Path $SignedFilesPath -ChildPath '*'
Get-ChildItem -Path $signedFilesFilter -Recurse -File | Select-Object -ExpandProperty FullName | ForEach-Object -Process {
Write-Verbose -Verbose "Processing $_"

# Agents seems to be on a case sensitive file system
if ($IsLinux) {
$relativePath = $_.Replace($SignedFilesPathNormalized, '')
} else {
$relativePath = $_.ToLowerInvariant().Replace($SignedFilesPathNormalized.ToLowerInvariant(), '')
}

Write-Verbose -Verbose "relativePath = $relativePath"
$destination = (Get-Item (Join-Path -Path $BuildPathNormalized -ChildPath $relativePath)).FullName
Write-Verbose -Verbose "destination = $destination"
$relativePath = $_.ToLowerInvariant().Replace($SignedFilesPath.ToLowerInvariant(),'')
$destination = Join-Path -Path $BuildPath -ChildPath $relativePath
Write-Log "replacing $destination with $_"

if (-not (Test-Path $destination)) {
$parent = Split-Path -Path $destination -Parent
$exists = Test-Path -Path $parent

if ($exists) {
Write-Verbose -Verbose "Parent:"
Get-ChildItem -Path $parent | Select-Object -ExpandProperty FullName | Write-Verbose -Verbose
}

Write-Error "File not found: $destination, parent - $parent exists: $exists"
}

$signature = Get-AuthenticodeSignature -FilePath $_

if ($signature.Status -ne 'Valid') {
Write-Error "Invalid signature for $_"
}

Copy-Item -Path $_ -Destination $destination -Force
}

foreach($filter in $RemoveFilter) {
$removePath = Join-Path -Path $BuildPathNormalized -ChildPath $filter
$removePath = Join-Path -Path $BuildPath -ChildPath $filter
Remove-Item -Path $removePath -Recurse -Force
}
}
Expand Down

0 comments on commit e29d8bf

Please sign in to comment.