Files
bible-app/pre-extract-wincodesign.ps1
T

117 lines
4.7 KiB
PowerShell
Raw Normal View History

2026-09-24 13:05:20 -04:00
# Pre-extract winCodeSign archive to avoid symlink errors
# This script monitors for the archive download and extracts it manually
$cacheDir = "$env:LOCALAPPDATA\electron-builder\Cache\winCodeSign"
$maxWait = 60 # Wait up to 60 seconds
$checkInterval = 1 # Check every second
Write-Host "Monitoring for winCodeSign archive download..."
for ($i = 0; $i -lt $maxWait; $i++) {
Start-Sleep -Seconds $checkInterval
# Look for .7z files in the cache directory
$archives = Get-ChildItem -Path $cacheDir -Filter "*.7z" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending
if ($archives) {
$archive = $archives[0]
$outputDir = Join-Path $cacheDir ([System.IO.Path]::GetFileNameWithoutExtension($archive.Name))
# Check if already extracted
if (Test-Path $outputDir) {
Write-Host "Archive already extracted: $outputDir"
# Create placeholder files for symlinks if they don't exist
$symlinks = @(
"darwin\10.12\lib\libcrypto.dylib",
"darwin\10.12\lib\libssl.dylib"
)
foreach ($symlink in $symlinks) {
$symlinkPath = Join-Path $outputDir $symlink
$symlinkDir = Split-Path $symlinkPath -Parent
if (-not (Test-Path $symlinkDir)) {
New-Item -ItemType Directory -Path $symlinkDir -Force | Out-Null
}
if (-not (Test-Path $symlinkPath)) {
New-Item -ItemType File -Path $symlinkPath -Force | Out-Null
Write-Host "Created placeholder for symlink: $symlink"
}
}
exit 0
}
Write-Host "Found archive: $($archive.FullName)"
Write-Host "Extracting to: $outputDir"
# Create output directory
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
# Use .NET's ZipFile class which handles archives better
try {
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($archive.FullName, $outputDir)
Write-Host "Extraction successful using .NET ZipFile"
} catch {
Write-Host "ZipFile extraction failed, trying 7zip..."
# Fallback to 7zip
$7zipPath = Join-Path $PSScriptRoot "node_modules\7zip-bin\win\x64\7za.exe"
if (Test-Path $7zipPath) {
$process = Start-Process -FilePath $7zipPath -ArgumentList "x", "-bd", "-y", "`"$($archive.FullName)`"", "`"-o$outputDir`"" -Wait -NoNewWindow -PassThru
# Create placeholder files for symlinks
$symlinks = @(
"darwin\10.12\lib\libcrypto.dylib",
"darwin\10.12\lib\libssl.dylib"
)
foreach ($symlink in $symlinks) {
$symlinkPath = Join-Path $outputDir $symlink
$symlinkDir = Split-Path $symlinkPath -Parent
if (-not (Test-Path $symlinkDir)) {
New-Item -ItemType Directory -Path $symlinkDir -Force | Out-Null
}
if (-not (Test-Path $symlinkPath)) {
New-Item -ItemType File -Path $symlinkPath -Force | Out-Null
Write-Host "Created placeholder for symlink: $symlink"
}
}
if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 2) {
Write-Host "Extraction completed (exit code: $($process.ExitCode))"
exit 0
}
}
}
# Create placeholder files for symlinks
$symlinks = @(
"darwin\10.12\lib\libcrypto.dylib",
"darwin\10.12\lib\libssl.dylib"
)
foreach ($symlink in $symlinks) {
$symlinkPath = Join-Path $outputDir $symlink
$symlinkDir = Split-Path $symlinkPath -Parent
if (-not (Test-Path $symlinkDir)) {
New-Item -ItemType Directory -Path $symlinkDir -Force | Out-Null
}
if (-not (Test-Path $symlinkPath)) {
New-Item -ItemType File -Path $symlinkPath -Force | Out-Null
Write-Host "Created placeholder for symlink: $symlink"
}
}
exit 0
}
}
Write-Host "Timeout waiting for archive download"
exit 1