# Extract winCodeSign archive, creating dummy files for symlinks param( [string]$ArchivePath, [string]$OutputPath ) Write-Host "Extracting winCodeSign archive (handling symlinks)..." # Create output directory if (-not (Test-Path $OutputPath)) { New-Item -ItemType Directory -Path $OutputPath -Force | Out-Null } # Get 7zip path $7zipPath = Join-Path $PSScriptRoot "node_modules\7zip-bin\win\x64\7za.exe" if (-not (Test-Path $7zipPath)) { Write-Host "ERROR: 7zip not found at $7zipPath" exit 1 } # Extract with 7zip (will fail on symlinks, but that's OK) $process = Start-Process -FilePath $7zipPath -ArgumentList "x", "-bd", "-y", "-o`"$OutputPath`"", "`"$ArchivePath`"" -Wait -NoNewWindow -PassThru -RedirectStandardError "nul" # Create dummy files for the problematic symlinks (we don't need macOS files for Windows builds) $symlinkFiles = @( "darwin\10.12\lib\libcrypto.dylib", "darwin\10.12\lib\libssl.dylib" ) foreach ($symlink in $symlinkFiles) { $fullPath = Join-Path $OutputPath $symlink $dirPath = Split-Path $fullPath -Parent if (-not (Test-Path $dirPath)) { New-Item -ItemType Directory -Path $dirPath -Force | Out-Null } if (-not (Test-Path $fullPath)) { # Create empty file as placeholder New-Item -ItemType File -Path $fullPath -Force | Out-Null Write-Host "Created placeholder for: $symlink" } } # Return success even if 7zip had symlink errors (exit code 2) if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 2) { Write-Host "Extraction completed (symlinks handled)" exit 0 } else { Write-Host "Extraction failed with exit code: $($process.ExitCode)" exit $process.ExitCode }